Last modified: 6/16/2005

The WAR Contents
 

Typically, one creates the  WAR file with a GUI development tool or with the ant war task from the generated artifacts from wsimport, wsgen, or apt tools.

For example, a sample WAR file starting from a WSDL file:
 

WEB-INF/classes/hello/HelloIF.class          SEI
WEB-INF/classes/hello/HelloImpl.class Endpoint
WEB-INF/sun-jaxws.xml JAX-WS RI deployment descriptor
WEB-INF/web.xml Web deployment descriptor
WEB-INF/wsdl/HelloService.wsdl WSDL
WEB-INF/wsdl/schema.xsd WSDL imports this Schema

The sun-jaxws.xml File

The element contain one or more elements. Each endpoint represents a port in the WSDL and it contains all information about implementation class, servlet url-pattern, binding, WSDL, service, port QNames.  The following shows a sun-jaxws.xml file for a simple HelloWorld service. sun-jaxws.xml is the schema instance of sun-jaxws.xsd.
 


xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime"
version="2.0">
name="MyHello"
implementation="hello.HelloImpl"
url-pattern="/hello"/>


  • endpoint can have the following attributes
  • Attribute Optional
     
    Use
     
    name
    N
     
    Name of the endpoint
     
    wsdl
    Y
     
    Primary wsdl file location in the WAR file. For e.g. WEB-INF/wsdl/HelloService.wsdl. If this isn't specified, JAX-WS will create and publish a new WSDL. When the service is developed from Java, it is recommended to omit this attribute.
     
    service
    Y
     
    QName of WSDL service. For e.g. {http://example.org/}HelloService. When the service is developed from java, it is recommended to omit this attribute.
    port
    Y
     
    QName of WSDL port. For e.g. {http://example.org/}HelloPort. When the service is developed from Java, it is recommended to omit this attribute.
    implementation
    N
     
    Endpoint implementation class name. For e.g: hello.HelloImpl. The class should have @WebService annotation. Provider based implementation class doesn't have to have this annotation.
     
    url-pattern
    N
     
    Should match in web.xml
     
    binding
    Y
     
    Binding id defined in the JAX-WS API. The possible values are:
    "http://schemas.xmlsoap.org/wsdl/soap/http",
    "http://www.w3.org/2003/05/soap/bindings/HTTP/"
    If omitted, it is considered SOAP1.1 binding.
     
    enable-mtom
    Y
     
    Enables MTOM optimization. true or false. Default is false.
     

  •  
  • endpoint can have a optional handler-chain element


>
   
      somename
     
        MyHandler
        hello.MyHandler
     

   


The web.xml File

The following shows a web.xml file for a simple HelloWorld service. It specifies JAX-WS RI specific listener, servlet classes. These classes are com.sun.ws.transport.http.servlet.JAXRPCContextListener, and com.sun.xml.ws.transport.http.servlet.JAXRPCServlet is servlet
 

 






com.sun.xml.ws.transport.http.servlet.JAXRPCContextListener


hello
com.sun.xml.ws.transport.http.servlet.JAXRPCServlet
1


hello
/hello


60


Remember these requirements when building a WAR:

  • WSDL and auxiliary WSDL, Schema files should be packaged under WEB-INF/wsdl dir. It is recommended that they need not be packaged when the service is started from Java
     
  • WebService implementation class should contain @WebService annotation. Provider based endpoints need not have @WebService annotation.
  • wsdl, service, port attributes for endpoint element are mandatory for Provider based endpoints.