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
|