有一个相关的问题,但我无法清楚地得到答案。Android,通过HTTP POST方法发送和接收XML
我想发布一个简短的XML代码
<aaaLogin inName="admin" inPassword="admin123"/>
通过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("<aaaLogin inName=\"admin\" inPassword=\"admin123\"/>",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保存为文件。有人可以编写代码片段吗?