2 Replies Latest reply on Jul 30, 2012 3:42 PM by Igor Urdenko

    Is it possible to create JBoss web service without EJB?

    Igor Urdenko Newbie

      Hello,

       

      I have a question regarding webservice creation.

       

      I have an EJB which has a lot of methods that use heavy objects as a parameters. I tried to create a webservice from the EJB but found that I have also to change all classes that define the methods parameters. I cannot completely recreate these classes. So, I decided to create a web service class which will have methods with simple-type parameters. This web service will create correct parameters and call EJB methods.

       

      I tried to create a simple web service adding @WebService annotation to the class and @WebMethod to its methods but I cannot deploy this web service to JBoss. There are no error but my web service is not displayed in JMX console.

       

      So, the question is - is it possible to create and deploy a simple web service based on POJO, not an EJB? If yes, then how?

       

      I am using JBoss 4.2.3.GA with default configuration.

       

      Sincerely,

      Igor Urdenko

        • 1. Re: Is it possible to create JBoss web service without EJB?
          Peter Johnson Master

          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>
          • 2. Re: Is it possible to create JBoss web service without EJB?
            Igor Urdenko Newbie

            Thank you!

            Where was my head?! I completely forgot about WAR and was dealing with JAR...

            Thank you very much.