In Java, people used to write an interface first and they
stick to the interface before writing the implementation class. The interface
will obviously tells us what are all the input arguments, return type and
exception if any. In web service the client won’t directly communicate with the
implementation class. The client used to
talk with the interface. So we can do any modifications in the implementation
class.
If you want to change anything in the interface like adding
new service methods or adding new arguments to the existing service method
leads to more problems. All the clients
using your web service would be notified to use the updated one - version 2.0.
This might leads to the code change. Solution for this would be sticks to the
service interface and do not alter it.
But in the case web service we are writing the
Implementation class first!!! Yes we are writing the HelloWorld interface and
HelloWorldImpl class first. Then generated the WSDL out of it. (See the blog
post How to generate the WSDL from implementation class). So which one should
come first? Is it WSDL or implementation class? We can do this in either way.
In our case first we have written the implementation class first and generated
WSDL out of it. It is known as service first or implementation first approach
or bottom up approach.
There are some tools available to generate the WSDL. So we
can write a WSDL first and generate classes which are necessary for writing a
web service out of it. This is known as contract first or WSDL first approach
or Top down approach.
No comments:
Post a Comment