简体   繁体   English

如何检查数据是否正确发布到Android中的Web服务?

[英]How to check if Data is correctly posted to webservice in android?

I want to check if I have successfully posted the data to webservice using the httppost method. 我想检查是否已使用httppost方法成功将数据发布到Web服务。 How to verify that the data is posted successfully? 如何验证数据是否成功过账? How to check if json.put("URL".getpref()); 如何检查json.put(“ URL” .getpref()); is successfully posted to webservice? 已成功发布到webservice?

HttpPost post = new HttpPost(url1);
try {
json.put("URL", getPref());


Log.i("json Object", json.toString());
StringEntity stringEntity = new StringEntity(json.toString());

stringEntity.setContentEncoding("UTF-8");
stringEntity.setContentType("application/json");
post.setEntity(stringEntity);
//ResponseHandler responseHandler = new BasicResponseHandler();
response = client.execute(post);
Log.e("RESPONSE", response.toString());
String responseBody = EntityUtils
toString(response.getEntity());
System.out.println(responseBody);

You need to check the response from the server. 您需要检查服务器的响应。 The response from a webservice could be as simple as a string like "success" . 来自Web服务的响应可能像"success"这样的字符串一样简单。 If you or your team has access to the webservice you may ask to them to return appropriate repsonse from the server. 如果您或您的团队有权访问Web服务,则可以要求他们从服务器返回适当的响应。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM