• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

RestFul web services with Axis 2

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am new to web service and I have to implement RESTFul web service using Axis2.
I have created the service and it is working fine when tested with normal http client.
But when I am trying to call it through other client getting error saying content-type required. When set the content type in client code getting other error which says can not create SOAPEnvelop for REST.

Has enyone faced the same issue ever and able to resolve? If so please tell me how to do it?
 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by yash wardhan:
I am new to web service and I have to implement RESTFul web service using Axis2.



Both Axis 2 and JAX-WS claim to support RESTful web services - in my opinion they are not ideal for the development of RESTful web services.
That is why JAX-RS (JSR-311) was developed which is currently implemented in Jersey and then there is also Restlet.

I'm not expecting the REST support under JAX-WS (and Axis2) to develop any further and wouldn't be surprised if it was deprecated in the future. So it may make more sense for you to switch to an alternative framework whose main focus is the development of RESTful web services.

How NOT to do RESTful Web Services (2007 Jun)
 
yash wardhan
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Peer,
Can you please point me to an article or tutorial of creating RESTFul web services which will have end to end steps of developing a sample application?
I googled but didn't find anything helpful(may be I haven't searched it properly).
It would be really nice if that application doesn't use any IDE or just eclipse.

Thanks in advance
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure about articles, but the Jersey library Peer linked to comes with a number of examples, some of which are pretty basic. The "Get Started" section on its "Learn" page has a number of useful links to introductory material. No IDE is required, and the services can be deployed in a standard servlet container such as Tomcat.
 
yash wardhan
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for Reply,

Actually what I am trying to do is create the RESTFul web service.
It is working fine from java http client.
When tried to call it with j2me client it is working for GET but not for POST.
When the content-type is set through setRequestProperty() method, at the server side getting an error as
"Error in creating a SOAPEnvelope from the REST request".
When I set the content-type from my java http client, then also getting the same error.

Please help me in solving this problem.
Thanks
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by yash wardhan:
"Error in creating a SOAPEnvelope from the REST request".



RESTful web services usually don't choose SOAP envelopes as a representation. This leads me to believe that there is a much more fundamental error at work here - one that cannot be uncovered from the limited information that you are giving here.

Originally posted by yash wardhan:
It is working fine from java http client.
When tried to call it with j2me client it is working for GET but not for POST.



How does the code between the two differ?
What do the HTTP requests/responses look like for both the java http client and the j2me client? (and what is the difference?)

(Use something like Apache TCPMon (Tutorial) or java.net tcpmon to capture/view the HTTP request/response pairs)
[ December 23, 2008: Message edited by: Peer Reynders ]
 
yash wardhan
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Peer,


How does the code between the two differ?
What do the HTTP requests/responses look like for both the java http client and the j2me client? (and what is the difference?)



The http client for java and j2me is same. And there is a normal class with reader and writer. Java's client uses HttpUrlConnection and that of j2me uses the HttpConnection object.
When the request is made from java client I am getting the response.
But when requested from j2me getting an error like
"ContentType should be given to proceed,according to WSDL 2.0 HTTP binding rules".
When the content type is set explicitly, getting the exception as .
Error in creating a SOAPEnvelope from the REST request
This is happening for both java client and j2me client when content-type is set explicitly.

One more question.
Till now I was taking help of IDE to do all the stuff for me. But I don't want that. So I decided to create the aar manually using build file. I am able to create the aar with the same structure as that of the one created by the IDE, but when I deploy it and try from my client(java client which is working well) getting an exception as
"SEVERE: org.apache.axis2.AxisFault: Required element null defined in the schema can not be found in the request".
Can you please tell me what am I missing?

Sorry for the long reply Peer,the exceptions may be basic but I am facing problems to resolve them. Thanks for your reply Peer.

Regards,
Yash
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by yash wardhan:

When the request is made from java client I am getting the response.
But when requested from j2me getting an error like
"ContentType should be given to proceed,according to WSDL 2.0 HTTP binding rules".
When the content type is set explicitly, getting the exception as .
Error in creating a SOAPEnvelope from the REST request
This is happening for both java client and j2me client when content-type is set explicitly.



  • What is the difference in the actual HTTP requests?
  • While it makes sense to use a RESTful web service for a J2ME client it makes no sense to still use SOAP. The is something very wrong with this approach. If you want SOAP, use JAX-RPC through JSR 172, J2ME Web Services Specification. If you want RESTful forget about SOAP and WSDL.

  •  
    reply
      Bookmark Topic Watch Topic
    • New Topic