我有点卡在这里。我们正在尝试使用Spring WS编写WS Client。挑战在于处理像getVersion()这样的Web服务,它们不需要将任何值传递给服务器。
以下是您通常使用的典型客户端实施:
public class MyServiceClient extends WebServiceGatewaySupport {
public String getVersion() {
SomeJaxbGeneratedClass request = new SomeJaxbGeneratedClass();
String response = (String) getWebServiceTemplate().marshalSendAndReceive(request,
new SoapActionCallback("someNameSpace/getVersion"));
return response;
}
}
问题是当调用getVersion时,没有SomeJaxbGeneratedClass作为请求传递,因为它只是要求获取版本号。所以我的问题是在这种情况下应该作为请求(RequestPayload)传递什么? WebServiceTemplate是否有另一种更好的方法?
这里是如何在WSDL中定义getVersion:
<WSDL:message name="getVersionRequest"/>
<WSDL:message name="getVersionResponse">
<WSDL:part name="version" type="xsd:string"/>
</WSDL:message>
<portType>
<WSDL:operation name="getVersion">
<WSDL:input message="tns:getVersionRequest"/>
<WSDL:output message="tns:getVersionResponse"/>
</WSDL:operation>
</portType>
<binding>
<WSDL:operation name="getVersion">
<SOAP:operation soapAction="someNameSpace/getVersion"/>
<WSDL:input>
<SOAP:body namespace="someNameSpace" use="literal"/>
</WSDL:input>
<WSDL:output>
<SOAP:body namespace="someNameSpace" use="literal"/>
</WSDL:output>
</WSDL:operation>
</binding>
非常感谢任何帮助。
答案 0 :(得分:0)
只是想在遇到类似问题时给大家一个更新。我通过使用JaxWsPortProxyFactoryBean从Spring WS切换到Spring JAX-WS解决方案来解决这个问题。