日期:2014-05-20  浏览次数:20994 次

webservice接口返回带"<>"字符的String如何不被转义
例如我想返回如下数据:
<?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是我们服务器端返回的对象数据
Java code

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代码如下:
Java code

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 code
<?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>


求各位大神!



------解决方案--------------------
不懂,友情帮顶!
------解决方案--------------------
帮顶一下,没有遇到过这样的问题,可以Google一下!