例如我想返回如下数据:
<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soap:Body xmlns:ns1="http://www.mbossvsop.com.cn/vsop"><ns2:UserInfoSyncToISMPResp xmlns:ns2="http://www.mbossvsop.com.cn/vsop"><response>
<![CDATA[<Response>
<UserInfoSyncToISMPResp>
<StreamingNo>000000000000000000000000000000000000000000000000000000003759</StreamingNo>
<ResultCode>0</ResultCode>
<ResultDesc>操作成功</ResultDesc>
</UserInfoSyncToISMPResp>
</Response>]]>
</response></ns2:UserInfoSyncToISMPResp></soap:Body></soap:Envelope>
[/code]这些是用wsdl文件生成的代码,request是客户端传值过来的对象,response是我们服务器端返回的对象数据UserInfoSyncToISMPSV_BindingImpl.java
UserInfoSyncToISMPSV_BindingSkeleton.java
UserInfoSyncToISMPSV_BindingStub.java
UserInfoSyncToISMPSV_PortType.java
UserInfoSyncToISMPSV_Service.java
UserInfoSyncToISMPSV_ServiceLocator.java
VsopServiceRequest.java
VsopServiceResponse.java
我的UserInfoSyncToISMPSV_BindingImpl.java代码如下:if(logger.isDebugEnabled()){
logger.debug("[UserSyncToVsopService][req]:"+parameters.getRequest());
}
String resXml = "";
try{
resXml = userInfoProc.proc(parameters.getRequest());
}catch(BtirException e){
logger.error(e);
}
if(logger.isDebugEnabled()){
logger.debug("[UserSyncToVsopService][res]:"+resXml);
}
VsopServiceResponse res = new VsopServiceResponse();
res.setResponse(resXml);
logger.debug("UserInfoSyncFromVsopService:"+res.getResponse());
return res;七中resXml通过userInfoProc处理逻辑类得到的内容如下:
<![CDATA[<Response><UserInfoSyncToISMPResp><StreamingNo>000000000000000000000000000000000000000000000000000000003759</StreamingNo><ResultCode>0</ResultCode><ResultDesc>操作成功</ResultDesc></UserInfoSyncToISMPResp></Response>]]>
到这里应该没有错误。但是通过查看soap包得到的却是下面的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;000000000000000000000000000000000000000000000000000000003759&lt;/StreamingNo&gt;&lt;ResultCode&gt;0&lt;/ResultCode&gt;&lt;ResultDesc&gt;&#x64CD;&#x4F5C;&#x6210;&#x529F;&lt;/ResultDesc&gt;&lt;/UserInfoSyncToISMPResp&gt;&lt;/Response&gt;]]&gt;</response></UserInfoSyncToISMPResp></soapenv:Body></soapenv:Envelope>求各位大神!

解决方案 »

  1.   

    哎,CSDN也是哥神话啊。60分木有人要
      

  2.   

    应该不会啊。我这边用Rest 返回xml 的字符串,也不会出现转义的情况
      

  3.   

    再说了&lt;&gt;这是HTML中才会进行解析。JAVA中也不存在这种转义
      

  4.   

    我们这边是通过wsdl文件生成服务端代码,然后客户端通过HttpURLConnection获得所有soap包,但是中文变成这样&#x64CD;的字符,实际System.out.println((char)Integer.parseInt("64CD",16));是可以变成中文"你"的。我们用的webservice是Axis1.4,至于这个是怎么返回xml的soap包的就是不知道,无法跟踪很郁闷。
      

  5.   

    你返回也string类型的xml不行么
      

  6.   

    实在不行你就:<>这种符号采用可以不乱码的代替,避免使用中文,不过你最好再看下Axis1.4文档(上网查...),这个真没怎么用过