Annotation in JAX-WS

Connect with

Oracle Java
This post is about differnet types of annoation which are being used in JAX-WS. There are different annotation used in JAX-WS which you should know.

1. JAX-WS Annotation used

In JAX-WS all the annotation driven class exist in javax.ws package.
[table “” not found /]

2. @WebService Annotation

import javax.jws.WebService;

@WebService
public class GreetingServiceImpl implements GreetingService {

    public String printMessage() {
        return "Hello, World!";
    }
}

3. @WebMethod Annotation Example

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

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!";
    }
}

Your comments are welcome to improve this post. Happy Learning 🙂


Connect with

Leave a Reply

Your email address will not be published. Required fields are marked *