0

我正在处理一个问题,我必须使用从 WSDL 开发的遗留 Web 服务客户端,该客户端将实际 XML 请求作为请求中唯一一个变量的值传递。我现在使用的 Web 服务具有不同的 WSDL,我试图欺骗我的 XML 解析器,但它正在编码我的实际 XML 响应。

无论如何配置解析器所以请求:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:Header/>
   <soapenv:Body>
      <request>&lt;elemA&gt;&lt;elemB&gt;abc&lt;/elemB&gt;&lt;/elemA&gt;</request>
   </soapenv:Body>
</soapenv:Envelope>

改成这样:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:Header/>
   <soapenv:Body>
      <foo>
         <elemA>
            <elemB>abc</elemB>
         </elemA>
      </foo>
   </soapenv:Body>
</soapenv:Envelope>

我正在使用 JAX-WS 和 WebSphere 7。

提前致谢。

巴勃罗

4

1 回答 1

0

去年我不得不处理一次这种情况,对我来说,解决方案是将进入肥皂消息中的 XML 包装在 CDATA 部分中。

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
       <soapenv:Header/>
       <soapenv:Body>
          <![CDATA[
          <foo>
             <elemA>
                <elemB>abc</elemB>
             </elemA>
          </foo>
          ]]
       </soapenv:Body>
    </soapenv:Envelope>
于 2011-08-15T20:37:19.910 回答