JBoss Community

Re: Is it possible to create JBoss web service without EJB?

created by Peter Johnson in JBoss Web Services - View the full discussion

Yes you can. Just package the web service in a WAR and deploy. Here's a simple class for a hello web service:

 

package my.web.service;
import javax.jws.WebService;
import javax.jws.WebMethod;
 
@WebService()
public class Hello {
  @WebMethod()
  public String hello(String name) {
    return "Hello " + name;
  }
}

and here is the web.xml for it:

<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>Hello</servlet-name>
    <servlet-class>my.web.service.Hello</servlet-class>
  </servlet>
 
  <servlet-mapping>
    <servlet-name>Hello</servlet-name>
    <url-pattern>/hello</url-pattern>
  </servlet-mapping>
</web-app>

Reply to this message by going to Community

Start a new discussion in JBoss Web Services at Community