What are the list of Annotation in JAX-WS in Java? Different types of annotations are being used in JAX-WS for implementing Java JAX-WS web services.
You will learn various Java JAX-WS annotations and its used. This post is very intesting because you find Java JAX-WS annotations cheat sheet.
1. Annotation in JAX-WS used
In Java JAX-WS all the annotation driven class exist in javax.ws
package. Java JAX-WS annotations cheat sheet as follows in the form of table.
Annotation Name | Description |
@WebService | This is used to tell to JAX-WS container that this class is used as webservice. this annotation will be on SEI (Service Endpoint Interface) and its implementation class. |
@WebMethod | this annotation is used on business method level of class which has expose as webservice. |
@SOAPBinding | used to bind either RPC or Document style of webservice. |
@HandlerChain | used for intercepting of incoming request and outgoing going response and vice-versa. this can be used in service and client both side. or any one of them. |
@WebserviceProvider | This is used to tell this class is used a service end point. |
@WebParam | This is used in webservice parameter in method. |
@WebResult | This is used as return in java webservice exposed method. |
2. @WebService Annotation
import javax.jws.WebService; @WebService public class GreetingServiceImpl implements GreetingService { public String printMessage() { return "Hello, World!"; } }
3. @WebMethod Annotation Example
@WebMethod will be used on the method level only for notifying to JVM this method will be used as an operation. This specified this method represents the operation of web service. And the Method will be public accessibility.
import javax.jws.WebService; @WebService @SOAPBinding(style = SOAPBinding.Style.RPC) public class GreetingServiceImpl implements GreetingService { @WebMethod public String printMessage() { return "Hello, World!"; } }
4. @SOAPBinding Annotation Example
This @SOAPBinding
annotation in JAX-WS is used to specify the SOAP messaging style
which further can either be RPC
stype or Document
style. Here, style
represents the encoding style of message sent to and fro while using the Java web service.
import javax.jws.WebService; import javax.jws.soap.SOAPBinding; @WebService @SOAPBinding(style = SOAPBinding.Style.RPC) public class GreetingServiceImpl implements GreetingService { public String printMessage() { return "Hello, World!"; } }
5. @HandlerChain Annotation Example
import javax.jws.HandlerChain; import javax.jws.WebService; import javax.jws.soap.SOAPBinding; @WebService @HandlerChain(file = "handlers.xml") @SOAPBinding(style = SOAPBinding.Style.RPC) public class GreetingServiceImpl implements GreetingService { public String printMessage() { return "Hello, World!"; } }
11. Reference for Java JAX-WS Annotations
For more details of Java JAXWS wsgen example you can visit Java JAX-WS annotations
Thanks for visiting this page for Java JAX-WS annotations.
Happy Learning 🙂 for annotation in JAX-WS java, you can visit JAX-WS web services tutorial page.
Your comments are welcome to improve this post. Happy Learning! 🙂
I have to to read more writing from you! And I will share this |blog immediately. Thanks!