私はPHPサーバーにJSON文字列をポストしようとしていますが、サーバー側で何も起こっていません。ここでPHPサーバーへのjava httpポスト、何も起こっていません
は、サーバーのコードです:
public void sendError(Error e)
{
String json = e.toJSONString();
try
{
if(url == null)
{
url = new URL("http://www.rstougaard.dk/errorHandler");
}
if(conn == null)
{
conn = (HttpURLConnection) url.openConnection();
}
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
conn.setRequestProperty("json", URLEncoder.encode(json));
output = new DataOutputStream(conn.getOutputStream());
conn.connect();
output.writeBytes("json=" + URLEncoder.encode(json, "UTF-8"));
output.flush();
BufferedReader input = new BufferedReader(new InputStreamReader(conn.getInputStream()));
while(input.ready())
{
System.out.println(input.readLine());
}
System.out.println(conn.getResponseCode() + " " + conn.getResponseMessage());
} catch (MalformedURLException ex)
{
Logger.getLogger(ConnectionController.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException exc)
{
Logger.getLogger(ConnectionController.class.getName()).log(Level.SEVERE, null, exc);
}
}
.getResponseCode()と.getResponseMessage()はそれぞれ '200' を返し、 'OK':
<?php
$json = $_POST['json'];
$decoded = json_decode($json);
echo($decoded);
?>
そしてここでは、Javaコードがあります。そして、inputStreamはJSON文字列が続くサイトからphpコードを出力します。これは私には奇妙なものです。
ここには何が見つかりませんか?私は私がチェックするために、カール使用して試してみました).setResponseMethodでPOST "(「をGET"。しかし、まだdidntの仕事。
EDIT
を変更した
EDIT
サーバーレスポンスですが、javaコード内のinputStreamと同じことです。ウェブサイトからhtml/phpコードを出力します。
サービス側をカールでテストしましたか? –
サーバーログを確認しましたか? – m02ph3u5
明日の前にサーバーログにアクセスできません。 one.comは自分のドメインをホストしているもので、所有者が自分のログファイルにアクセスできるようにしていません.... :( – Pogoe