Is there any way, i can forward the request to some other application running on some other server and get the response back?
I tried to use Apache HTTPClient API, but it is not letting me send the original request, and constructs a new request.
Basically, i want to have a HTTP Proxy, but i want to perform some operations on incoming request and possibly also on the response, so i'm not using socket programming.
If there isn't a way to forward the request, can i construct the same request and send it?
Thanks in advanced....
I can visualize you want the behavior where I book the train tickets and I am forwarded to payment gateway and after payment is processed I am shown the seat confirmation page on the railway website...right?
Any other way to send a duplicate request?
I may have SOAP requests as well as HTTPRequest,
So it is not working with Apache HTTPClient API. It can construct new requests with parameters or attributes, but how can i attache SOAP envelope to this?
Http is a protrocol that limits the communication between only two ends(one cliente and one server), thus you can forward the request only to resources located in that server. If you need to communicate with another server , you need another conection and another request. What you are trying to accomplish, is create a pipeline of comunication between your servers (see Pipes and Filters -POSA). You will need to use one application as a httpProxy (You can implement this using a Front Controller and App.Controller or an an Intercepting Filter-JEE Core Patterns) in front of target server, handle the request, extract the http message payload, create another request, copy old payload to the new request, forward the new request to the target server(you can use java.net). Also you can use SAAJ with that strategy to handle soap messages. I'm not very familiar with Apache HttpClient API, but i'm pretty sure it's an abstraction layer for what i described here.