Smart and funny ways to save money during recession
A quick refresher of JAX-WS basics!
—————————————————————————————————-
Concepts:
—————————————————————————————————-
- JAX-WS stands for Java API for XML Web Services.
- It allows to write message-oriented as well as RPC-oriented web services
- A web service invocation is done using an xml based protocol like SOAP
- The developer does not generate or parse SOAP messages.JAX-WS runtime takes care of it.
- A service endpoint interface or service endpoint implementation (SEI) is a Java interface or class, respectively, that declares the methods that a client can invoke on the service.
- An interface is not required when building a JAX-WS endpoint. The web service implementation class implicitly acts as an SEI.
- Jax-WS clients call a service through a port, a local object that acts as a proxy for the remote service.
—————————————————————————————————-
Requirements of a JAX-WS Endpoint:
—————————————————————————————————-
- The implementing class must be annotated with either the javax.jws.WebService or javax.jws.WebServiceProvider annotation.
- The implementing class may explicitly reference an SEI through the endpointInterface element of the @WebService annotation, but is not required to do so. If no endpointInterface is specified in @WebService, an SEI is implicitly defined for the implementing class.
- The business methods of the implementing class must be public, and must not be declared static or final.
- Business methods that are exposed to web service clients must be annotated with javax.jws.WebMethod.
- Business methods that are exposed to web service clients must have JAXBcompatible parameters and return types.
- The implementing class must not be declared final and must not be abstract.
- The implementing class must have a default public constructor.
- The implementing class must not define the finalize method.
- The implementing class may use the javax.annotation.PostConstruct or javax.annotation.PreDestroy annotations on its methods for life cycle event callbacks.
—————————————————————————————————-
Steps to create a Service:
—————————————————————————————————-
- Define a Service (web service endpoint) by annotating the class with @WebService annotation
- If an explicit interface is used then it can be specified by adding the endpointInterface element to the @WebService annotation
- Use endpoint implementation class and the wsgen tool to generate the web service artifacts that connect a web service client to the JAX-WS runtime.
- Package it as a war and deploy. Application Server generates the web service artifacts (which are used to communicate with clients) during deployment.
—————————————————————————————————-
Steps to create a Client:
—————————————————————————————————-
- Uses the javax.xml.ws.WebServiceRef annotation to declare a reference to a web service. @WebServiceRef uses the wsdlLocation element to specify the URI of the deployed service’s WSDL file.
- Retrieve a port to the service. The port is created at development time by the wsimport tool, which generates JAX-WS portable artifacts based on a WSDL file.
- Invoke the web service method
RK
Filed under: Technology | Tagged: jax-ws, Technology, webservice
This topic is quite hot in the net at the moment. What do you pay attention to while choosing what to write ?