Web Services Metadata
By Benoy Jose
Introduction
The web services metadata specification proposes a rapid and
simple solution to define and develop web services. The
specification introduces the concept of adding metadata to the
implementation bean to define a web service. The metadata can be
in the form of custom tags for the different elements in a web
service. The metadata tags would not interfere with the normal
working of the application but would allow a preprocessor to
interpret the metadata tags and generate the appropriate code
for web services. This reduces the amount of code the programmer
has to write for making Java classes behave both as a regular
application and as a web service.
To make this possible the web service metadata specification
uses the "JSR 175 – A Program Annotation Facility for Java"
specification. More information about the program annotation
facility in Java can be found in the references section below.
Anybody familiar with the EJBGEN utility used in weblogic or the
Xdoclet API would appreciate the web services metadata approach.
The ideas of all these APIs are the same. Instead of making the
developer create multiple configuration files, interface classes
and mapping files, these application give the developer the
flexibility to write the business implementation class and
define custom tags with the same class. An interpreter will read
these custom tags and create all the other supporting classes.
The same approach can work for web services, as a web service
requires multiple files for it’s functioning. A web service
developer usually would have to create several artifacts for
defining a web service: a WSDL document outlining the interface
to the web service, a service endpoint which is the Java
representation of a web service interface, a service
implementation bean which has the business logic for the web
service and finally one or more deployment descriptors which
link the WSDL document, the web service interface and the web
service bean together. "JSR –181" alleviates all these problems by
an annotation based web services generation solution.
Features: Listed below are some of the features of the web
services metadata specification.
- It provides a facility to create web services by
creating annotations in Java code.
- It provides a common syntax for web service
definitions, which can be used by developers and can
be manipulated by custom tools.
- It provides a standard and simple way to develop web
services.
- It makes it easier for developers to develop web
services that conform to the standards of SOAP and WSDL.
- It makes it easier to develop web services that work
seamlessly with the core Java web services APIs.
- This separation between the actual web service
implementation and the web service definition helps to
segregate the public web service APIs and the actual business
implementations.
Sample:
import javax.jws.WebService;
import javax.jws.WebMethod ;
@WebService {
name = “SampleWebService” ,
targetNamespace = “http://javaboutique.com/sample/SampleWebService”
}
public class SampleBean{
@WebMethod
public String webServiceMethod1(){
…..
return “Sample Method working”;
}
public void regularMethod1(){
…
}
}
The above sample is a regular Java class that has been annotated with
"JSR –181" web service annotations.
New on the Java Boutique:
New Review:
Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling
API boasts simplicity, ease-of-integration, a well-rounded feature
set, and it's free!
New Applet:
Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA
sequences into three useful formats.
Elsewhere on internet.com:
WebDeveloper Java
Lots of Java information on webdeveloper.com
WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.
ScriptSearch Java
Hundreds of free Java code files to download.
jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.