Java – jax-ws/wsimport generates WebMethod with void return – same Request/ResponseWrapper


I'm working with a client's WSDL file that uses the same element definition for the input and output messages, but I'm having trouble getting JAX-WS/JAXB to unmarshal the response.

<wsdl:message name="invokeServiceRequest">
    <wsdl:part element="impl:requests" name="multiRequestWrapper"/>
<wsdl:message name="invokeServiceResponse">
    <wsdl:part element="impl:requests" name="result"/>
<wsdl:portType name="GCGatewayPortType">
    <wsdl:operation name="requests">
        <wsdl:input message="impl:invokeServiceRequest" name="invokeServiceRequest"/>
        <wsdl:output message="impl:invokeServiceResponse" name="invokeServiceResponse"/>

For some reason, the code generated by wsimport has a void return, and the INOUT params don't seem to be updated when the response is received.

 * This class was generated by the JAX-WS RI.
 * JAX-WS RI 2.1.7-b01-
 * Generated source version: 2.1
@RequestWrapper(localName = "requests", targetNamespace = "", className = "")
@ResponseWrapper(localName = "requests", targetNamespace = "", className = "")
public void requests(
    @WebParam(name = "paramOne", targetNamespace = "", mode = WebParam.Mode.INOUT)
    Holder<String> paramOne,
    @WebParam(name = "paramTwo", targetNamespace = "", mode = WebParam.Mode.INOUT)
    Holder<String> paramTwo,
    @WebParam(name = "requestList", targetNamespace = "", mode = WebParam.Mode.INOUT)
    Holder<List<RequestType>> requestList);

When I call port.request( paramOne, paramTwo, requestList ), I can see that the SOAP request is sent to the server, which responds with a valid SOAP response:

<soapenv:Envelope ...>
    <soapenv:Header />
        <requests ...>
                <!-- various elements that JAXB has generated code for -->

However, when I run my app in debug mode, I can see each RequestType instance in the debugger variables view, but because RequestsType has an <xsd:choice> with RequestData or ResponseData, the latter is null and the RequestData is as I provided.

I've successfully used JAX-WS on other projects, but in those cases it generated code with a @WebResult and non-void return type named after the WebResult. In this project, I think I'm not getting the WebResult because JAX-WS has decided that the request and response types are the same and it can reuse the same object – but how do I get it to update that object with data from the response?

Best Solution

You can solve this by instructing JAX-WS to disable wrapping. This is done through a JAX-WS bindings file.

<jaxws:bindings xmlns:jaxws="">
Related Question