Android ICS SOAP 方法不起作用?

标签 android soap xml-parsing

我在 samsung galaxy tab 中测试了 SOAP 方法并且工作正常。

我在 Android ice cream sandwich 上测试过的相同代码无法正常工作。

下面是我的代码,

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);            
            }

在这段代码中,我打印了 httpResponse.getStatusLine().toString() 这样的打印值 HTTP/1.1 200 OK 代码 200

但行值变为空。

谢谢。

最佳答案

试试这个,

StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(策略);

关于Android ICS SOAP 方法不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12154174/

相关文章:

android - 将背景图像添加到随滚动移动的 RecyclerView

java - 使用 before 方法比较两个日期(字符串格式的日期和当前时间)

java - 两个不同的 SOAP 端点中是否可以存在同名的操作?

java - 当部署在 Glassfish 中时,基于 Spring-WS 的 SOAP 服务返回 405

xmlstarlet 选择并更新 xml

java - 如何使用Proteus Android Layout Engine实现级联资源

java - 线程中的Android无限循环

json - XML 是面向文档的。这是什么意思?

javascript - XML Javascript解析问题(具体代码问题)

xsd - 如何正确使用 GenerateDS 进行 DDEX XML 绑定(bind)