You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by "Brown, Ben" <be...@bluefingroup.co.uk> on 2009/07/27 17:02:11 UTC

Multiple HTTP Chained Requests

Hi All

Due to a specification change I need to rewrite a HTTP endpoint from a
simple POST and response to a more complex interaction.  I now need to
do a HTTP post, read a location from a response header and then do a GET
to that location (all of this being out of our control).  Actually the
response is a HTTP 302 redirect.

There are a couple of ways I have thought of achieving this:

1) Use the Servicemix HTTP component to do the initial post (as I need
to use a SSL certificate), and read back the response, then use camel to
do the second GET.  The issue I have with this approach is that the
response from the POST is HTML not XML, and therefore an exception is
thrown when the response is received in the Servicemix HTTP component.

2) Use Camel to do the initial post and then read the headers to
determine where the second post should be made.  The issue I have with
this approach is that using Servicemix 3.3 (and hence camel 1.6) I am
unable to prevent an exception from being thrown when a 302 response
code is returned from the initial POST (Camel 2.0 seems to provide this
feature...).

Does anyone have any suggestions as to how I can approach a solution?
Is there anything available that will help to automatically process this
HTTP 302 redirection?

Please let me know if you require any further information.

Thanks

Ben Brown 

This email and any files or information it contains are confidential and may be privileged.  It is for the intended addressee(s) only.  The unauthorised use, disclosure or copying of this email or any information it contains, is prohibited and could, in certain circumstances be a criminal offence. If you are not the intended recipient you should not disseminate or copy this email.  Please notify the sender immediately and delete this message from your system. 

Please note that any opinions presented in this email are solely those of the author (or those of a third party whose statement is forwarded) and do not necessarily represent those of any company within the Bluefin Group Limited group of companies.

Email transmission cannot be guaranteed to be secure or error free as information could be intercepted, corrupted, lost, destroyed, late in arriving or incomplete as a result of the transmission process.  The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of email transmission.

WARNING: Computer viruses can be transmitted by email. The recipient should check this email and any attachments for the presence of viruses.  The Bluefin Group Limited group of companies accepts no liability for any damage caused by any virus transmitted by this email.

Re: Multiple HTTP Chained Requests

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Ben,

If the initial post can be a little bit complex (SSL, etc), I think it's 
better to use the HTTP component. In the HTTP component, you can define 
your own marshaler. In this marshaler, you can extract the location from 
the headers. Once you have the location, you can target another HTTP 
endpoint (using another marshaler) to make the GET on the location 
extracted by the first endpoint. So to summarize:
1/ HTTP Endpoint 1: make the post, uses a custom marshaler to extract 
the location from the headers and put it in the message targeted to the 
Endpoint 2
2/ HTTP Endpoint 2: get the location extracted by Endpoint 1, use a 
custom marshaler to make a GET on this location. The out of this 
endpoint can be routing on the service of your choice.

Regards
JB

Brown, Ben wrote:
> Hi All
> 
> Due to a specification change I need to rewrite a HTTP endpoint from a
> simple POST and response to a more complex interaction.  I now need to
> do a HTTP post, read a location from a response header and then do a GET
> to that location (all of this being out of our control).  Actually the
> response is a HTTP 302 redirect.
> 
> There are a couple of ways I have thought of achieving this:
> 
> 1) Use the Servicemix HTTP component to do the initial post (as I need
> to use a SSL certificate), and read back the response, then use camel to
> do the second GET.  The issue I have with this approach is that the
> response from the POST is HTML not XML, and therefore an exception is
> thrown when the response is received in the Servicemix HTTP component.
> 
> 2) Use Camel to do the initial post and then read the headers to
> determine where the second post should be made.  The issue I have with
> this approach is that using Servicemix 3.3 (and hence camel 1.6) I am
> unable to prevent an exception from being thrown when a 302 response
> code is returned from the initial POST (Camel 2.0 seems to provide this
> feature...).
> 
> Does anyone have any suggestions as to how I can approach a solution?
> Is there anything available that will help to automatically process this
> HTTP 302 redirection?
> 
> Please let me know if you require any further information.
> 
> Thanks
> 
> Ben Brown 
> 
> This email and any files or information it contains are confidential and may be privileged.  It is for the intended addressee(s) only.  The unauthorised use, disclosure or copying of this email or any information it contains, is prohibited and could, in certain circumstances be a criminal offence. If you are not the intended recipient you should not disseminate or copy this email.  Please notify the sender immediately and delete this message from your system. 
> 
> Please note that any opinions presented in this email are solely those of the author (or those of a third party whose statement is forwarded) and do not necessarily represent those of any company within the Bluefin Group Limited group of companies.
> 
> Email transmission cannot be guaranteed to be secure or error free as information could be intercepted, corrupted, lost, destroyed, late in arriving or incomplete as a result of the transmission process.  The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of email transmission.
> 
> WARNING: Computer viruses can be transmitted by email. The recipient should check this email and any attachments for the presence of viruses.  The Bluefin Group Limited group of companies accepts no liability for any damage caused by any virus transmitted by this email.