javaweb-servicessoapejbejb-2.x

EJB 2.1 Web Service End Point @WebContext


I have a WSDL file which defines an event operation.

Need to define a SOAP web service end point which is called by a third-party with some parameters as specified in a WSDL file.

The project uses EJB 2.1

Can´t get the end point to work (404 error):

http://localhost:28080/myapp/ws/ClassCallBack

The classes below are inside a JAR file included in the root folder of the EAR file.

Is there anything wrong ? Do I have to declare this class as an EJB in some xml? (in ejb-jar.xml , all EJB Session Beans are declared, but this is not a session bean)

@WebService
public interface ClassCallBackWs {

@WebMethod
  public void event(@WebParam(name = "event") ClassParameter event) 
      throws Exception;      
}

=====================================

@Stateless(name = "ClassCallBackEjb")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@WebService(name = "ClassCallBackWs", portName = "ClassCallBackWs",
        serviceName = "ClassCallBackWsService",
        targetNamespace = "http://test.serverurl.org.com/",
        endpointInterface = "ClassCallBackWs")
@WebContext(contextRoot = "/myapp/ws/", 
            urlPattern = "/v0/ClassCallBackWsImpl", 
            transportGuarantee = "NONE", secureWSDLAccess = false)
public class ClassCallBackWsImpl implements ClassCallBackWs {

    @WebMethod
    public void event(@WebParam(name = "event") ClassParameter event) throws Exception {
    }

}

Solution

  • Give below an example of one possible solution. Created a custom servlet which has a mapping to the implementation class by defining a JAX WS end point in its XML

    (Have concealed all names relating to the final solution, as is private-owned. Sorry if there is a mistake because of this).

    Servlet mapping / XML:

    <servlet-mapping>
        <servlet-name>testws</servlet-name>
        <url-pattern>/myapp/ws/v0/</url-pattern>
    </servlet-mapping>
    

    XML configuration for the servlet used as End Point:

        <jaxws:endpoint
            id="CallBackWs" implementor="org.test.ClassCallBackWsImpl "
            wsdlLocation="WEB-INF/wsdl/CallBackTest.wsdl"
            address="/ClassCallBackWsImpl"
            bindingUri="ClassCallBackWsImpl">
        </jaxws:endpoint>
    

    End point Impl Class:

       @WebService(
          portName = "CallBackWs",
          serviceName = "CallBackWsService", 
          targetNamespace = "http://test.server.callback.ws/", 
          endpointInterface = "org.test.CallBackWs") 
       public class ClassCallBackWsImpl implements ClassCallBackWs{    
           public void event(ClassParameter event) throws Exception { 
           } 
       }
    

    Interface class:

    @WebService(targetNamespace = "http://test.server.callback.ws/", name = "ClassCallBackWs")
    public interface Ws {
        @RequestWrapper(localName = "event", targetNamespace = "http://test.server.callback.ws/", className = "org.test.ClassParameter")
        @WebMethod
        public void event(
            @WebParam(name = "event", targetNamespace = "")
            org.test.ClassParameter event
        ) throws Exception;
    }