You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-user@axis.apache.org by Subra A Narayanan <as...@gmail.com> on 2007/08/23 04:49:42 UTC

REST with Axis2/C

Good morning folks!

This is more of a approach/design question rather than an Axis2/C question.

The project I am working on requires that I provide both SOAP and REST
interface to my webservice. With Axis2/C SOAP is no big deal. But REST is
something I am not too sure about. As it says in the API documentation
itself, Axis2/C is a SOAP toolkit and REST is not supported that well.

These 2 issues in particular
1) There is no support for PUT and DELETE
2) Also the way Axis2/C requires the operation name and the operation
parameters in the url, is a shift away from REST as there is no resource
representation.

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.

I want to start looking in to improving REST support in Axis2/C. Is it
doable? 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.

If the above approach is not feasible, I will have to look at other ways of
supporting REST. One way would be to write my own apache module.

I would love to hear any comments/suggestions.


Thanks a lot for all the help!

Subra

Re: REST with Axis2/C

Posted by Samisa Abeysinghe <sa...@wso2.com>.
Subra A Narayanan wrote:
> Thanks for all your help Samisa!
You are most welcome :)

One more note, if you want to look into libcurl, we already have a 
client transport based on libcurl located in the folder 
src/core/transport/http/sender/libcurl/

If you have a look into that code, you can get some idea on how to use 
libcurl API.

Thanks,
Samisa...

-- 
Samisa Abeysinghe : WSO2 WSF/C
"http://wso2.org/projects/wsf/c?WSO2&nbsp;Web&nbsp;Services&nbsp;Framework/C&nbsp;-&nbsp;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


Re: REST with Axis2/C

Posted by Subra A Narayanan <as...@gmail.com>.
Thanks for all your help Samisa!


On 9/4/07, Samisa Abeysinghe <sa...@wso2.com> wrote:
>
> Sorry about the late reply - please see my comments in line.
> Subra A Narayanan wrote:
> > Good Morning Samisa,
> >
> > Could you pls elaborate a little bit more on ur statement "The problem
> > you would have to solve in
> > this case would be, how to handle the resources requested to a service."
> First, there is an error in my statement. It is not "how to handle",
> rather it should be "how to map". Sorry about that.
> Now to what I meant; when the request comes, you have to locate the
> service. In Axis2/C jargon, we call this process 'dispatching', and
> there are multiple dispatch mechanisms - from those request URL based
> dispatcher could be used for REST case.
> >
> > I am not sure I understand that correctly.
> >
> > Also can you point me to code in Axis2/C framework where I could begin
> > looking to get ideas for my module (this is the first time I will be
> > writing one). Also I will start looking into libcurl. Is threading a
> > major issue that needs to be dealt with while writing modules?
> Our apache module code is located inside the folder
> src/core/transport/http/server/apache2/
>
> Threading is not an issue - APR, the core library that httpd runs on,
> handles those for you - you just have to worry about how to handle
> requests.
>
> Thanks,
> Samisa...
>
> --
> Samisa Abeysinghe : WSO2 WSF/C
> "
> http://wso2.org/projects/wsf/c?WSO2&nbsp;Web&nbsp;Services&nbsp;Framework/C&nbsp;-&nbsp;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
>
>

Re: REST with Axis2/C

Posted by Samisa Abeysinghe <sa...@wso2.com>.
Sorry about the late reply - please see my comments in line.
Subra A Narayanan wrote:
> Good Morning Samisa,
>
> Could you pls elaborate a little bit more on ur statement "The problem 
> you would have to solve in
> this case would be, how to handle the resources requested to a service."
First, there is an error in my statement. It is not "how to handle", 
rather it should be "how to map". Sorry about that.
Now to what I meant; when the request comes, you have to locate the 
service. In Axis2/C jargon, we call this process 'dispatching', and 
there are multiple dispatch mechanisms - from those request URL based 
dispatcher could be used for REST case.
>
> I am not sure I understand that correctly.
>
> Also can you point me to code in Axis2/C framework where I could begin 
> looking to get ideas for my module (this is the first time I will be 
> writing one). Also I will start looking into libcurl. Is threading a 
> major issue that needs to be dealt with while writing modules?
Our apache module code is located inside the folder 
src/core/transport/http/server/apache2/

Threading is not an issue - APR, the core library that httpd runs on, 
handles those for you - you just have to worry about how to handle requests.

Thanks,
Samisa...

-- 
Samisa Abeysinghe : WSO2 WSF/C
"http://wso2.org/projects/wsf/c?WSO2&nbsp;Web&nbsp;Services&nbsp;Framework/C&nbsp;-&nbsp;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


Re: REST with Axis2/C

Posted by Subra A Narayanan <as...@gmail.com>.
Good Morning Samisa,

Could you pls elaborate a little bit more on ur statement "The problem you
would have to solve in
this case would be, how to handle the resources requested to a service."

I am not sure I understand that correctly.

Also can you point me to code in Axis2/C framework where I could begin
looking to get ideas for my module (this is the first time I will be writing
one). Also I will start looking into libcurl. Is threading a major issue
that needs to be dealt with while writing modules?


Thanks in advance!
Subra

On 9/3/07, Samisa Abeysinghe <sa...@wso2.com> wrote:
>
> Subra A Narayanan wrote:
> > Samisa,
> >
> > Thank you for ur reply.
> >
> > I think I agree with ur views. I think I will have to look for other
> > ways of supporting REST for my web service. I was loking in to writing
> > my own apache module since all I need is access to the request_rec
> > struct, parse the uri and then call the same library (its a c++
> > library with a C like interface) that I call from my SOAP web service.
> >
> > Do you think thats what I need? Do you think it would be better to use
> > some other library/framework rather than writing my own module? Do you
> > know of any such framework for REST?
> There are no C REST libraries as such that I know of out there. However,
> you can leverage the features of an HTTP library like libcurl. libcurl
> is a client side library though. Hence it looks it is better to write
> your own Apache httpd module for the server side, because then you have
> control over what you could do. The problem you would have to solve in
> this case would be, how to handle the resources requested to a service.
> I think it would not be a big deal to come up with a mechanism - you can
> even get some ideas and/or code form Axis2/C to do that. Axis2/C code
> also has a mime parser, so you can use that code too to pick up MIME
> attachments form requests.
>
> Thanks,
> Samisa...
>
>
>
>
> --
> Samisa Abeysinghe : WSO2 WSF/C
> "
> http://wso2.org/projects/wsf/c?WSO2&nbsp;Web&nbsp;Services&nbsp;Framework/C&nbsp;-&nbsp;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
>
>

Re: REST with Axis2/C

Posted by Samisa Abeysinghe <sa...@wso2.com>.
Subra A Narayanan wrote:
> Samisa,
>
> Thank you for ur reply.
>
> I think I agree with ur views. I think I will have to look for other 
> ways of supporting REST for my web service. I was loking in to writing 
> my own apache module since all I need is access to the request_rec 
> struct, parse the uri and then call the same library (its a c++ 
> library with a C like interface) that I call from my SOAP web service.
>
> Do you think thats what I need? Do you think it would be better to use 
> some other library/framework rather than writing my own module? Do you 
> know of any such framework for REST?
There are no C REST libraries as such that I know of out there. However, 
you can leverage the features of an HTTP library like libcurl. libcurl 
is a client side library though. Hence it looks it is better to write 
your own Apache httpd module for the server side, because then you have 
control over what you could do. The problem you would have to solve in 
this case would be, how to handle the resources requested to a service. 
I think it would not be a big deal to come up with a mechanism - you can 
even get some ideas and/or code form Axis2/C to do that. Axis2/C code 
also has a mime parser, so you can use that code too to pick up MIME 
attachments form requests.

Thanks,
Samisa...




-- 
Samisa Abeysinghe : WSO2 WSF/C
"http://wso2.org/projects/wsf/c?WSO2&nbsp;Web&nbsp;Services&nbsp;Framework/C&nbsp;-&nbsp;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


Re: REST with Axis2/C

Posted by Subra A Narayanan <as...@gmail.com>.
Samisa,

Thank you for ur reply.

I think I agree with ur views. I think I will have to look for other ways of
supporting REST for my web service. I was loking in to writing my own apache
module since all I need is access to the request_rec struct, parse the uri
and then call the same library (its a c++ library with a C like interface)
that I call from my SOAP web service.

Do you think thats what I need? Do you think it would be better to use some
other library/framework rather than writing my own module? Do you know of
any such framework for REST?

Your insight is much appreciated.

Regards,
Subra


On 9/3/07, Samisa Abeysinghe <sa...@wso2.com> wrote:
>
> Subra A Narayanan wrote:
> > Hey Samisa,
> >
> > First, I apologize for the delay in replying.
> >
> > I feel, the reason REST has got so much attention lately is because of
> > its perceived simplicity. I feel supporting REST by converting REST
> > requests in to SOAP requests behind the scenes may not be a good idea.
> > One major problem that I can see with that approach is how do we
> > handle REST requests with attachments?
> >
> > Can we have the ability in Axis2 to define 2 service endpoints? Lets
> > say something like
> >
> > http://www.foo.com/axis2c/ <http://www.foo.com/axis2c/> - for SOAP
> > (which is how axis2c works today)
> >
> > http://www.foo.com/axis2c/REST - for REST
> >
> >
> > Then in the axis2_apache2_worker_process_request function in the
> > apache2_worker.c file, depending on the end point either axis2
> > continues to do what it is doing today or hands over the request
> > (request_rec struct) to the user written code who can process it in
> > anyway and return a response. This will give so much flexibility to
> > for REST development. The ws creator can then take care of issues like
> > attachments, multiple parametrs for the operations etc at the same
> > time making use of the rich library that axis2 provides. And also the
> > user (service creator) can let axis2 worry abt threading and memory
> > management issues.
> As I understand, what you are requesting is to let the messages pass
> through to user code without modification in case of REST. Using the
> endpoint to do this is kind of tricky, as in the future, we may allow
> the user to modify the prefix in the URI, and also the user may have a
> service named 'REST'.
> By peeking at the message, the Axis2/C engine could tell if it is a SOAP
> call or not, already. Hence your scenario could be easily supported,
> where all those non SOAP cases are passed on to a separate processing
> unit. However, when doing this, we have to keep in mind that, one of the
> design features of Axis2/C was to help user write one service and serve
> both REST and SOAP requests. If we adopt your scenario, this would not
> be possible, as REST services would be independent form SOAP services.
> One of the solutions to keep the current model and still use the
> attachment and multiple parameter scenarios of REST would be to improve
> our HTTP processing model to support those cases. At the moment, those
> features are not supported because we did not think of those in the
> initial design. However, we could even use a third party library to deal
> with those cases, as far as I can understand.
> Axis2/C is basically a SOAP engine and supporting REST was thought to
> be  an added advantage. Given your requirement of supporting full REST,
> it is questionable if it is a good idea to piggyback on Axis2/C. I would
> assume it would be better for you to use Axis2/C for SOAP and use
> another lib for REST purposes, unless you want the benefit of both SOAP
> and REST with the same service.
>
> On a related note, I looked into the Java implementation and we can
> afford to deal with DELETE the same manner we deal with GET and deal
> with PUT similar to POST processing. However, I am not sure how
> attachments have to be dealt with.
>
> Tanks,
> Samisa...
>
> >
> > Such a feature would be a great help for developers like us who want
> > to provide a full fledged REST support for our services. Thoughts?
> >
> > Subra
> >
> >
> >
> >
> > On 8/29/07, * Samisa Abeysinghe* < samisa@wso2.com
> > <ma...@wso2.com>> wrote:
> >
> >
> >     >>
> >     >> 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.
> >     I looked at how Axis2/Java has implemented REST yesterday, and
> >     they seem
> >     to have done some improvements over the initial model that we have
> >     used
> >     in C.
> >
> >     The ideas come from WSDL 2.0 Adjuncts:
> >     http://www.w3.org/TR/wsdl20-adjuncts/
> >
> >     Basically you can provide a resource config in services.xml to map
> >     resources to operations and payload formats.
> >     You can have the config syntax of a resource like the following
> >
> http://localhost/axis2/services/[service_name]/[operation_name]/[val_1]/[val_2]
> >     <
> http://localhost/axis2/services/%5Bservice_name%5D/%5Boperation_name%5D/%5Bval_1%5D/%5Bval_2%5D
> >
> >
> >     So I can have something like the following in the services.xml file:
> >     http://localhost/axis2/services/echo/echoString/text
> >     <http://localhost/axis2/services/echo/echoString/text>
> >
> >     And the REST client is requesting for the resource
> >     http://localhost/axis2/services/echo/echoString/Hello%20World
> >
> >     I can map that resource to service 'echo' and build the payload
> >         <echoString>
> >            <text>
> >               Hello World
> >            </text>
> >         </echoString>
> >
> >     I can use the URL based dispatcher to find the payload. I think we
> can
> >     implement this model without much trouble on top of Axis2/C
> >     architecture.
> >
> >     Thoughts please...
> >
> >     Thanks,
> >     Samisa...
> >
> >     And if your mapping is like
> >     >
> >     > 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
> >     <ma...@wso2.com>
> >     >> <mailto: samisa@wso2.com <ma...@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>
> >     >>     <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 <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>
> >     <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
> >     <ma...@wso2.com>
> >     >>     <mailto:samisa@wso2.com <ma...@wso2.com>>
> >     >>     > <mailto: samisa@wso2.com <ma...@wso2.com>
> >     <mailto:samisa@wso2.com <ma...@wso2.com>>>> wrote:
> >     >>     >
> >     >>     >     Dinesh Premalal wrote:
> >     >>     >     > Hi Subra,
> >     >>     >     > "Subra A Narayanan" < aswathsn@gmail.com
> >     <ma...@gmail.com>
> >     >>     <mailto:aswathsn@gmail.com <ma...@gmail.com>>
> >     >>     >     <mailto: aswathsn@gmail.com
> >     <ma...@gmail.com> <mailto: aswathsn@gmail.com
> >     <ma...@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;-&nbsp;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%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;-&nbsp;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%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
> >     <ma...@ws.apache.org>
> >     >>     <mailto:axis-c-user-unsubscribe@ws.apache.org
> >     <ma...@ws.apache.org>>
> >     >>     >     <mailto: axis-c-user-unsubscribe@ws.apache.org
> >     <ma...@ws.apache.org>
> >     >>     <mailto:axis-c-user-unsubscribe@ws.apache.org
> >     <ma...@ws.apache.org>>>
> >     >>     >     For additional commands, e-mail:
> >     >>     axis-c-user-help@ws.apache.org
> >     <ma...@ws.apache.org>
> >     >> <mailto: axis-c-user-help@ws.apache.org
> >     <ma...@ws.apache.org>>
> >     >>     >     <mailto: axis-c-user-help@ws.apache.org
> >     <ma...@ws.apache.org>
> >     >>     <mailto: axis-c-user-help@ws.apache.org
> >     <ma...@ws.apache.org>>>
> >     >>     >
> >     >>     >
> >     >>
> >     >>
> >     >>     --
> >     >>     Samisa Abeysinghe : WSO2 WSF/C
> >     >>     "
> >     >>
> >     >>
> >
> http://wso2.org/projects/wsf/c?WSO2&nbsp;Web&nbsp;Services&nbsp;Framework/C&nbsp;-&nbsp;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%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
> >     <ma...@ws.apache.org>
> >     >>     <mailto:axis-c-user-unsubscribe@ws.apache.org
> >     <ma...@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
> >     <ma...@ws.apache.org>>
> >     >>
> >     >>
> >     >
> >     >
> >
> >
> >     --
> >     Samisa Abeysinghe : WSO2 WSF/C
> >     "
> >
> http://wso2.org/projects/wsf/c?WSO2&nbsp;Web&nbsp;Services&nbsp;Framework/C&nbsp;-&nbsp;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
> >     <ma...@ws.apache.org>
> >     For additional commands, e-mail: axis-c-user-help@ws.apache.org
> >     <ma...@ws.apache.org>
> >
> >
>
>
> --
> Samisa Abeysinghe : WSO2 WSF/C
> "
> http://wso2.org/projects/wsf/c?WSO2&nbsp;Web&nbsp;Services&nbsp;Framework/C&nbsp;-&nbsp;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
>
>

Re: REST with Axis2/C

Posted by Samisa Abeysinghe <sa...@wso2.com>.
Subra A Narayanan wrote:
> Hey Samisa,
>
> First, I apologize for the delay in replying.
>
> I feel, the reason REST has got so much attention lately is because of 
> its perceived simplicity. I feel supporting REST by converting REST 
> requests in to SOAP requests behind the scenes may not be a good idea. 
> One major problem that I can see with that approach is how do we 
> handle REST requests with attachments?
>
> Can we have the ability in Axis2 to define 2 service endpoints? Lets 
> say something like
>
> http://www.foo.com/axis2c/ <http://www.foo.com/axis2c/> - for SOAP 
> (which is how axis2c works today)
>
> http://www.foo.com/axis2c/REST - for REST
>
>
> Then in the axis2_apache2_worker_process_request function in the 
> apache2_worker.c file, depending on the end point either axis2 
> continues to do what it is doing today or hands over the request 
> (request_rec struct) to the user written code who can process it in 
> anyway and return a response. This will give so much flexibility to 
> for REST development. The ws creator can then take care of issues like 
> attachments, multiple parametrs for the operations etc at the same 
> time making use of the rich library that axis2 provides. And also the 
> user (service creator) can let axis2 worry abt threading and memory 
> management issues.
As I understand, what you are requesting is to let the messages pass 
through to user code without modification in case of REST. Using the 
endpoint to do this is kind of tricky, as in the future, we may allow 
the user to modify the prefix in the URI, and also the user may have a 
service named 'REST'.
By peeking at the message, the Axis2/C engine could tell if it is a SOAP 
call or not, already. Hence your scenario could be easily supported, 
where all those non SOAP cases are passed on to a separate processing 
unit. However, when doing this, we have to keep in mind that, one of the 
design features of Axis2/C was to help user write one service and serve 
both REST and SOAP requests. If we adopt your scenario, this would not 
be possible, as REST services would be independent form SOAP services.
One of the solutions to keep the current model and still use the 
attachment and multiple parameter scenarios of REST would be to improve 
our HTTP processing model to support those cases. At the moment, those 
features are not supported because we did not think of those in the 
initial design. However, we could even use a third party library to deal 
with those cases, as far as I can understand.
Axis2/C is basically a SOAP engine and supporting REST was thought to 
be  an added advantage. Given your requirement of supporting full REST, 
it is questionable if it is a good idea to piggyback on Axis2/C. I would 
assume it would be better for you to use Axis2/C for SOAP and use 
another lib for REST purposes, unless you want the benefit of both SOAP 
and REST with the same service.

On a related note, I looked into the Java implementation and we can 
afford to deal with DELETE the same manner we deal with GET and deal 
with PUT similar to POST processing. However, I am not sure how 
attachments have to be dealt with.

Tanks,
Samisa...

>
> Such a feature would be a great help for developers like us who want 
> to provide a full fledged REST support for our services. Thoughts?
>
> Subra
>
>
>
>
> On 8/29/07, * Samisa Abeysinghe* < samisa@wso2.com 
> <ma...@wso2.com>> wrote:
>
>
>     >>
>     >> 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.
>     I looked at how Axis2/Java has implemented REST yesterday, and
>     they seem
>     to have done some improvements over the initial model that we have
>     used
>     in C.
>
>     The ideas come from WSDL 2.0 Adjuncts:
>     http://www.w3.org/TR/wsdl20-adjuncts/
>
>     Basically you can provide a resource config in services.xml to map
>     resources to operations and payload formats.
>     You can have the config syntax of a resource like the following
>     http://localhost/axis2/services/[service_name]/[operation_name]/[val_1]/[val_2]
>     <http://localhost/axis2/services/%5Bservice_name%5D/%5Boperation_name%5D/%5Bval_1%5D/%5Bval_2%5D>
>
>     So I can have something like the following in the services.xml file:
>     http://localhost/axis2/services/echo/echoString/text
>     <http://localhost/axis2/services/echo/echoString/text>
>
>     And the REST client is requesting for the resource
>     http://localhost/axis2/services/echo/echoString/Hello%20World
>
>     I can map that resource to service 'echo' and build the payload
>         <echoString>
>            <text>
>               Hello World
>            </text>
>         </echoString>
>
>     I can use the URL based dispatcher to find the payload. I think we can
>     implement this model without much trouble on top of Axis2/C
>     architecture.
>
>     Thoughts please...
>
>     Thanks,
>     Samisa...
>
>     And if your mapping is like
>     >
>     > 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
>     <ma...@wso2.com>
>     >> <mailto: samisa@wso2.com <ma...@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>
>     >>     <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 <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>
>     <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
>     <ma...@wso2.com>
>     >>     <mailto:samisa@wso2.com <ma...@wso2.com>>
>     >>     > <mailto: samisa@wso2.com <ma...@wso2.com>
>     <mailto:samisa@wso2.com <ma...@wso2.com>>>> wrote:
>     >>     >
>     >>     >     Dinesh Premalal wrote:
>     >>     >     > Hi Subra,
>     >>     >     > "Subra A Narayanan" < aswathsn@gmail.com
>     <ma...@gmail.com>
>     >>     <mailto:aswathsn@gmail.com <ma...@gmail.com>>
>     >>     >     <mailto: aswathsn@gmail.com
>     <ma...@gmail.com> <mailto: aswathsn@gmail.com
>     <ma...@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;-&nbsp;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%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;-&nbsp;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%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
>     <ma...@ws.apache.org>
>     >>     <mailto:axis-c-user-unsubscribe@ws.apache.org
>     <ma...@ws.apache.org>>
>     >>     >     <mailto: axis-c-user-unsubscribe@ws.apache.org
>     <ma...@ws.apache.org>
>     >>     <mailto:axis-c-user-unsubscribe@ws.apache.org
>     <ma...@ws.apache.org>>>
>     >>     >     For additional commands, e-mail:
>     >>     axis-c-user-help@ws.apache.org
>     <ma...@ws.apache.org>
>     >> <mailto: axis-c-user-help@ws.apache.org
>     <ma...@ws.apache.org>>
>     >>     >     <mailto: axis-c-user-help@ws.apache.org
>     <ma...@ws.apache.org>
>     >>     <mailto: axis-c-user-help@ws.apache.org
>     <ma...@ws.apache.org>>>
>     >>     >
>     >>     >
>     >>
>     >>
>     >>     --
>     >>     Samisa Abeysinghe : WSO2 WSF/C
>     >>     "
>     >>
>     >>
>     http://wso2.org/projects/wsf/c?WSO2&nbsp;Web&nbsp;Services&nbsp;Framework/C&nbsp;-&nbsp;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%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
>     <ma...@ws.apache.org>
>     >>     <mailto:axis-c-user-unsubscribe@ws.apache.org
>     <ma...@ws.apache.org>>
>     >>     For additional commands, e-mail:
>     axis-c-user-help@ws.apache.org <ma...@ws.apache.org>
>     >>     <mailto:axis-c-user-help@ws.apache.org
>     <ma...@ws.apache.org>>
>     >>
>     >>
>     >
>     >
>
>
>     --
>     Samisa Abeysinghe : WSO2 WSF/C
>     "
>     http://wso2.org/projects/wsf/c?WSO2&nbsp;Web&nbsp;Services&nbsp;Framework/C&nbsp;-&nbsp;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
>     <ma...@ws.apache.org>
>     For additional commands, e-mail: axis-c-user-help@ws.apache.org
>     <ma...@ws.apache.org>
>
>


-- 
Samisa Abeysinghe : WSO2 WSF/C
"http://wso2.org/projects/wsf/c?WSO2&nbsp;Web&nbsp;Services&nbsp;Framework/C&nbsp;-&nbsp;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


Re: REST with Axis2/C

Posted by Subra A Narayanan <as...@gmail.com>.
Hey Samisa,

First, I apologize for the delay in replying.

I feel, the reason REST has got so much attention lately is because of its
perceived simplicity. I feel supporting REST by converting REST requests in
to SOAP requests behind the scenes may not be a good idea. One major problem
that I can see with that approach is how do we handle REST requests with
attachments?

Can we have the ability in Axis2 to define 2 service endpoints? Lets say
something like

http://www.foo.com/axis2c/ - for SOAP (which is how axis2c works today)

http://www.foo.com/axis2c/REST - for REST


Then in the axis2_apache2_worker_process_request function in the
apache2_worker.c file, depending on the end point either axis2 continues to
do what it is doing today or hands over the request (request_rec struct) to
the user written code who can process it in anyway and return a response.
This will give so much flexibility to for REST development. The ws creator
can then take care of issues like attachments, multiple parametrs for the
operations etc at the same time making use of the rich library that axis2
provides. And also the user (service creator) can let axis2 worry abt
threading and memory management issues.

Such a feature would be a great help for developers like us who want to
provide a full fledged REST support for our services. Thoughts?

Subra




On 8/29/07, Samisa Abeysinghe < samisa@wso2.com> wrote:
>
>
> >>
> >> 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.
> I looked at how Axis2/Java has implemented REST yesterday, and they seem
> to have done some improvements over the initial model that we have used
> in C.
>
> The ideas come from WSDL 2.0 Adjuncts:
> http://www.w3.org/TR/wsdl20-adjuncts/
>
> Basically you can provide a resource config in services.xml to map
> resources to operations and payload formats.
> You can have the config syntax of a resource like the following
> http://localhost/axis2/services/[service_name]/[operation_name]/[val_1]/[val_2]
>
> <http://localhost/axis2/services/%5Bservice_name%5D/%5Boperation_name%5D/%5Bval_1%5D/%5Bval_2%5D>
>
> So I can have something like the following in the services.xml file:
> http://localhost/axis2/services/echo/echoString/text
>
> And the REST client is requesting for the resource
> http://localhost/axis2/services/echo/echoString/Hello%20World
>
> I can map that resource to service 'echo' and build the payload
>     <echoString>
>        <text>
>           Hello World
>        </text>
>     </echoString>
>
> I can use the URL based dispatcher to find the payload. I think we can
> implement this model without much trouble on top of Axis2/C architecture.
>
> Thoughts please...
>
> Thanks,
> Samisa...
>
> And if your mapping is like
> >
> > 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
> >>     <ma...@wso2.com>
> >>     > <mailto: samisa@wso2.com <mailto:samisa@wso2.com >>> wrote:
> >>     >
> >>     >     Dinesh Premalal wrote:
> >>     >     > Hi Subra,
> >>     >     > "Subra A Narayanan" < aswathsn@gmail.com
> >>     <ma...@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;-&nbsp;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%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;-&nbsp;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%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
> >>     <ma...@ws.apache.org>
> >>     >     <mailto: axis-c-user-unsubscribe@ws.apache.org
> >>     <ma...@ws.apache.org>>
> >>     >     For additional commands, e-mail:
> >>     axis-c-user-help@ws.apache.org
> >> <ma...@ws.apache.org>
> >>     >     <mailto: axis-c-user-help@ws.apache.org
> >>     <ma...@ws.apache.org>>
> >>     >
> >>     >
> >>
> >>
> >>     --
> >>     Samisa Abeysinghe : WSO2 WSF/C
> >>     "
> >>
> >> http://wso2.org/projects/wsf/c?WSO2&nbsp;Web&nbsp;Services&nbsp;Framework/C&nbsp;-&nbsp;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%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
> >>     <ma...@ws.apache.org>
> >>     For additional commands, e-mail: axis-c-user-help@ws.apache.org
> >>     <ma...@ws.apache.org>
> >>
> >>
> >
> >
>
>
> --
> Samisa Abeysinghe : WSO2 WSF/C
> "http://wso2.org/projects/wsf/c?WSO2&nbsp;Web&nbsp;Services&nbsp;Framework/C&nbsp;-&nbsp;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
> For additional commands, e-mail: axis-c-user-help@ws.apache.org
>
>

Re: REST with Axis2/C

Posted by Samisa Abeysinghe <sa...@wso2.com>.
>>
>> 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.
I looked at how Axis2/Java has implemented REST yesterday, and they seem 
to have done some improvements over the initial model that we have used 
in C.

The ideas come from WSDL 2.0 Adjuncts: http://www.w3.org/TR/wsdl20-adjuncts/

Basically you can provide a resource config in services.xml to map 
resources to operations and payload formats.
You can have the config syntax of a resource like the following
http://localhost/axis2/services/[service_name]/[operation_name]/[val_1]/[val_2]

So I can have something like the following in the services.xml file:
http://localhost/axis2/services/echo/echoString/text

And the REST client is requesting for the resource
http://localhost/axis2/services/echo/echoString/Hello%20World

I can map that resource to service 'echo' and build the payload
    <echoString>
       <text>
          Hello World
       </text>
    </echoString>

I can use the URL based dispatcher to find the payload. I think we can 
implement this model without much trouble on top of Axis2/C architecture.

Thoughts please...

Thanks,
Samisa...

And if your mapping is like
>
> 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 
>> <ma...@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
>>     <ma...@wso2.com>
>>     > <mailto: samisa@wso2.com <ma...@wso2.com>>> wrote:
>>     >
>>     >     Dinesh Premalal wrote:
>>     >     > Hi Subra,
>>     >     > "Subra A Narayanan" < aswathsn@gmail.com
>>     <ma...@gmail.com>
>>     >     <mailto: aswathsn@gmail.com <ma...@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;-&nbsp;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;-&nbsp;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
>>     <ma...@ws.apache.org>
>>     >     <mailto:axis-c-user-unsubscribe@ws.apache.org
>>     <ma...@ws.apache.org>>
>>     >     For additional commands, e-mail:
>>     axis-c-user-help@ws.apache.org 
>> <ma...@ws.apache.org>
>>     >     <mailto:axis-c-user-help@ws.apache.org
>>     <ma...@ws.apache.org>>
>>     >
>>     >
>>
>>
>>     --
>>     Samisa Abeysinghe : WSO2 WSF/C
>>     "
>>     
>> http://wso2.org/projects/wsf/c?WSO2&nbsp;Web&nbsp;Services&nbsp;Framework/C&nbsp;-&nbsp;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
>>     <ma...@ws.apache.org>
>>     For additional commands, e-mail: axis-c-user-help@ws.apache.org
>>     <ma...@ws.apache.org>
>>
>>
>
>


-- 
Samisa Abeysinghe : WSO2 WSF/C
"http://wso2.org/projects/wsf/c?WSO2&nbsp;Web&nbsp;Services&nbsp;Framework/C&nbsp;-&nbsp;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


Re: REST with Axis2/C

Posted by Samisa Abeysinghe <sa...@wso2.com>.
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 
> <ma...@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
>     <ma...@wso2.com>
>     > <mailto: samisa@wso2.com <ma...@wso2.com>>> wrote:
>     >
>     >     Dinesh Premalal wrote:
>     >     > Hi Subra,
>     >     > "Subra A Narayanan" < aswathsn@gmail.com
>     <ma...@gmail.com>
>     >     <mailto: aswathsn@gmail.com <ma...@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;-&nbsp;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;-&nbsp;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
>     <ma...@ws.apache.org>
>     >     <mailto:axis-c-user-unsubscribe@ws.apache.org
>     <ma...@ws.apache.org>>
>     >     For additional commands, e-mail:
>     axis-c-user-help@ws.apache.org <ma...@ws.apache.org>
>     >     <mailto:axis-c-user-help@ws.apache.org
>     <ma...@ws.apache.org>>
>     >
>     >
>
>
>     --
>     Samisa Abeysinghe : WSO2 WSF/C
>     "
>     http://wso2.org/projects/wsf/c?WSO2&nbsp;Web&nbsp;Services&nbsp;Framework/C&nbsp;-&nbsp;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
>     <ma...@ws.apache.org>
>     For additional commands, e-mail: axis-c-user-help@ws.apache.org
>     <ma...@ws.apache.org>
>
>


-- 
Samisa Abeysinghe : WSO2 WSF/C
"http://wso2.org/projects/wsf/c?WSO2&nbsp;Web&nbsp;Services&nbsp;Framework/C&nbsp;-&nbsp;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


Re: REST with Axis2/C

Posted by Subra A Narayanan <as...@gmail.com>.
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)

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.

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 <sa...@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>
> >
> >
> > #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>
> >
> >
> > 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
>
> 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>> wrote:
> >
> >     Dinesh Premalal wrote:
> >     > Hi Subra,
> >     > "Subra A Narayanan" < 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;-&nbsp;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;-&nbsp;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
> >     <ma...@ws.apache.org>
> >     For additional commands, e-mail: axis-c-user-help@ws.apache.org
> >     <ma...@ws.apache.org>
> >
> >
>
>
> --
> Samisa Abeysinghe : WSO2 WSF/C
> "http://wso2.org/projects/wsf/c?WSO2&nbsp;Web&nbsp;Services&nbsp;Framework/C&nbsp;-&nbsp;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
> For additional commands, e-mail: axis-c-user-help@ws.apache.org
>
>

Re: REST with Axis2/C

Posted by Samisa Abeysinghe <sa...@wso2.com>.
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>
>
>
> #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>
>
>
> 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

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 
> <ma...@wso2.com>> wrote:
>
>     Dinesh Premalal wrote:
>     > Hi Subra,
>     > "Subra A Narayanan" < aswathsn@gmail.com
>     <ma...@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;-&nbsp;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&nbsp;Web&nbsp;Services&nbsp;Framework/C&nbsp;-&nbsp;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
>     <ma...@ws.apache.org>
>     For additional commands, e-mail: axis-c-user-help@ws.apache.org
>     <ma...@ws.apache.org>
>
>


-- 
Samisa Abeysinghe : WSO2 WSF/C
"http://wso2.org/projects/wsf/c?WSO2&nbsp;Web&nbsp;Services&nbsp;Framework/C&nbsp;-&nbsp;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


Re: REST with Axis2/C

Posted by Subra A Narayanan <as...@gmail.com>.
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


#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


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?

Thanks,
Subra


On 8/23/07, Samisa Abeysinghe <sa...@wso2.com> wrote:
>
> Dinesh Premalal wrote:
> > Hi Subra,
> > "Subra A Narayanan" <as...@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;-&nbsp;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
>
>

Re: REST with Axis2/C

Posted by Subra A Narayanan <as...@gmail.com>.
Thanks Samisa.....I will start looking in to this and email you guys with
any questions that I may have.



On 8/23/07, Samisa Abeysinghe <sa...@wso2.com> wrote:
>
> Dinesh Premalal wrote:
> > Hi Subra,
> > "Subra A Narayanan" <as...@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;-&nbsp;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
>
>

Re: REST with Axis2/C

Posted by Samisa Abeysinghe <sa...@wso2.com>.
Dinesh Premalal wrote:
> Hi Subra,
> "Subra A Narayanan" <as...@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;-&nbsp;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


Re: REST with Axis2/C

Posted by Dinesh Premalal <xy...@gmail.com>.
Hi Subra,
"Subra A Narayanan" <as...@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 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
-- 
Dinesh Premalal
http://xydinesh.wordpress.com/
GPG ID : A255955C
GPG Key Finger Print : C481 E5D4 C27E DC34 9257  0229 4F44 266E A255 955C

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