You’ll find some useful tips for Web Service interop at Top Ten Tips for Web Services Interoperability and in my german article Entwicklung interoperabler Web Services mit J2EE und .NET in the dotnetpro magazine (Login required).
Sometimes I hear the question “Why not decouple the service from the caller by using generic interfaces?”
To better understand this question let’s have a look at the following pseudo code example:
Flight getAvailableFlights(date flightDate, string destination);
bool bookFlight(int flightId);
The Web Service BookingService has two methods, which can be called by the clients and is described in an BookingService.wsdl file.
If we would like to add a new method for instance cancelFlight(int flightId) we have to change the caller of the service. In most cases this means rebuilding the client side proxy.
Why not using a generic interface like one of the following:
Generic parameter approach:
Map getAvailableFlights(Map params);
Map bookFlight(Map params);
This approach uses only generic parameters but no generic service operations.
Generic service approach:
Map execute(int commandId,Map params);
This approcach uses the common command pattern. It means the client sends a command id toghether with the required parameters to the service.
Dependent of the command id the service dispatches the call to the service implementation.
In order to add the service method cancelFlight we simply have to add a new command. The contract remains unchanged and the proxy hasn’t to be rebuild.
And even better the parameters can be processed in a generic way. That’s cool, isn’t it?
At first glance this approach looks promising. But at what price?
A common misunderstanding is that the Web Service Signature described in the WSDL file forms the service contract. This is only one option.
More precisely said the name of the service operation (or command id) in conjunction with the required in and out parameters form the contract.
It doesn’t matter where this information is stored.
What really happens when using generic interfaces is that the contract is shifted from a standarized to a custom layer.
That means the contract is not described in the BookingService.wsdl file anymore. Now the service and the caller need a proprietary way to describe and exchange the contract.
Moreover the type safety is lost because only generic types are used.
The command dispatching must be implemented. This is usually handled by the Web Service infrastructure for instance by using the SoapAction in the HTTP-Header.
Generic parameter processing is not a reason to use generic interfaces. If necessary reflection can be used to process typed parameters in a generic way, but without loosing type safety.
I think the drawbacks of generic interfaces outweight the benefits.
What do you think?
A friend of mine Antoine Doubacis who works at the olympic games in Athens took this picture in the olympic village.
It somehow reminds me to SOA. Looks complicated but has well defined interfaces. Quite impressive.
During the recent months I had to deal with several open source implementations like Log4J, Jacorb or Tomcat. While I was happy that it is free in terms of licence cost I was unhappy about some other issues that campe up when using it in an productive environment.
To make things clearer it sometimes helps to use an analogy.
In many aspects the use of software is similar to using like for instance a car or a hifi-system.
So what would you expect when buying a car? (at least I’m expecting that)
A .It should bring you from A to B in a secure and fast way.
B. It should be reliable and error free.
C. If an error comes up the garage should fix it as fast as possible.
D. The price/quality ratio should be reasonable.
Does it really matter, how the car works under the hood or that you can fix it on your own?
I think for 99% of drivers the answer is no.
The same applies to open source software. The fact that a software is open, semi open or closed source is not really a feature of a software (except of rare mainly academic cases).
The important thing is that the price/quality ratio is good so that it’s worth using it.
In brief the advantage of the features must be higher than the disadvantage of the cost.
I think this it true of all kinds of software.
My advice is as follows:
Use open source software when:
A. You can replace it easily without a lot of effort
B. The price/quality ratio is good in terms of total cost of ownership (TCO – be honest)
C. You are a geek and love it to do everything on your own
D. There is no other solution around
Don’t use open source software when:
A. You need a solution for infrastructure or mission critical applications except you can replace it easily
B. You need professional and guaranteed support
C. The open source software module can break the entire application
D. You have no choice due to your corporate policies
I know that this issue is very controversial – so what do you think?