User login

Proxy requests between a http servlet and a axis2 web service

Forums :

Hi everyone,

First of all, I´m new here. I didn't found any topic related to question that I'm going to make but sorry if it was already answered and in that case, please paste here the link to the related topic.

What I want to do with wso2 esb is to proxy requests (and make the necessary transformations on those requests) between a http servlet and a axis2 web service. I have a web application with some servlets that receive the needed parameters throught an ordinary http get request and I want now to expose them to the world as axis2 web services. Is it possible to implement this only with wso2 esb or do I need any external tool that transforms the soap package in normal parameters for the servlet and then do the opposite for the response? (I saw http://noodle.tigris.org/ and I think it might do this, but having 2 separate apps running is not the best solution at all...).

I saw that in the definition of an endpoint that one can set it's format to "get" and thus I could mediate a message from the web service to the servlet (without any parameters to the servlet) but the response that arrives to the web services is plain html (and I think [because I didn't tested it as intensively as that] that the request that arrived in the servlet was also a soap envelope). The inverse was not possible to test because the proxy definition doesn't have this format option. I need to be abble to parse this html and send to the web service client a soap envelope with a "operation completed" of "operation failed" information (it's as easy as that!).

Sorry for the extensive post, but I really think that this is possible to do with wso2 esb but I've got to be forgetting something!
Thanks for the attention.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Hi Joao Is it possible for

Hi Joao

Is it possible for you to draw a diagram (like in noodle) that shows your expectation and what types of messages are transmitted?

You can create proxy services with the WSO2 ESB - these are services exposed on the ESB which can accept messages, transform them, route them etc and then forward to another [real] service. In your case I assume the servlets would act as clients for your axis2 services, using the ESB as the proxy for transformations etc.

"but the response that arrives to the web services is plain html" - I do not understand what you mean here.. a diagram which shows the paths with the messages exchanged would help us to serve you better

asankha

Hi Asankha, What I want is

Hi Asankha,

What I want is this:

A client makes a request to an ordinary web service. This web service is supposed to be in wso2 esb.
Then this request is transformed to a typical browser request to a server in an http get request, where the parameters are sent to the server in the body of the http request, like when one types an address in the browser with this format: http://myserver.com?name=john&location=lisbon

Then the server response is again sent to wso2 esb which in turn transforms it again and forwards it to the client via web service.

I think that now it is more clear what I want to do. Is it possible?

Thanks for your time!

Hi Joao This time your

Hi Joao

This time your description is clear to me.. so yes, you can transform an ordinary web service call into a HTTP GET request with the WSO2 ESB - however, a GET servlet cannot accept complex types, and thus you may have some limitations, which I believe you are aware of already

As for the response, yes - you can transform an HTML response back into a SOAP response - but you will have to define the XSLT or XQuery or your own Java or scripting language transformation for it.. if your servlet outputs XHTML etc, this would be a simple task

hope this helps
asankha

Thanks Asankha! That was

Thanks Asankha!
That was really what I want to ear! :D

And yes I now there are some limitations but for what I want to do this issue will not be a problem!

For what I understood this is made with custom mediators right?

Thanks for the help.

Hi Joao Yes a custom

Hi Joao

Yes a custom mediator is one way.. how ever since your request will be SOAP / POX, you can easily use XPath expressions to grab pieces of information, and then XPath functions such as fn:concat() to concatenate these and build the GET URL, and then set this to the message To header, and just call

For the response, if you are getting an XHTML response, using XSLT/XQ would be simplest.. but if the HTML is crappy, you might have to write your own mediator to extract stuff from the raw HTML and create the payload XML you want to return

asankha

Thanks for everything!

Thanks for everything!

Hi again, All the other

Hi again,

All the other questions were already implemented and all is working as expected, thanks to Asankha.
Now I have just another question. What if, I want to inverse my client-server roles, and now my http server acts like a client and retrieves information from the application that deployed web services. Can wso2 esb publish a simple http servlet similar like the one I have in my http server and then transforms and send the request to the web services applications?

An interation in this scenarion could be something like this:

I have a button in my web app that once clicked fires a request to the server which calls the servlet in ws02 esb (with a regular http get request like the one explained in an above reply). wso2 esb in turn transforms this request in a SOAP/POX request and forwards it to a thirth application that receives web services requests. This app will respond and the response will be again transformed with wso2 and forward to the http server.

The only problem I faced to implement this solution was to publish in wso2 esb a http servlet that receives ordinary get requests. Can this be done or do I need to allways communicate with ws02 esb proxies services via SOAP?

Thanks in advance.

Hi, If you just need a way

Hi,

If you just need a way to accept the GET requests this also can be done through proxy services, you don't need another servlet to handle this. Any proxy service can accept GET requests.

Being said that, I must also say that there was an issue in the 1.7 distribution of the WSO2 ESB and it is fixed on the latest SNAPSHOT builds. If you are using the 1.7 version then this will not work, but is fixed on the trunk.

So upon receiving the GET request you may transform it to any form using XSLT and specify the format in the endpoint (soap, pox, get) so that the request to the web service that you want to invoke will be sent according to the specified format.

Is this what you want to do? I am sorry, you will need to get a SNAPSHOT build in order to get this working.

Thanks,
Ruwan Linton

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.