设想:
- 客户端是一个使用SOAP::Lite的 Perl 脚本。
- 服务器是使用 Spring 和 CXF 的基于 Java 的应用程序。
我的客户端基于 WSDL 生成以下 SOAP 请求:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<createFolder xmlns="http://xyz.com/">
<parentId xsi:type="xsd:string">1</parentId>
<folderName xsi:type="xsd:string">Test</folderName>
</createFolder>
</soap:Body>
</soap:Envelope>
此请求将针对 CXF 失败。经过几次调查,我发现以下手动生成的请求可以工作:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xyz="http://xyz.com/">
<soap:Body>
<xyz:createFolder>
<parentId xsi:type="xsd:string">1</parentId>
<folderName xsi:type="xsd:string">Test</folderName>
</xyz:createFolder>
</soap:Body>
</soap:Envelope>
不同之处在于元素的命名空间定义createFolder
。
我的问题是:如何配置 SOAPLite 来创建有效的 SOAP 请求?
反之亦然:如何将 CXF 配置为接受 SOAP::Lite 请求样式?