Hello,
I try to exchange SOAP Messages between two Web services using SAAJ. I have followed the tutorial from this (Tip: Send and receive SOAP messages with SAAJ) link. Surprisingly, the doesn't describe the process on the receiver of the SOAP message i.e. how the request is processed and a response SOAP message is generated and sent back. After hours of googling, I found this link (SAAJ) which looked to be very promising (SAAJ Client With a JAXM Server Example).
But when I attempt to retrieve the contents of the SOAP message on client using SOAPPart respSOAP = response.getSOAPPart();, I get “Null Pointer Exception”. I wonder how the OnMessage method could not receive the communicated SOAP message. The server log is given below.
The log message is null.
java.lang.NullPointerException
at weather.WeatherService.onMessage(WeatherService.ja va:43)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at com.sun.enterprise.webservice.InstanceResolverImpl $1.invoke(InstanceResolverImpl.java:112)
at com.sun.xml.ws.server.InvokerTube$2.invoke(Invoker Tube.java:146)
at com.sun.xml.ws.server.sei.EndpointMethodHandler.in voke(EndpointMethodHandler.java:257)
at com.sun.xml.ws.server.sei.SEIInvokerTube.processRe quest(SEIInvokerTube.java:93)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:5 95)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:55 4)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:539 )
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:4 36)
at com.sun.xml.ws.api.pipe.helper.AbstractTubeImpl.pr ocess(AbstractTubeImpl.java:106)
at com.sun.enterprise.webservice.MonitoringPipe.proce ss(MonitoringPipe.java:147)
at com.sun.xml.ws.api.pipe.helper.PipeAdapter.process Request(PipeAdapter.java:115)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:5 95)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:55 4)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:539 )
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:4 36)
at com.sun.xml.ws.api.pipe.helper.AbstractTubeImpl.pr ocess(AbstractTubeImpl.java:106)
at com.sun.enterprise.webservice.CommonServerSecurity Pipe.processRequest(CommonServerSecurityPipe.java: 222)
at com.sun.enterprise.webservice.CommonServerSecurity Pipe.process(CommonServerSecurityPipe.java:133)
at com.sun.xml.ws.api.pipe.helper.PipeAdapter.process Request(PipeAdapter.java:115)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:5 95)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:55 4)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:539 )
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:4 36)
at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSE ndpointImpl.java:243)
at com.sun.xml.ws.transport.http.HttpAdapter$HttpTool kit.handle(HttpAdapter.java:444)
at com.sun.xml.ws.transport.http.HttpAdapter.handle(H ttpAdapter.java:244)
at com.sun.xml.ws.transport.http.servlet.ServletAdapt er.handle(ServletAdapter.java:135)
at com.sun.enterprise.webservice.JAXWSServlet.doPost( JAXWSServlet.java:177)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:754)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:847)
at org.apache.catalina.core.ApplicationFilterChain.se rvletService(ApplicationFilterChain.java:427)
at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:315)
at org.apache.catalina.core.StandardContextValve.invo keInternal(StandardContextValve.java:287)
at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:218)
at org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:648)
at org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:593)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipel ine.java:94)
at com.sun.enterprise.web.PESessionLockingStandardPip eline.invoke(PESessionLockingStandardPipeline.java :98)
at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:222)
at org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:648)
at org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:593)
at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:587)
at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:1096)
at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:166)
at org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:648)
at org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:593)
at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:587)
at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:1096)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(Co yoteAdapter.java:288)
at com.sun.enterprise.web.connector.grizzly.DefaultPr ocessorTask.invokeAdapter(DefaultProcessorTask.jav a:647)
at com.sun.enterprise.web.connector.grizzly.DefaultPr ocessorTask.doProcess(DefaultProcessorTask.java:57 9)
at com.sun.enterprise.web.connector.grizzly.DefaultPr ocessorTask.process(DefaultProcessorTask.java:831)
at com.sun.enterprise.web.connector.grizzly.DefaultRe adTask.executeProcessorTask(DefaultReadTask.java:3 41)
at com.sun.enterprise.web.connector.grizzly.DefaultRe adTask.doTask(DefaultReadTask.java:263)
at com.sun.enterprise.web.connector.grizzly.DefaultRe adTask.doTask(DefaultReadTask.java:214)
at com.sun.enterprise.web.portunif.PortUnificationPip eline$PUTask.doTask(PortUnificationPipeline.java:3 80)
at com.sun.enterprise.web.connector.grizzly.TaskBase. run(TaskBase.java:265)
at com.sun.enterprise.web.connector.grizzly.ssl.SSLWo rkerThread.run(SSLWorkerThread.java:106)
<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<S:Fault xmlns:ns3="http://www.w3.org/2003/05/soap-envelope">
<faultcode>S:Server</faultcode>
<faultstring>java.lang.NullPointerException</faultstring>
</S:Fault>
</S:Body>
</S:Envelope>
Later, I give up the retrieving the SOAP message and tried to generate a new SOAP message and send it to the sender, as the return type of the connection.call method is SOAPMessage. Here, I could not get any SOAPFault or exceptions. However, when I write out the response to the console, I get a SOAP Message with empty body as shown below.
<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2nMessageResponse xmlns:ns2="http://weather/">
<return/>
</ns2nMessageResponse>
</S:Body>
</S:Envelope>
Any help at the earliest would be really helpful.
Regards,
Arun.