有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java使用空的RequestPayload从SpringWS客户端发送消息

我有点困在这里了。我们正在尝试使用SpringWS编写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>

任何帮助都将不胜感激


共 (1) 个答案

  1. # 1 楼答案

    只是想给每个人一个更新,以防你遇到类似的问题。通过使用JaxWsPortProxyFactoryBean从SpringWS切换到SpringJAX-WS解决方案,我解决了这个问题