Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HTTP Request froward to other application

 
Tejas Shah
Greenhorn
Posts: 23
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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....
 
Sunny Bhandari
Ranch Hand
Posts: 448
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65228
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, you need to use a different request.
 
Tejas Shah
Greenhorn
Posts: 23
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How?

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?
 
Deriko Prata
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello there,

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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic