如题,怎么解决成正常的

解决方案 »

  1.   

    这不是encoding问题,都是默认的为utf-8
      

  2.   

    例如我在程序中返回这些信息:
    <![CDATA[<Response>
    <UserInfoSyncToISMPResp>
    <StreamingNo></StreamingNo>
    <ResultCode>-113</ResultCode>
    <ResultDesc>参数错误</ResultDesc>
    </UserInfoSyncToISMPResp>
    </Response>]]>那HttpURLConnection用得到的soap就为这样:
    <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><UserInfoSyncToISMPResp xmlns="http://www.mbossvsop.com.cn/vsop"><response xmlns="">&lt;![CDATA[&lt;Response&gt;&lt;UserInfoSyncToISMPResp&gt;&lt;StreamingNo&gt;&lt;/StreamingNo&gt;&lt;ResultCode&gt;-113&lt;/ResultCode&gt;&lt;ResultDesc&gt;&#x53C2;&#x6570;&#x9519;&#x8BEF;&lt;/ResultDesc&gt;&lt;/UserInfoSyncToISMPResp&gt;&lt;/Response&gt;]]&gt;</response></UserInfoSyncToISMPResp></soapenv:Body></soapenv:Envelope>
    怎么出现这种情况
      

  3.   


    我的回答有误,不好意思,看看soap请求时有没有参数设置不转义,如果没的话只能自己解析了。
      

  4.   

    他们请求的我这边都可以正确获得,包括中文。但是就是我这边返回的信息,他们用HttpURLConnection获得时出现这种情况,但是我自己这边用wsdl文件生成的客户端调用是没有什么问题的
      

  5.   

    发下HttpURLConnection请求的代码看看。
      

  6.   

    用HttpURLConnection获得是木有问题的,再说对方平台调用,我们也不能修改。需要也可以发布出来
    HttpURLConnection connection = null;
    String soapAction = "userInfoSynSV";
    String requestXML = getXML();
    String serviceURL = "--------";
                   connection = openConnection(serviceURL, requestXML, soapAction);
    InputStream input = connection.getInputStream();
    StringBuffer buf = new StringBuffer();
    byte[] b = new byte[1024];
    int length = -1;
    while ((length = input.read(b)) != -1) {
    buf.append(new String(b, 0, length, "UTF-8"));
    }
    return buf.toString();
    private static HttpURLConnection openConnection(String serviceURL,
    String requestXML, String soapAction) throws Exception {
    URL url = new URL(serviceURL);
    URLConnection connection = url.openConnection();
    String host =url.getHost();
    HttpURLConnection httpConn = (HttpURLConnection) connection; // Open the
    httpConn.setRequestProperty("Host", host);
    httpConn.setRequestProperty("Content-Length", requestXML.length() + "");
    httpConn.setRequestProperty("Content-Type", "application/soap+xml; charset=utf-8");
    // httpConn.setRequestProperty("Content-Type", "text/xml; charset=utf-8");
    httpConn.setRequestProperty("SOAPAction", soapAction);
    httpConn.setRequestMethod("POST");
    httpConn.setDoOutput(true);
    httpConn.setDoInput(true); // Everything's set up; send the XML that was
    OutputStream os = httpConn.getOutputStream();
    os.write(requestXML.getBytes("utf-8"));
    os.flush();
    os.close();
    return httpConn;
    }
      

  7.   

    别把信息放在<![CDATA[]]标签里!
      

  8.   

    觉得12楼的说法不对,含有特殊字符的数据本来就该放在CDATA里,我觉得还是编码的问题吧
      

  9.   

    <![CDATA[<Response>
    <UserInfoSyncToISMPResp>
    <StreamingNo></StreamingNo>
    <ResultCode>-113</ResultCode>
    <ResultDesc>参数错误</ResultDesc>
    </UserInfoSyncToISMPResp>
    </Response>]]>这是我返回的,木有看到么?先看清再回答