Java 使用空的RequestPayload从Spring WS客户端发送消息

Java 使用空的RequestPayload从Spring WS客户端发送消息,java,spring,web-services,wsdl,spring-ws,Java,Spring,Web Services,Wsdl,Spring Ws,我有点困在这里了。我们正在尝试使用SpringWS编写WS-Client。挑战在于处理诸如getVersion()之类的web服务,这些服务不需要向服务器传递任何值 以下是您通常使用的典型客户端实现: public class MyServiceClient extends WebServiceGatewaySupport { public String getVersion() { SomeJaxbGeneratedClass request = new SomeJaxbGe

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


任何帮助都将不胜感激。

我只想给大家一个更新,以防您遇到类似问题。我通过使用JaxWsPortProxyFactoryBean从Spring WS切换到Spring JAX-WS解决方案解决了这个问题。

我认为这不是文档驱动web服务的预期用途,这只是通过web进行的RPC调用。这是个坏主意。。。只需使用文档驱动的web服务创建一条请求和响应消息。M.Deinum,感谢您的回复。您说过:创建请求和响应消息。我遇到的问题是请求,因为没有JAXB生成的类可以这样使用。如果您有一个请求和响应消息的示例,这将非常有用。谢谢。只需为
getVersionRequest
getVersionResponse
创建一个类型即可。这两个类型都已创建。现在它抛出这个异常:org.springframework.oxm.UncategorizedMappingException:Unknown JAXB异常;嵌套的异常是javax.xml.bind.JAXBException:class com.cvc.adservice.envio.getVersionRequest,该上下文也不知道它的任何超类。下面是getVersionRequest类:@XmlRootElement(name=“getVersionRequest”)公共类getVersionRequest{}您必须告诉SpringWeb服务它可以处理哪些类。您需要注册一个
Jaxb2Marshaller
,并指定哪些包包含您的jaxb类。