0

サーバーにデータを投稿してデータを更新しようとしています。投稿中に成功として応答を得ていますが、このデータは指定された URL で更新されていません。このデータが特定の URL にどのように反映されるかを教えてください。

public static ServerResponse postData(String url,
        FarmInchargeEntity farmInchargeEnt) {
    // Create a new HttpClient and Post Header
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost(url);
    ServerResponse sr = new ServerResponse();
    farmChargeEntity = farmInchargeEnt;

    try {

        StringEntity se;
        se = new StringEntity(getRequestJson());

        // Set HTTP parameters
        httppost.setEntity(se);
        httppost.setHeader("Accept", "application/json");
        httppost.setHeader("Content-type", "application/json;charset=UTF-8");
        httppost.setHeader("Accept-Encoding", "gzip");

        // Execute HTTP Post Request
        HttpResponse response = httpclient.execute(httppost);

        if (response.getStatusLine().getStatusCode() == 200) {
            sr.setSuccess(true);
            sr.setResponseString(response.toString());
        } else {
            sr.setErrorMessage(response.toString());
        }

        Log.v("HttpPostResponse", "" + response.toString());

    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return sr;
}

// JSON文字列を取得するメソッド

public static String getRequestJson() {
    String r = "{" + "id" + ":" + null + "," + "surName" + ":"
            + farmChargeEntity.surName + "," + "givenName" + ":"
            + farmChargeEntity.givenName + "," + "dateOfBirth" + ":"
            + farmChargeEntity.dateOfBirth + "," + "education" + ":" + null
            + "," + "gender" + ":" + farmChargeEntity.gender + ","
            + "address" + ":" + "{" + "id" + ":" + null + "," + "addrLine1"
            + ":" + farmChargeEntity.addrLine1 + "," + "addrLine2" + ":"
            + farmChargeEntity.addrLine2 + "," + "taluk" + ":"
            + farmChargeEntity.taluk + "," + "district" + ":"
            + farmChargeEntity.district + "," + "state" + ":"
            + farmChargeEntity.state + "," + "pincode" + ":"
            + farmChargeEntity.pinCode + "," + "phoneNumber" + ":"
            + farmChargeEntity.phoneNumber + "," + "mobileNumber" + ":"
            + farmChargeEntity.mobileNumber + "," + "email" + ":"
            + farmChargeEntity.email + "," + "fax" + ":"
            + farmChargeEntity.fax + "," + "longitude" + ":"
            + farmChargeEntity.longitude + "," + "latitude" + ":"
            + farmChargeEntity.latitude + "," + "radius" + ":"
            + farmChargeEntity.radius + "}" + "," + "familyMembers" + ":"
            + farmChargeEntity.familyNumbers + "," + "startDateOfAssoc"
            + ":" + farmChargeEntity.startDateOfAssoc + ","
            + "endDateOfAssoc" + ":" + farmChargeEntity.endDateOfAssoc
            + "," + "farm" + ":" + farmChargeEntity.farmInchargeId + "}";

    return r;

}
4

1 に答える 1

0

あなたの側では、サーバー側で1回チェックするだけでよいと思います。データを投稿すると、サーバーがデータを受信して​​応答を送信すると成功しますが、その後、データベースに保存するか、Web側のサーバーコードで1回チェックするだけではありません

于 2013-10-16T05:42:39.313 に答える