Friday, February 14, 2014

JAX-WS Web Service with SOAP 1.2

JAX-WS uses the SOAP 1.1 for the Web Services if the SOAP version is not explicitly defined (By Default). this is the default behavior.  if you want to use SOAP 1.2 for your web service, then you may need to explicitly declare it in the web service. then following annotation can be used to explicitly define the SOAP version of the web service.

For SOAP 1.2

@BindingType(value = SOAPBinding.SOAP12HTTP_BINDING) 


Sample Java Implementation

package com.chathurangaonline.sample.jaxws;

import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.xml.ws.BindingType;
import javax.xml.ws.soap.SOAPBinding;

/**
 * <p>
 *     Service Implementation Bean (SIB) for CalculatorService endpoint interface
 * </p>
 */
@WebService
@BindingType(value = SOAPBinding.SOAP12HTTP_BINDING)
public class CalculatorServiceImpl implements CalculatorService{


    @WebMethod
    public long add(long number1, long number2) {
        return number1+number2;
    }

    @WebMethod
    public long subtract(long number1, long number2) {
        return number1+number2;
    }

    @WebMethod
    public long multiply(long number1, long number2) {
        return number1*number2;
    }
}
 
Hope this will be helpful for you!

Thanks and Regards

Chathuranga Tennakoon
www.chathurangaonline.com

No comments:

Post a Comment