Sunday Apr 22, 2007
Today's Page Hits: 183
Sunday Apr 22, 2007
As the debate regarding the right way to service contract design has increased as can be seen from here, and here, I wanted to reiterate some of the points I made earlier regarding the same. When designing a Service Contract, you can take two major approaches - well three (if you factor in the Meet-in-the-Middle case) but in reality that is a mix of the other two. The approaches as I have already mentioned in a previous blog entry are:
As I have already mentioned, the preferred approach to Service Contract Design is the Top-Down approach, namely Contract-First Development.
You should avoid the Bottom-up approach, namely Implementation-First Development as much as possible. Granted that an Implementation-First approach allows the developer to write a lot of code that we developers are fond of writing, and tools like the NetBeans SOA pack can generate WSDL and XSD from the implemented classes. There are a lot of issues with the Implementation-First approach, but I will re-iterate a couple of them in this blog entry once again:
Therefore, try to avoid Implementation-First Development as much as possible. However, if you do have to do Implementation-First Development, you have to pay special attention to the following points:
Moreover, when exposing the Interface Endpoint, you have a couple of choices to make. Your service endpoint can be exposed as:
In this approach, the service is generally implemented as a Stateless EJB SessionBean and therefore, multi-threaded access is handled by the EJB Container. Also, since the service interface is exposed through an EJB, the service runs in the transactional context of the EJB container. This has many advantages for example, for one, it allows you to declaratively demarcate transactions.
In this approach, the service is generally implemented as a servlet, and therefore, the service has to handle concurrent client access on its own. Since the service implementation is done through a servlet, the transactional context is unspecified. For the same reason, you do not have any declarative means to start a transaction.
Please be aware of these when designing your service contract.
Like this write-up? Subscribe to receive more like it.
Disclaimer: The contents of this Weblog represent my personal opinion which may differ from the official views of my employer, Sun Microsystems, Inc. or any past employers.