axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nick Steel <>
Subject Re: Axis2 REST client and server questions (Data bindings, Headers, Performance)
Date Mon, 01 Sep 2008 15:37:07 GMT

Thank you Jay and Keith for your replies.  I've upgraded to version 1.4.1 but
this had made no difference.  Below is a really simple version of my code
taking the options used by Jay in his working service but I can still only
get the correct response using getGigsIn() with POST, every other
combination else fails with: 
<soapenv:Reason xmlns:soapenv="">
	<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>"
String epr =
NicksGigsServiceStub portal = new NicksGigsServiceStub(epr);
Options options = portal._getServiceClient().getOptions();
options.setProperty(Constants.Configuration.ENABLE_REST, Boolean.TRUE);
Gig[] results = portal.getGigsIn("London");
for (int j = 0; j < results.length; j++) 

Note that I had to comment out the MESSAGE_TYPE property for this to work. I
have also commented out the SOAP_ACTION property here since although it did
remove the action(s) in the header it didn't make any difference to the end

The thing which strikes me most about this is that whether using GET or POST
the bindings do not append the method names to the endpoint like I would
expect them to.  I wrongly assumed that at some point the axis generated
code would do something like endpoint+"/"+methodName but it doesn't seem
to...  Is this correct behaviour?

I took a look at the blog entry and after a closer look at my WSDL it seems
that the one generated at 
...NicksGigs-war-Axis2/services/GigListingsService?wsdl has the correct
parameter names, but the wsdl generated by the maven java2wsdl plugin and
then subsequently used by wsdl2java to create my stub has the param0, param1
names. Maven automatically compiles with debug on and I've made no changes
to this so I am a bit confused why I'm getting this. Even more so by the
fact that if I create unwrapped bindings then the correct parameter names
are used.



keith chapman wrote:
> 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
> <> 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,
>> Or
>> options.setProperty(Constants.Configuration.HTTP_METHOD,
>> ?
> 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=""><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=""><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=""><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
>> 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 ( 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
>> example.wsdl
>> --
>> View this message in context:
>> Sent from the Axis - User mailing list archive at
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:
>> For additional commands, e-mail:
> -- 
> Keith Chapman
> Senior Software Engineer
> WSO2 Inc.
> Oxygenating the Web Service Platform.
> blog:
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

View this message in context:
Sent from the Axis - User mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message