Java – Needed: Tomcat + Axis2 + JAX-WS guide for dummies

axis2javajax-wstomcatweb services

We are working with Tomcat + Axis2 + POJO for web service implementation, and we encountered some issues with POJO and Axis2 that are a showstopper for us.
It seems that Axis2 and POJO implementation of SOAP parsing ignores the names of the XML elements and just assign values to the arguments according to the order of the XML elements in the SOAP message. This thing causes a lot of problems in complex APIs.

After some swimming in the documentation swamp of Axis2 I was more confused then I came in, so I really need some help.

I understand that JAX-WS and Axis2 doesn't have those issues (correct me if I'm wrong), but I can't seem to know how to develop and deploy such solution.

I wrote a POJO, and annotated it with the JAX-WS annotations, I executed wsgen on the class, and packed all in an aar file along with this services.xml file:

<service name="TESTService" >
    <description>
        TEST web service
    </description>
    <messageReceivers>
        <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only" class="org.apache.axis2.jaxws.server.JAXWSMessageReceiver" />
        <messageReceiver  mep="http://www.w3.org/2004/08/wsdl/in-out"  class="org.apache.axis2.jaxws.server.JAXWSMessageReceiver"/>
    </messageReceivers>
    <parameter name="ServiceClass">com.test.WsdlImpl</parameter>
</service>

When I try to execute a web service call I get an exception in Tomcat:

 [ERROR] The service class cannot be found for this AxisService.
java.lang.RuntimeException: The service class cannot be found for this AxisService.
    at org.apache.axis2.jaxws.server.JAXWSMessageReceiver.receive(JAXWSMessageReceiver.java:95)
    at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:176)
    at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:275)
    at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:133)
    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:233)
    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:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Unknown Source)

Please help me by explaining how to deploy a JAX-WS with Tomcat + Axis2 (if CXF works with Tomcat I can use it also), or direct me to a GOOD tutorial that covers Tomcat+Axis2.

Thanks!!

Best Answer

Straight from Axis2 Web site, this is a tutorial covering Axis2 and Jax-Ws. You get the above error probably because the axis2-jaxws-1.3.jar is missing. Check your classpath.

You can of course use CXF with Tomcat and my personal opinion is that you would be better off with it.

Related Topic