How to invoke an Axis2 JAXWS service RESTfully?

Have you ever tried to invoke an Axis2 JAXWS service in RESTful manner? Was it successfull? If not, you will find the reason in this post. And also you will find how to do it.

Most of the time we write simple JAXWS services like this..

public class JAXWSAARService {

@WebMethod (operationName = “echo”, action = “urn:echo”)
public String echo(String in) {
return in;


In this service, @BindingType annotation is not used and according to the JAXWS specification, the default is SOAP 11 binding. So the generated WSDL for the above service will only generate a SOAP 11 binding. That’s why we can’t invoke the service in RESTful manner. If you try it, it will give you the following error.

“Incoming message protocol does not match endpoint protocol.”

In order to invoke a service RESTfully, an HTTP binding is needed. Therefore in the above service, you have to use the @BindingType annotation and set it’s value to HTTP binding as follows.

@BindingType(value= HTTPBinding.HTTP_BINDING)
public class JAXWSAARService {


Now the Axis2 JAXWS deployer will generate an HTTP binding for you. Now you can invoke the service RESTfully using the following URL.





About isurues
Age : 24 Date of Birth : 05.11.1984 Country : Sri Lanka

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: