Jee*_*123 6 android soap xml-parsing
我在三星galaxy tab中测试了SOAP方法,并且工作正常.
相同的代码,我在Android冰淇淋三明治上测试,并没有工作.
以下是我的代码,
HttpPost httppost = new HttpPost("xxxxxx");
httppost.setHeader("Content-type", "text/xml; charset=utf-8");
httppost.setHeader("SOAPAction", SoapAction);
StringEntity se1 = new StringEntity(env,HTTP.UTF_8);
se1.setContentType("text/xml");
se1.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "text/xml; charset=utf-8"));
httppost.setEntity(se1);
HttpClient httpclient = new DefaultHttpClient();
BasicHttpResponse httpResponse = (BasicHttpResponse) httpclient.execute(httppost);
System.out.println("res------"+httpResponse.getStatusLine().toString()+" code "+httpResponse.getStatusLine().getStatusCode());
//Checking response
if(httpResponse!=null){
inputStream = httpResponse.getEntity().getContent();
BufferedReader r = new BufferedReader(new InputStreamReader(inputStream));
StringBuilder total = new StringBuilder();
String line="";
try {
while ((line = r.readLine()) != null) {
total.append(line);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("line----"+line);
}
Run Code Online (Sandbox Code Playgroud)
在这段代码中,我打印了httpResponse.getStatusLine().toString()打印的值,如此 HTTP/1.1 200 OK代码200
但是行值变为null.
谢谢.
小智 0
尝试这个 ,
StrictMode.ThreadPolicy 策略 = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(策略);
| 归档时间: |
|
| 查看次数: |
204 次 |
| 最近记录: |