[jboss-user] [Beginners Corner] - Re: Web Service - what needs to be in the .war?

PeterJ do-not-reply at jboss.com
Tue Oct 14 18:48:10 EDT 2008


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

Simple hello service:
package ws.simple;
  | @javax.jws.WebService
  | public class HelloService {
  |   @javax.jws.WebMethod
  |   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"
  |   version="2.5"
  | >
  |   <servlet>
  |     <servlet-name>HelloService</servlet-name>
  |     <servlet-class>ws.simple.HelloService</servlet-class>
  |   </servlet>
  |   <servlet-mapping>
  |     <servlet-name>HelloService</servlet-name>
  |     <url-pattern>/hello</url-pattern>
  |   </servlet-mapping>
  | </web-app>

And the contents of the resulting hello.war:
WEB-INF/web.xml
WEB-INF/classes/ws/simple/HelloService.class

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.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4182249#4182249

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4182249



More information about the jboss-user mailing list