有一个相关的问题,但我无法清楚地得到答案.
我想POST一个简短的xml代码
通过HTTP到特定的URL地址.Web服务将向我发回XML代码.重要的是我将解析收到的XML,并希望将其存储为文件.
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://192.168.192.131/"); //URL address
StringEntity se = new StringEntity("",HTTP.UTF_8); //XML as a string
se.setContentType("text/xml"); //declare it as XML
httppost.setHeader("Content-Type","application/soap+xml;charset=UTF-8");
httppost.setEntity(se);
BasicHttpResponse httpResponse = (BasicHttpResponse) httpclient .execute(httppost);
tvData.setText(httpResponse.getStatusLine().toString()); //text view is expected to print the response
收到回复有问题.此外,我没有写任何东西来保存收到的XML作为文件.有人可以编写代码片段吗?