Main
SOA

« Image Annotations for the semantic web | Main | AJAX : To Loosely Couple or Not. »

April 4, 2006

Web Services in EJB 3 and WCF very much alike.

By their very nature, web services are the natural choice for designing a service orientated architecture, even though there are proponents which state you don't need the former to obtain the latter, the platform independence offered by web services lends itself to this design. For this reason, its important to realize just how web services are composed in mainstream platforms, while you might expect varying differences among main contenders, there are many similarities in both .NET and Java in their newest web services offerings, WCF (Windows Communication Framework) and EJB 3 (Enterprise Java Beans), respectively.

[Entry continues to the left and below ad ]
Plain Business Logic with Meta-Data.

Both EJB 3 and WCF place great emphasis on creating web services from plain business classes -- POJO's as they are readily referred to in the Java World -- and complementing them with meta-data -- attributes as they are known in .NET -- instead of working with specialized API's or inheritance hierarchies. This not only eases the creation of web services, but also brings benefits to other developments issues ranging from Testing to Re-factoring/Maintenance.

Run-time engines.

The meta-data used in both WCF and EJB is used for "wiring" everything from transactional behaviour to the WSDL contracts that will be used by service clients. This interpretation is achieved by a run time engine, which takes care of translating all meta-data into system code or routines that save development time. In the case of .NET this is WCF run-time, and for Java this would be an application server supporting EJB 3.

Here is a very brief code listing showing both models

WCF Web Service
[ServiceContract]
public class Calculator
{
   [OperationContract]
   public double Add(double a, double b) { // Business logic };  
   [OperationContract]
   private double Subtract(double a, double b) { // Business logic };
}
EJB Web Service
@Stateless
@WebService(serviceName="Calculator")
public class CalculatorBean  {

   @WebMethod
   public double Add(double a, double b) {    // Business logic }

   @WebMethod
   private double Subtract(double a, double b) { // Business logic }

}

Although the previous examples are as simplistic as they can get, it shows the implementing web services patterns used by these two major platforms are very much alike.

[Comments below ad ]

Posted by Daniel at April 4, 2006 4:34 PM


Comments


Post a comment




Remember Me?

(you may use HTML tags for style)

Track back Pings

Track Back URL for this entry:
http://www.webforefront.com/mtblog/mt-tb.cgi/42.

 
XHTML 1.1   Powered by Movable Type 3.33