Hi Nick,

Sorry I couldn't get back to you sooner. Was held up with some travel
last week. So here goes, see my comments inline. (As a summary could
you try this with 1.4.1 as I did fix some REST bugs for this release)

On Thu, Aug 21, 2008 at 6:12 PM, Nick Steel
<[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I've recently started looking at using the REST support in Axis2 to invoke
> my web service instead of the currently used SOAP calls and I have a number
> of issues I can't work out for myself.  Any help with these would be great.
> I've been using Axis2 version 1.3 (and then also tried 1.4 in the hope my
> issues would be solved) and tcpmon to monitor the traffic between my test
> client and my service running locally on tomcat at
> http://localhost:8080/NicksGigs-war-Axis2/services/GigListingsService.  The
> WSDL is created using java2wsdl and is attached.
>
> I've read in another (old) post here that Axis2 is just a soap stack and any
> incoming rest style messages are converted into soap messages first so that
> they can then be processed. Is this still the case?

Yes. Axis2 is primarily a SOAP engine and hence once a message gets
into axis2 it has a SOAP message. So when Axis2 receives a REST
message we do create a SOAP message out of it.

Does this have a
> performance hit? Is there anything in the documentation about this?
>
>
> I'm using (unwrapped) ADB bindings generated by wsdl2java for my test
> client, to use the rest style web calls with the bindings is it simply a
> case of adding the line of code below into my client?
> options.setProperty(Constants.Configuration.ENABLE_REST,
> Constants.VALUE_TRUE);
> I want to clarify this since all the examples I have seen do not use
> bindings.
>
>
> Is it possible to use both POST and GET when my operation parameters are all
> simple types?  To change between the two transports is it simply a case of
> options.setProperty(Constants.Configuration.HTTP_METHOD, HTTP_METHOD_GET);
> Or
> options.setProperty(Constants.Configuration.HTTP_METHOD, HTTP_METHOD_POST);
> ?

Yes you could set the HTTP Method you need as explained above. Axis2
also supports PUT and DELETE.
>
>
> I've found that I can use POST with operations that have parameters but not
> on those without parameters.  For example, a call to getGigsIn("London")
> using HTTP_POST makes the following successful request:
> POST /NicksGigs-war-Axis2/services/GigListingsService HTTP/1.1
> Content-Type: application/xml; charset=UTF-8
> SOAPAction: urn:getGigsIn
> User-Agent: Axis2
> Content-Length: 115
>
> <ns2:getGigsIn
> xmlns:ns2="http://NicksGigs.nsteel.qis.qualcomm.com";><ns2:param0>London</ns2:param0></ns2:getGigsIn>
>
> But a call to getMostActiveArtist() makes the following unsuccessful
> request:
> POST /NicksGigs-war-Axis2/services/GigListingsService HTTP/1.1
> Content-Type: application/xml; charset=UTF-8
> SOAPAction: urn:getMostActiveArtist
> User-Agent: Axis2
> Content-Length: 0
>
> with received error:
> <faultstring>The endpoint reference (EPR) for the Operation not found is
> /NicksGigs-war-Axis2/services/GigListingsService and the WSA Action =
> null</faultstring>
>
> Why doesn't this work??
>
>
> After setting the HTTP_METHOD to HTTP_GET I am unable to make any successful
> calls to my service.  getGigsIn("London") gives:
> GET /NicksGigs-war-Axis2/services/GigListingsService?param0=London HTTP/1.1
> Content-Type: application/x-www-form-urlencoded;
> charset=UTF-8;action="urn:getGigsIn";
> SOAPAction: urn:getGigsIn
> User-Agent: Axis2
>
> <soapenv:Reason
> xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope";><soapenv:Text
> xml:lang="en-US">The endpoint reference (EPR) for the Operation not found is
> /NicksGigs-war-Axis2/services/GigListingsService and the WSA Action =
> null</soapenv:Text></soapenv:Reason>
>
> while getMostActiveArtist() gives:
> GET /NicksGigs-war-Axis2/services/GigListingsService HTTP/1.1
> Content-Type: application/x-www-form-urlencoded;
> charset=UTF-8;action="urn:getMostActiveArtist";
> SOAPAction: urn:getMostActiveArtist
> User-Agent: Axis2
>
> And the same error response.
>
> Shouldn't the bindings be appending the operation name onto the end of the
> endpoint for me?  If I explicitly set the endpoint to
> http://localhost:8080/NicksGigs-war-Axis2/services/GigListingsService/getGigsIn
> it makes the following request:
> GET /NicksGigs-war-Axis2/services/GigListingsService/getGigsIn?param0=London
> HTTP/1.1
> Content-Type: application/x-www-form-urlencoded;
> charset=UTF-8;action="urn:getGigsIn";
> SOAPAction: urn:getGigsIn
> User-Agent: Axis2
>
> Which still gives an error, but this time:
> <soapenv:Reason
> xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope";><soapenv:Text
> xml:lang="en-US">Exception occurred while trying to invoke service method
> getGigsIn</soapenv:Text></soapenv:Reason>
>
> If I simply go to
> http://localhost:8080/NicksGigs-war-Axis2/services/GigListingsService/getGigsIn?city=London
> in my browser I get the correct response.

The above should work for you correctly with codegenerated stubs. Can
you try this with Axis2 -1.4.1 please. I fixed some bugs on REST
invocation for this release and verified that these stuff work.
>
> For me, one of the advantages of the generated bindings is not having to
> worry about the contents of the WSDL; I shouldn't have to know that the WSDL
> says I must specify the "city" parameter in my query string for the
> getGigsIn operation. Why are my ADB bindings setting "param0" instead?

This blog entry (http://wso2.org/blog/sumedha/3727) gives you the
answer to this.
>
>
> Finally, the documentation specifies that Axis2 determines if an incoming
> message is REST or SOAP by checking if "the content type is text/xml and if
> the SOAPAction Header is missing".  If you examine the requests the
> following headers are present for each method.
> HTTP_GET: Both SOAPAction and "action" in Content-Type
> HTTP_POST: Just SOAPAction
> SOAP: Just "action" in Content-Type
>
> What is going on here, are these the correct headers? And what is the
> "SOAPAction Header", is it "SOAPAction" or is it "action" in Content-Type!?
> I also found that when using POST I can even remove the SOAPAction header
> but providing I ensure the Content-Type still contains "application/xml" I
> will still receive the correct (non-soap) response from the service.
>
>
> I'm aware I might be doing something fundamentally wrong on the client side
> (maybe you can't use ADB bindings?) to get these results and I'd be very
> grateful for any responses to any of these questions.

You can use codegenerated stub to invoke REST services.

Thanks,
Keith.
>
> Thanks,
> Nick
> http://www.nabble.com/file/p19087933/example.wsdl example.wsdl
> --
> View this message in context: 
> http://www.nabble.com/Axis2-REST-client-and-server-questions-%28Data-bindings%2C-Headers%2C-Performance%29-tp19087933p19087933.html
> Sent from the Axis - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-- 
Keith Chapman
Senior Software Engineer
WSO2 Inc.
Oxygenating the Web Service Platform.
http://wso2.org/

blog: http://www.keith-chapman.org

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to