我需要从一个WSDL文件中消费一个汤网络服务。我想用和maven-jaxb2-plugin
来解决这个问题。 WS服务器可能会使用一个旧的SOAP合同。我在WSDL文件中找到类似<soap:operation soapAction="" style="rpc"/>
的东西。 WSDL文件:spring WS需要在旧的WS合同中使用“请求”包装请求属性
<?xml version='1.0' encoding='UTF-8'?><wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://impl.sub.xxx.com/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" name="hahaPaymentWSImpl" targetNamespace="http://impl.sub.xxx.com/">
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://impl.sub.xxx.com/" targetNamespace="http://impl.sub.xxx.com/" version="1.0">
<xs:complexType name="singlePaymentRequest">
<xs:sequence>
<xs:element minOccurs="0" name="accountName" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="singlePaymentResponse">
<xs:sequence>
<xs:element minOccurs="0" name="amount" type="xs:double"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="singlePayment">
<wsdl:part name="request" type="tns:singlePaymentRequest">
</wsdl:part>
</wsdl:message>
<wsdl:message name="singlePaymentResponse">
<wsdl:part name="return" type="tns:singlePaymentResponse">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="hahaPaymentWS">
<wsdl:operation name="singlePayment">
<wsdl:input message="tns:singlePayment" name="singlePayment">
</wsdl:input>
<wsdl:output message="tns:singlePaymentResponse" name="singlePaymentResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="hahaPaymentWSImplSoapBinding" type="tns:hahaPaymentWS">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="singlePayment">
<soap:operation soapAction="" style="rpc"/>
<wsdl:input name="singlePayment">
<soap:body namespace="http://impl.sub.xxx.com/" use="literal"/>
</wsdl:input>
<wsdl:output name="singlePaymentResponse">
<soap:body namespace="http://impl.sub.xxx.com/" use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="hahaPaymentWSImpl">
<wsdl:port binding="tns:hahaPaymentWSImplSoapBinding" name="hahaPaymentWSPort">
<soap:address location="http://999.00.837.212:8888/services/hahaPaymentWS"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
第一次,maven-jaxb2-plugin
自动生成WSDL文件中的Java bean。但后来没有@XmlRootElement
标签。所以我用WSDL文件中的<xs:element>
手动变换<xs:complexType>
。它的工作原理。
然后,我发送请求到服务器。它告诉我Found element accountName but could not find matching RPC/Literal part
。像这样在日志中的要求:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<ns3:singlePayment xmlns:ns3="http://impl.sub.xxx.com/">
<accountName>xxx</accountName>
</ns3:singlePayment>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
我觉得soupUI
可以工作,只是因为soupUI
与<request>
标签包裹请求属性:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<ns3:singlePayment xmlns:ns3="http://impl.sub.xxx.com/">
<request>
<accountName>xxx</accountName>
</request>
</ns3:singlePayment>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
我想知道的是服务器的合同这个问题?我怎样才能轻松解决这个问题?