weird soap issue: Cannot find the dispatch method

Hi,

I'm having strange problem with SOAP message.

I created a simple web service using jax-ws, wsgen, and so on. I deployed it on sun app server 9.0. I wrote client application (i'm using SAAJ 1.3) for testing. The response I'm getting is something like this:

<soapenv:Envelope xmlns:ns1="http://put/"

xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<soapenv:Body>

<soapenv:Fault>

<faultcode>soapenv:Client</faultcode>

<faultstring>Cannot find the dispatch method</faultstring>

</soapenv:Fault>

</soapenv:Body>

</soapenv:Envelope>

First I thought there's a problem with webservice I created. So I downloaded soapui (www.soapui.org) for testing. I provided it with wsdl and endpoint. And web sevice seems to work corectly - response I got back was ok.

The strange part is: soap messages sent from soapui and from client application written by me seem to be identical. Both look like this:

<SOAP-ENV:Envelope

xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:put="http://put">

<SOAP-ENV:Body>

<put:sayHello>

<arg0>test</arg0>

</put:sayHello>

</SOAP-ENV:Body>

</SOAP-ENV:Envelope>

I even sniffed packets (WinDump) sent to application server and in both cases soap message is the same. There's only a slight difference in http headers. Here's what server log contains after receiving a soap message from my client application:

DetailsTimestamp:2006-09-14 13:28:03.315

Log Level: SEVERE

Logger:javax.enterprise.resource.webservices.jaxws.server.soapmd

Name-Value Pairs:_ThreadID=13;

Record Number:443

Message ID:Error in decoding SOAP Message Error in decoding SOAP Message at com.sun.xml.ws.encoding.

soap.server.SOAPXMLDecoder.toInternalMessage(SOAPXMLDecoder.java

Complete Message

86)

at com.sun.xml.ws.protocol.soap.server.SOAPMessageDispatcher.

toMessageInfo(SOAPMessageDispatcher.java:168)

at com.sun.xml.ws.protocol.soap.server.SOAPMessageDispatcher$SoapInvoker.

invoke(SOAPMessageDispatcher.java:533)

at com.sun.xml.ws.protocol.soap.server.SOAPMessageDispatcher.receive(SOAPMessageDispatcher.java:144)

at com.sun.xml.ws.server.Tie.handle(Tie.java:88)

at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.handle(WSServletDelegate.java:279)

at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doPost(WSServletDelegate.java:232)

at com.sun.xml.ws.transport.http.servlet.WSServlet.doPost(WSServlet.java:77)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:767)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:860)

at sun.reflect.GeneratedMethodAccessor61.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:585)

at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)

at java.security.AccessController.doPrivileged(Native Method)

at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)

at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)

at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:257)

at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55)

at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:161)

at java.security.AccessController.doPrivileged(Native Method)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:263)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)

at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:225)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:173)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:132)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)

at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:933)

at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:189)

at com.sun.enterprise.web.connector.grizzly.ProcessorTask.doProcess(ProcessorTask.java:604)

at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:475)

at com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:371)

at com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:264)

at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:281)

at com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:83)

Caused by: javax.xml.ws.soap.SOAPFaultException: Cannot find the dispatch method

at com.sun.xml.ws.encoding.soap.SOAPDecoder.raiseFault(SOAPDecoder.java:662)

at com.sun.xml.ws.encoding.soap.server.SOAPXMLDecoder.decodeDispatchMethod(SOAPXMLDecoder.java:151)

at com.sun.xml.ws.encoding.soap.SOAPDecoder.decodeBodyContent(SOAPDecoder.java:335)

at com.sun.xml.ws.encoding.soap.SOAPDecoder.decodeBody(SOAPDecoder.java:325)

at com.sun.xml.ws.encoding.soap.SOAPDecoder.decodeEnvelope(SOAPDecoder.java:248)

at com.sun.xml.ws.encoding.soap.server.SOAPXMLDecoder.toInternalMessage(SOAPXMLDecoder.java:78)

... 39 more

I'm new to web services and I'm completely out of ideas what is the problem. I googled a lot but I can't find any solution. Any help would be appreciated :)

null

[6447 byte] By [frikraaga] at [2007-10-3 4:58:27]
# 1
For JAXWS services, If you want to construct your soap messages by yourself and send it to the service side, you need to do so through the Dispatch class. please turn to the Client API section in the JAXWS 2.0 specification for detailed instructions. you can find very good examples there.
@smile@a at 2007-7-14 23:03:49 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

Are you saying I can't just write jax-ws based web service using @WebService and @WebMethod and then, on client side, write code like this?

SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();

SOAPConnection connection = soapConnectionFactory.createConnection();

MessageFactory factory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);

SOAPMessage request = factory.createMessage();

//

// create proper message elements

//

URL endpoint = new URL(endpoint_url);

SOAPMessage response = connection.call(request, endpoint);

//

// process response

//

frikraaga at 2007-7-14 23:03:49 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3
Stupidity beyond belief! Solved. SOAP messages I mentioned earlier wasn't identical: I didn't notice missing trailing slash:wasxmlns:put=" http://put"should bexmlns:put=" http://put/"
frikraaga at 2007-7-14 23:03:49 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...