[prev in list] [next in list] [prev in thread] [next in thread] 

List:       axis-c-user
Subject:    Re: REST with Axis2/C
From:       Samisa Abeysinghe <samisa () wso2 ! com>
Date:       2007-08-29 3:19:25
Message-ID: 46D4E5BD.9010508 () wso2 ! com
[Download RAW message or body]

Subra A Narayanan wrote:
> Hey Samisa,
> 
> The way Axis2/C supports REST is not fully REST compliant (I am sorry 
> to use the word compliant since REST is not really a standard). REST 
> says everything is a resource and URI represent resources. So the URIs 
> should have nouns in them rather than verbs. For e.g. in the Amazon S3 
> webservice example, the uri just had the object name but what action 
> needs to be taken on the object is decided by the HTTP method (GET 
> retrieves the object, DELETE removes it and PUT stores the object. The 
> URI is the same in all the 3 cases)
Yes got the point. I am not a REST expert, so your explanation helps a lot.
> 
> Here are my thoughts:
> 
> I have been going through the Axis2/c framework code and I think I 
> have a fair (although not complete) understanding of how REST works in 
> Axis2. If we can have a way to let the developers of the webservice 
> write their own implementaion of how to handle REST request, that will 
> be great.
> 
> Something like an interface that the developers have to implement so 
> as to receive RESt requests. Once the request is received, it is up to 
> the developers to construct the corresponding SOAP message by looking 
> at the URL and the HTTP method and give it back to the framework which 
> inturn forwards the SOAP envelop to the web service implementation.
This sounds very flexible. There are two points the user can specify 
what they want in case of a service. One is in the services.xml config 
file. The second is the service implementation itself. Non of these 
methods could be used in this case, as we have to first deal with the 
request to identify the service to be invoked. May be, the REST request 
processing could be another service, which will process the request and 
formulate the payload based on the request, and invoke the required 
service within that service.

Thanks,
Samisa...
> 
> They say a picture is worth a thousand words - I will try to summarize 
> this whole thing as a diagram first thing tomorrow morning and send it 
> to you guys.
> 
> I would like to emphasize that the above is my understanding of how 
> REST works and I admit it may be flawed. So feel free to correct me 
> lets discuss what is the best way to implement REST in Axis2.
> 
> 
> Thanks for the help!
> 
> Subra
> 
> 
> On 8/28/07, *Samisa Abeysinghe* < samisa@wso2.com 
> <mailto:samisa@wso2.com>> wrote:
> 
> Subra A Narayanan wrote:
> > Samisa,
> > 
> > I have been looking at the code that you pointed me to and trying to
> > figure out how REST works. Right now, the method name needs to be in
> > the URL for REST to work. To make Axis2/C more RESTful, we would
> need
> > a way to map HTTP methods and keywords in the URI to map to
> webservice
> > method names. I will take amazon s3  service to explain what I mean.
> > Look at the following 2 requests:
> > 
> > #1 get object request
> > 
> > GET /[bucket-name]/[key-name] HTTP/1.0
> > Date: Wed, 08 Mar 2006 04:06:18 GMT
> > Authorization: AWS [aws-access-key-id]:[header-signature]
> > Host: s3.amazonaws.com <http://s3.amazonaws.com>
> <http://s3.amazonaws.com>
> > 
> > 
> > #2 delete object request
> > 
> > DELETE /[bucket-name]/[key-name] HTTP/1.0
> > Date: Wed, 08 Mar 2006 04:06:19 GMT
> > Authorization: AWS [aws-access-key-id]:[header-signature]
> > Host: s3.amazonaws.com <http://s3.amazonaws.com> <
> http://s3.amazonaws.com>
> > 
> > 
> > The above 2 requests look exactly the same except for their HTTP
> > methods: GET vs DELETE. In Axis2/C I think we would need a way
> to may
> > HTTP method name/key word in URI to be mapped to a webservice
> > operation name so that the soap request can be formed accordingly.
> > 
> > Do you have suggestions as to how this can be done in a generic way?
> At the moment, in out GET support for REST, you can get something
> like
> the following working.
> 
> GET /axis2/services/echo/echoString?text=Hello%20World%21 HTTP/1.1
> User-Agent: Axis2/C
> Host: 127.0.0.1:9090 <http://127.0.0.1:9090>
> 
> The mapping that we use at the moment is that the last token in
> request
> URI path become the operation, in this case 'echoString'. And the
> parameters that follow becomes parameter/value pairs. In this case we
> have "text => Hello World". Using parameter/value pairs we
> construct the
> XML payload for the request.
> 
> Now lets consider the sample GET case first. Could you point me to few
> use cases where the format that we are using would not map to the GET
> template that you have provided. That would help me understand
> what we
> should be doing different at Axis2/C level.
> 
> Once we understand the GET case, we can look into DELETE case.
> However,
> if you feel that our current implementation of GET support can handle
> the generic GET template that you are providing, we can use the
> same for
> DELETE as well.
> 
> Thanks,
> Samisa...
> > 
> > Thanks,
> > Subra
> > 
> > 
> > On 8/23/07, *Samisa Abeysinghe* < samisa@wso2.com
> <mailto:samisa@wso2.com>
> > <mailto: samisa@wso2.com <mailto:samisa@wso2.com>>> wrote:
> > 
> > Dinesh Premalal wrote:
> > > Hi Subra,
> > > "Subra A Narayanan" < aswathsn@gmail.com
> <mailto:aswathsn@gmail.com>
> > <mailto: aswathsn@gmail.com <mailto:aswathsn@gmail.com>>>
> writes:
> > > 
> > > > So the solution looks like writing an Apache module (I have
> > never written one
> > > > before) which receives the REST request, translates the
> request
> > to a SOAP
> > > > request and then forwards it on to Axis2/c. But this is
> exactly
> > what Axis2/C is
> > > > also doing.
> > > > 
> > > Yes, that is also a possibility. However I think it will
> be quite
> > > arduous to maintain two apache modules in the long run. I
> would
> > rather
> > > like improving Axis2/C REST support.
> > > 
> > I too think that it would be much simpler to improve the
> current REST
> > support rather than to implement another Apache module.
> > 
> > If you look at the apache module implementation, in source file
> > src/core/transport/http/server/apache2/apache2_worker.c,
> there is a
> > method named axis2_apache2_worker_process_request. If you have a
> > look at
> > this, then you can understand how GET and POST requests are
> dealt
> > with
> > and in turn, this function calls the methods
> > axis2_http_transport_utils_process_http_get_request and
> > axis2_http_transport_utils_process_http_post_request methods
> deal with
> > detailed request processing, including REST stuff. So if you
> want PUT
> > and DELETE you can implement new functions like,
> > axis2_http_transport_utils_process_http_put_request and
> > axis2_http_transport_utils_process_http_delete_request.
> Also, if you
> > want to deal with the media types, before control is passed
> on to
> > Axis2/C, I hope you can do that within
> > axis2_apache2_worker_process_request function, as you have
> access
> > to the
> > request information there.
> > The above are just few suggestions, to use the current
> apache module
> > code and improve that to deal with more REST stuff. However,
> I did not
> > look into that in detail. If you try that and have more
> questions
> > please
> > feel free to ask this list.
> > 
> > Thanks,
> > Samisa...
> > > > I want to start looking in to improving REST support in
> > Axis2/C. Is
> > > > it doable?
> > > > 
> > > Yes, It is.
> > > 
> > > > Am I missing something very obvious which would prevent
> us from
> > implementing
> > > > such support in Axis2? If not please let me know as to
> where I
> > should start
> > > > looking in the Axis2 source.
> > > > 
> > > You could start at looking HTTP transport I guess. If you
> could
> > debug
> > > echo_rest sample, it will be helpful to understand the
> underlying
> > > logic.
> > > 
> > > thanks,
> > > Dinesh
> > > 
> > 
> > 
> > --
> > Samisa Abeysinghe : WSO2 WSF/C
> > "
> > 
> http://wso2.org/projects/wsf/c?WSO2&nbsp;Web&nbsp;Services&nbsp;Framework/C&nbsp;-&n \
> bsp;Open&nbsp;source&nbsp;C&nbsp;library&nbsp;for&nbsp;providing&nbsp;and&nbsp;consuming&nbsp;Web&nbsp;services
>  <http://wso2.org/projects/wsf/c?WSO2%C2%A0Web%C2%A0Services%C2%A0Framework/C%C2%A0- \
> %C2%A0Open%C2%A0source%C2%A0C%C2%A0library%C2%A0for%C2%A0providing%C2%A0and%C2%A0consuming%C2%A0Web%C2%A0services>
> 
> > <
> http://wso2.org/projects/wsf/c?WSO2&nbsp;Web&nbsp;Services&nbsp;Framework/C&nbsp;-&n \
> bsp;Open&nbsp;source&nbsp;C&nbsp;library&nbsp;for&nbsp;providing&nbsp;and&nbsp;consuming&nbsp;Web&nbsp;services
>  <http://wso2.org/projects/wsf/c?WSO2%C2%A0Web%C2%A0Services%C2%A0Framework/C%C2%A0- \
> %C2%A0Open%C2%A0source%C2%A0C%C2%A0library%C2%A0for%C2%A0providing%C2%A0and%C2%A0consuming%C2%A0Web%C2%A0services>>"
> 
> > 
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> axis-c-user-unsubscribe@ws.apache.org
> <mailto:axis-c-user-unsubscribe@ws.apache.org>
> > <mailto:axis-c-user-unsubscribe@ws.apache.org
> <mailto:axis-c-user-unsubscribe@ws.apache.org>>
> > For additional commands, e-mail:
> axis-c-user-help@ws.apache.org <mailto:axis-c-user-help@ws.apache.org>
> > <mailto:axis-c-user-help@ws.apache.org
> <mailto:axis-c-user-help@ws.apache.org>>
> > 
> > 
> 
> 
> --
> Samisa Abeysinghe : WSO2 WSF/C
> "
> http://wso2.org/projects/wsf/c?WSO2&nbsp;Web&nbsp;Services&nbsp;Framework/C&nbsp;-&n \
> bsp;Open&nbsp;source&nbsp;C&nbsp;library&nbsp;for&nbsp;providing&nbsp;and&nbsp;consuming&nbsp;Web&nbsp;services
>  <http://wso2.org/projects/wsf/c?WSO2%C2%A0Web%C2%A0Services%C2%A0Framework/C%C2%A0- \
> %C2%A0Open%C2%A0source%C2%A0C%C2%A0library%C2%A0for%C2%A0providing%C2%A0and%C2%A0consuming%C2%A0Web%C2%A0services>"
>  
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
> <mailto:axis-c-user-unsubscribe@ws.apache.org>
> For additional commands, e-mail: axis-c-user-help@ws.apache.org
> <mailto:axis-c-user-help@ws.apache.org>
> 
> 


-- 
Samisa Abeysinghe : WSO2 WSF/C
"http://wso2.org/projects/wsf/c?WSO2&nbsp;Web&nbsp;Services&nbsp;Framework/C&nbsp;-&nb \
sp;Open&nbsp;source&nbsp;C&nbsp;library&nbsp;for&nbsp;providing&nbsp;and&nbsp;consuming&nbsp;Web&nbsp;services"



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-user-help@ws.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic