Inside Scoop on J2EE : Tips and tricks on J2EE and Oracle Application Server by Debu Panda
Updated: 4/26/2005; 7:12:38 AM.

 

Subscribe to "Inside Scoop on J2EE" in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.

 
 

Thursday, April 14, 2005

J2EE 5.0 intends to make development of web services applications simpler by making use of web services metadata defined by JSR 181. Goals for EJB 3.0 and JSR 181 are the same to provide developer friendliness. Unfortunately JSR 181 has not gotten coverage like EJB 3.0 (JSR 220). The main reasons are EJB 3.0 has a broader goal and EJB is the core to the J2EE platform.

 

 

For a developing a simple Java web service in J2EE 1.4 you need several web service artifacts such as WSDL, Mapping file, standard and proprietary web services deployment descriptors and these are verbose. JSR 181 is taking configuration by default approach similar to EJB 3.0 to make development easier and you do not need to supply unless you need those. The JSR 181 annotation processor (or web services assembly tool) will generate these files for you and the developer has to worry only about the implementation class.

 

Here is how a simple Java web service looks like when developed using JSR 181 web service metadata

 

 

package oracle.jr181.demo;

import javax.jws.WebMethod;

import javax.jws.WebService;

@WebService(name = "HelloWorldEndpoint", targetNamespace = "http://hello/targetNamespace" )

public class HelloWorldService

{    

@WebMethod       public String sayhello(String name )

{          

return "Hello" +name+ " from jws";

}      

}

 

 

If you are using a Stateless EJB web service and using  JSR 181 and EJB 3.0 then the web service endpoint and bean class will look like the following:

 

package oracle.ejb30.ws;

import javax.ejb.Remote;

import javax.jws.WebService;

 

@WebService

/**

 * This is an Enterprise Java Bean Service Endpoint Interface

 */

public interface HelloServiceInf extends java.rmi.Remote{

 

   

 @WebMethod  java.lang.String sayHello(java.lang.String name) throws java.rmi.RemoteException;

 

}

 

Bean Class:

 

package oracle.ejb30.ws;

 

import java.rmi.RemoteException;

import javax.ejb.Stateless;

 

/**

 * This is a Session Bean Class.

 */

@Stateless(name="HelloServiceEJB")

public class HelloServiceBean implements HelloServiceInf {

 

    public String sayHello(String name) {

        return("Hello "+name +" from first EJB3.0 Web Service");

    }

 

}

 

The good news for SLSB web service is that I do not worry about packaging the ejb-jar xml and other web services descriptors with my ejb-jar.

 

JSR 181 and EJB 3.0 are really going to make our life simpler. In OC4J 10.1.3 that is due this summer we will have support for both JSR 181 and EJB 3.0. We already have EJB 3.0 Preview and we plan to have a final preview of OC4J 10.1.3  next month before we ship OC4J 10.1.3 in summer.


8:40:26 AM    comment []

© Copyright 2005 Debu Panda.

PS: These are my own thoughts and not of my employer ..



Click here to visit the Radio UserLand website.
 


April 2005
Sun Mon Tue Wed Thu Fri Sat
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Mar   May