以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 Android 高级开发 』   (http://bbs.xml.org.cn/list.asp?boardid=53)
----  android 2.3调用web service 遇到的问题  (http://bbs.xml.org.cn/dispbbs.asp?boardid=53&rootid=&id=95229)


--  作者:huracanwang
--  发布时间:8/19/2011 4:18:00 PM

--  android 2.3调用web service 遇到的问题
通过HttpURLConnection 调用web service,在getInputStream时
直接抛了个异常:unknown format(magic number a0d)
而在2.2及以前的版本都是没问题的!!!
有啥解决办法吗?

代码:
String flag="0";
  try {
   
   URL url = new URL("http://xxxxx/test.php");

   HttpURLConnection con = (HttpURLConnection) url.openConnection();   
   con.setDoOutput(true);
   con.setRequestProperty("Pragma:", "no-cache");
   con.setRequestProperty("Cache-Control", "no-cache");
   con.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
   con.setRequestMethod("POST");
   String xmlInfo= "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
    + "<soap:Body>" +para+"</soap:Body></soap:Envelope>";
   if (xmlInfo != null) {
    OutputStreamWriter out = new OutputStreamWriter(con
      .getOutputStream());
    out.write(new String(xmlInfo.getBytes("UTF-8")));
    out.flush();
    out.close();
   }
   flag="0";
   con.connect(); 
   flag="1";
   InputStream is = con.getInputStream(); //这儿出错了
   flag="2";


--  作者:tjwzjs
--  发布时间:8/20/2011 2:45:00 PM

--  
貌似 俺不懂 学习学习
--  作者:qian2012
--  发布时间:12/17/2012 4:13:00 PM

--  
选择千锋 选择卓越  千锋3G 手机软件开发培训第一品牌

[url=http://www.mobiletrain.org/]iOS培训[/url]   [url=http://www.mobiletrain.org/]北京iOS培训[/url]   [url=http://www.1000phone.net/]iOS开发[/url]


W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
6,148.438ms