WAR file


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 <endpoints> element contain one or more <endpoint> 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.

<?xml version="1.0" encoding="UTF-8"?>
<endpoints
xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime"
version="2.0">
<endpoint
name="MyHello"
implementation="hello.HelloImpl"
url-pattern="/hello"/>
</endpoints>

<?xml version="1.0" encoding="UTF-8"?>
<endpoints ...">
<endpoint ...>
    <handler-chain>
      <handler-chain-name>somename</handler-chain-name>
      <handler>
        <handler-name>MyHandler</handler-name>
        <handler-class>hello.MyHandler</handler-class>
      </handler>
    </handler-chain>
</endpoint>
</endpoints>

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

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">

<web-app>
<listener>
<listener-class>com.sun.xml.ws.transport.http.servlet.JAXRPCContextListener</listener-class>
</listener>
<servlet>
<servlet-name>hello</servlet-name>
<servlet-class>com.sun.xml.ws.transport.http.servlet.JAXRPCServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>hello</servlet-name>
<url-pattern>/hello</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>60</session-timeout>
</session-config>
</web-app>

Remember these requirements when building a WAR:



Copyright © 2005 Sun Microsystems, Inc. All rights reserved.