• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RESTFul webservice with axis2

 
ajay solanki
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am not much familiar with RESTFul webservices. I need to develop some RESTFul webservice using axis2. But I am not able to find any material on this, even though I found some using Jersey.
It would be very helpful if someone could tell any tutorial or a simple example, so I can start.

Thanks in Advance
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13073
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My recommendation is to drop the idea of using AXIS2 for a RESTful service.

Last time I looked it was a real kludge added on to the SOAP engine and does NOT provide for all the REST features, such as returning any kind of resource instead of just XML.

Jersey or Restlet - these are APIs designed from the start to support REST - a much better choice.

Bill
 
ajay solanki
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bill for reply and I do agree with you about using Jersey instead of Axis2 for RESTFul webservices. But I have to use axis2 and I need only XML type as return parameters.
So still waiting for someone to suggest some link for sample code or something which can help.

Thanks
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does the type of data returned have to do with the choice of a proper REST library vs. Axis? Jersey can return XML just fine.
 
ajay solanki
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ulf,

It is nothing to do with the choice of any tool, I said that because Bill mention that using Axis2 I can return only XML. But for me there is no choice, I have to use axis2 for that. I know axis2 is for SOAP web services but they claim it can be used to develop RESTFul web services as well, but I had no luck to find a sample code or something which can show the way to use axis2 to create a RESTFul web service. It will be great help if someone could tell such sample.

Thanks
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13073
6
 
ajay solanki
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bill,
I have gone through the example which you posted. But according to it I have to use WSDL 2.0 to develop REST web services, is there any way that I do not need to use WSDL 2.0, but I am willing to use WADL instead. I mean I do not want to use WSDL 2.0 for that. My requirements are like this. Thanks
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13073
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your requirements have certainly put you in a box

WADL is not necessary for creating a RESTful web service. If you have to use Axis2, you are stuck with WSDL 2.0.

The big commercial services with RESTful architecture seem to depend more on text descriptions and source code examples to assist client development rather than WADL.

Bill

 
Jeff Boucher
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a little hard to answer this question because I don't have a lot of information about what you're trying to do. I'm guessing that you have some kind of data or resource that you'd like to present through consistent (and preferably clean) URI's?

If all you need is GET, you can use Axis2 pretty easily. Here's a link from the Axis2 website:

http://axis.apache.org/axis2/java/core/docs/quickstartguide.html#create

essentially, all you need to do is create a model class that represents the data you'd like to present, and then create a simple POJO that contains the methods you'd use to access this data. Axis2 will turn these methods into a web service. If it's just get, you can pass parameters to the methods through the URL, ie., like

http://servername/axis2/services/myservice/mymethodname?param1=value¶m2=value

Axis2 will take whatever the method returns (probably the model you defined to represent your output) and parse it into XML for you. Unfortunately, the URI isn't especially pretty (and contains request variables), and The default XML will contain a lot of axis-specific tags.

It sounds like Axis2 and REST are strict requirements for you - if what I described above is all you need to do and you had more flexibility with your approach, I think there would be better ways to go about it.







 
ajay solanki
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Thanks for Reply,

I have been going through some articles and sample code for REST web services. So what I understood is that Axis2 has implementation of jax-WS, not jax-RS. But it does supports REST with some restrictions. So if REST needs to be implemented using Axis2 we have to use WSDL 2.0(which is very new). But Jersey has the implementation of Jax-RS so it is the better way to develop any REST web service.

Is that right? If yes, then I will go with Jersey to build REST web service. Thanks
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, Jersey is the proper tool for building REST services.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic