2 Replies Latest reply on Oct 14, 2008 6:54 PM by Peter Johnson

    Web Service - what needs to be in the .war?

    Clark Valentine Newbie


      I'm more or less a newbie to Java EE, and I'm attempting to design a web service that accepts incoming SOAP requests and does (something). I've been playing with sample code, but I can't get anything to deploy correctly. For some reason, I cannot find a good, solid list of what needs to be in a .war file for a web service.

      So? Can anyone give me a nickel tour of a .war file as JBoss expects to see it? Is it different whether I use a servlet, an EJB, or both in my design?


      - Clark Valentine, Java EE n00b

        • 1. Re: Web Service - what needs to be in the .war?
          Peter Johnson Master

          In a WAR filer all you need are the POJO web service and the web.xml.

          Simple hello service:

          package ws.simple;
          public class HelloService {
           public String sayHello(String name) {
           return "Hello, " + name;

          The web.xml:
          <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"

          And the contents of the resulting hello.war:

          Caveat: The above was transcribed from a slightly more complex web service, so it might have typos, but other than that it should be all you need.

          • 2. Re: Web Service - what needs to be in the .war?
            Peter Johnson Master

            If your web service is EJB-based, all you need is a jar file with the web service class.

            Add two more annotations to the class:

            @org.jboss.wsf.spi.annotation.WebContext(contextRoot="/hello", urlPattern="/hello")
            public class HelloService {...}

            And the contents of hello.jar: