javaee / metro-jax-ws

https://javaee.github.io/metro-jax-ws/
Other
132 stars 68 forks source link

WebParam.Mode.OUT always returns a null holder-value in response #1126

Open glassfishrobot opened 11 years ago

glassfishrobot commented 11 years ago

Hi

First Jira contact ever. Hope i don't mess this up.

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

...

... ... 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 header0, @WebParam(name = "getTransactionListResponse", targetNamespace = "http://namespace/IAS/WebService/Schema", mode = WebParam.Mode.OUT, partName = "body") Holder 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 header0 = new Holder(new ResponseHeaderType()); Holder body0 = new Holder(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 header0, final Holder 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. Bye Holger #### Environment Win XP, myEclipse 10, JDK 1.6.0_45 #### Affected Versions [2.1.6]
glassfishrobot commented 11 years ago

Reported by h_20097

glassfishrobot commented 11 years ago

h_20097 said: I'd be glad to add sources / a testcase, but i don't know where...

Bye Holger

glassfishrobot commented 11 years ago

h_20097 said: Did some more investigation. I've downloaded JAXWS2.2.7-20120813 bin + src and used endorsed-dir to override the jax-ws-api and jaxb-api of the JDK. I then included all the supplied jars in project and tomcat-libs.

As far as now, i found out that TieHandler assigns a EndpointArgumentsBuilder.NullSetter to the last 2 of 4 params. The first two are recognized correctly (header-IN and body-IN). The last 2 (body-OUT and header-OUT) are classified as ParameterBinding.Kind.UNBOUND.

Bye Holger

glassfishrobot commented 11 years ago

h_20097 said: Hi

The solution is: In the implementation just set the holder-value yourself

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

It never came to my mind that value is an public accessible field. Seems i'm 100% indoctrinated by bean semantics and getter/setter-pairs.

Eventually this can be transformed into an enhancement request: Add value getter/setter for the Holder-class.

If not, please see this ussue as resolved and don't tell anyone

Bye Holger

glassfishrobot commented 7 years ago

This issue was imported from java.net JIRA JAX_WS-1126