Skip to main content

SOAP, WebParam.Mode.OUT always returns null (solved)

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
1 reply [Last post]
h_20097
Offline
Joined: 2013-08-01

Hi

I have a question to a JAX-WS project using JDK 1.6.0_45

I've generated a webservice from a WSDL looking like this:

...
        <wsdl:operation name="getTransactionList">
            <soap:operation style="document" soapAction="getTransactionList"/>
            <wsdl:input>
                <soap:body use="literal" parts="body"/>
                <soap:header use="literal" message="tns:getTransactionListRequest" part="header"/>
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal" parts="body"/>
                <soap:header use="literal" message="tns:getTransactionListResponse" part="header"/>
            </wsdl:output>
            <wsdl:fault name="fault1">
                <soap:fault use="literal" name="fault1"/>
            </wsdl:fault>
        </wsdl:operation>
...
    <wsdl:message name="getTransactionListResponse">
        <wsdl:part name="header" element="ns0:responseHeader"/>
        <wsdl:part name="body" element="ns0:getTransactionListResponse"/>
    </wsdl:message>
...

As you can see, getTransactionList returns a message with 2 components, header and body. Using wsimport this ends up like this:

    @WebMethod(action = "getTransactionList")
    public void getTransactionList(
        @WebParam(name = "requestHeader", targetNamespace = "http://namespace/IAS/WebService/Schema", header = true, partName = "header")
        RequestHeaderType header,
        @WebParam(name = "getTransactionListRequest", targetNamespace = "http://namespace/IAS/WebService/Schema", partName = "body")
        GetTransactionListRequestType body,
        @WebParam(name = "responseHeader", targetNamespace = "http://namespace/IAS/WebService/Schema", header = true, mode = WebParam.Mode.OUT, partName = "header")
        Holder<ResponseHeaderType> header0,
        @WebParam(name = "getTransactionListResponse", targetNamespace = "http://namespace/IAS/WebService/Schema", mode = WebParam.Mode.OUT, partName = "body")
        Holder<GetTransactionListResponseType> body0)
        throws ErrorInfo
    ;

The two return values are annoted as WebParam.Mode.OUT.

Now i've written a short test method

  public static void main(final String[] args) throws Exception {
    try {
      IASService _s = new IASService(new URL("http://127.0.0.1/WodisScratch/IAServiceEndpoint?wsdl"), new QName(
          "http://namespace/IAS/WebService/WDSL/concrete", "IAS_Service"));
      RequestHeaderType header = new RequestHeaderType();
      GetTransactionListRequestType body = new GetTransactionListRequestType();
      Holder<ResponseHeaderType> header0 = new Holder<ResponseHeaderType>(new ResponseHeaderType());
      Holder<GetTransactionListResponseType> body0 = new Holder<GetTransactionListResponseType>(new GetTransactionListResponseType());
      System.out.println("Call");
      System.out.println("body0: " + body0);
      System.out.println("body0.value: " + body0.value);

      System.out.println("*BOOM*");
      _s.getIAServiceEndpoint().getTransactionList(header, body, header0, body0);
      System.out.println("Never seeing this");

      for (Transaction _t : body0.value.getTransaction()) {
        System.out.println(_t.getTransactionId());
      }
    } catch (ErrorInfo e) {
      e.printStackTrace();
    }
  }

Output:

Call
body0: javax.xml.ws.Holder@12d263f
body0.value: namespace.ias.webservice.schema.GetTransactionListResponseType@12a0f6c
*BOOM*

Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: java.lang.NullPointerException
at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:178)
at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:119)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:107)
at com.sun.proxy.$Proxy33.getTransactionList(Unknown Source)
at de.kalo.Test.main(Test.java:31)
Caused by: java.lang.NullPointerException
at namespace.ias.webservice.wdsl.concrete.IAServiceEndpointImpl.getTransactionList(IAServiceEndpointImpl.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.xml.ws.api.server.InstanceResolver$1.invoke(InstanceResolver.java:246)
at com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:146)
at com.sun.xml.ws.server.sei.EndpointMethodHandler.invoke(EndpointMethodHandler.java:257)
at com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:93)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:595)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:554)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:539)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:436)
at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:243)
at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:444)
at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:244)
at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:135)
at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doGet(WSServletDelegate.java:129)
at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doPost(WSServletDelegate.java:160)
at com.sun.xml.ws.transport.http.servlet.WSServlet.doPost(WSServlet.java:75)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:662)

The implementation looks like this:

  public void getTransactionList(final RequestHeaderType header, final GetTransactionListRequestType body, final Holder<ResponseHeaderType> header0,
      final Holder<GetTransactionListResponseType> body0) throws ErrorInfo {
    System.out.println("Start");
    System.out.println("body0: " + body0);
    System.out.println("body0.value: " + body0.value);
   ...

Output:
Start
body0: javax.xml.ws.Holder@1af8502
body0.value: null

Somewhere between API call and implementation the Holder-value ist lost, and replaced by another one with a null-value.

After half a day of googling and trying this and tthat i'm left clueless.

Have you any ideas?

Bye
Holger

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
h_20097
Offline
Joined: 2013-08-01

Solution: Simply set the OUT-values youself:

body0.value = new GetTransactionListResponseType();
header0.value = new ResponseHeaderType();

This is a 100% *Ouch*. Too simple to find out.

Bye
Holger