01 JAX-WS Intro
JAX-WS stands for JAVA API for XML based services like any other Java Enterprise Standard comprises of specification and an API.
A SPECIFICATION is a set of rules or guidelines from oracle when they write the Jax-Ws standard. A SPECIFICATION helps the webservices engine like CXF and the glassfish to implement the JAX-WS standard they act as guidelines for these webservices engines.
The API on the other hand is for the develpers and it comprises of a set of java annotations. Once we developer learn this annotations then we can simply mark our java classes and methods with these annotations and we are done. Once we mark our java class with these annotations the webservices engine like CXF at runtime it reads the annotations and take the correct action.
Core Annotations:
@javax.jws.WebService → It is the Java.jws package and all the core annotations are inside of this package.
Ex. @javax.jws.WebService
public class OrderService { …… }
When we mark our java class or interface with this annotation. The webservice engine knows that this class or interface is a endpoint webservice endpoint which can handle webservice requests that are coming in.@javax.jws.WebMethod → We use this against all of our webservices methods each methods in our web services end point.
ex. @WebResult(name=’order”) Order getOrder( @WebParam(name=”orderId”) Long orderId) { … } → It uses two other annotations the @webparam annotation allows us to control the names of the parameter which get what we passed in the SOAP message. Here it is orderId. This will be the xml element. We can control the arguments for our methods using @WebParam.
@webResult → we control how the result should be or the name of the result element using @webResult annotation. Here when a order java object order is sent back on the wire the xml element root element will be order.
@javax.xml.ws.WebFault → It is for custom exception which in turn will be converted into soap faults at runtime.
ex. MyCustomException extends Exception
We simply create the exception class that extends exception like we do in java and mark that class with the webfault and it becomes message.javax.jws.soap.SOAPBinding → by default it is document/literal
ex. @SOAPBinging (style=Style.PC, use = Use.LITERAL)
public interface OrderServiceAnd other is @javax.xml.wsRequestWrapper and javax.xml.wsResponseWrapper
Last but not least the request wrapper and the response wrapper classes allow us to wrap or map the incoming soap message to our Java objects in a custom manner and the response wrapper does the other way around.
if we want to customize the way your response Java object gets converted into a SOAP message. You can write a response wrapper.
We very rarely do this because the jax WS standard already does a great job in converting the soap messages into java objects and java objects into soap messages.
So we very rarely need to write a request wrapper and a response wrapper.
To summarize from this lecture you have learnt what jax WS is, is a standard which allows us to implement soap based web services in the Java world.
Question 1:
The Specification in the JAX-WS is for developers. → False
True
False
Question 2:
Which JAX-WS Annotation can be used to control the name of the web services request parameters in the wsdl/soap request? → @WebParam
@WebRequest
@WebResult
@WebParam
@WebService
Question 3:
Who Owns and Updates the JAX-WS API? → Oracle
Sun Micro Systems
W3C
OASIS
Oracle