I'm working on a web service using the top-down approach, generating service types and interfaces from a WSDL using JAX-WS' wsimport. This provides a port type interface as follows, which I implement.
/**
* This class was generated by the JAX-WS RI.
* JAX-WS RI 2.2.4-b01
* Generated source version: 2.2
*/
@WebService(name = "ExamplePortType", targetNamespace = "http://example.com")
public interface ExamplePortType {
/**
* @param example
* @return java.lang.String
* @throws ExampleException
*/
@WebMethod
@WebResult(name = "exampleResponse", targetNamespace = "http://example.com")
@RequestWrapper(localName = "sendExample", targetNamespace = "http://example.com", className = "com.example.SendExample")
@ResponseWrapper(localName = "sendExampleResponse", targetNamespace = "http://example.com", className = "com.example.SendExampleResponse")
public String sendExample(
@WebParam(name = "example", targetNamespace = "http://example.com")
ExampleRequest example)
throws ExampleException
;
}
It seems like the normal way to add this service to your application server (in my case, Tomcat), is to add the implementation class to the web.xml as a servlet and add WSServletContextListener as a listener. Very roughly, it seems that on initialization of the context, the listener constructs ServletAdapters which wrap the implementation bean and add them to a WSServletDelegate which is called by a thin WSServlet. Requests to your implementation are then handled by the WSServlet and passed to your bean by the delegate based on whatever URL patterns you have set up.
Is there a way to do the above programmatically? I want a method which accepts an instance of the above interface and returns to me an instance of a Servlet, which, if registered in a ServletContext, would route the appropriate requests to the wrapped implementation. Something like:
Servlet exampleServlet = new ServletAdapter().wrap(new ExamplePortTypeImpl());
One requirement is that I cannot rely on static configuration files (such as web.xml or sun-jaxws.xml). Does JAX-WS or a related library (ie: Axis2, etc.) provide this kind of functionality?
Apologies if something is not clear; it's my first time here :). Any pointers are appreciated.
Currently Using JAX-WS 2.1, Tomcat 7, Servlet 3.0.