recipientList with POST and request body

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

recipientList with POST and request body

Zemin Hu
Hi,
I need to send request to a dynamically constructed URL list which provides RESTful web services. So my simplest need is to send POST requests with fixed JSON body, later I may need to construct different JSON body for each URL in the list as well, and since it's RESTful service, DELETE/PUT are also possible. how should I do it?

This is standard recipientList pattern from document:
<route>
  <from uri="direct:a" />
  <recipientList delimiter=",">
    <header>myHeader</header>
  </recipientList>
</route>

Should I do:
<route>
  <from uri="servlet:///sendToRecipients" />
  <setHeader headerName="WEB_SERVICE_URLS">
        <constant>construct my urls here</constant>
  </setHeader>
  <setHeader headerName="CamelHttpMethod">
        <constant>POST</constant>
  </setHeader>
  <setHeader headerName="Content-Type">
    <constant>application/json</constant>
  </setHeader>
  <setBody>
    <constant>{"name":"fixed text"}</constant>
  </setBody>
  <recipientList delimiter=",">
    <header>WEB_SERVICE_URLS</header>
  </recipientList>
</route>

Thanks for advice.
Reply | Threaded
Open this post in threaded view
|

Re: recipientList with POST and request body

Willem.Jiang
Administrator
Hi,

I'm afraid the recipientList will not meet your needs at this time.
As you need to change the Http method and request JSON body dynamically, current recipientList just supports to change the Camel Endpoint URI dynamically.

So I suggest you to leverage the ProducerTemplate[1] in your customer bean, so you can get full control of message header , body and the Camel Endpoint URI at same time.

[1]https://camel.apache.org/producertemplate.html 

--  
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem





On Wednesday, January 9, 2013 at 2:48 AM, Zemin Hu wrote:

> Hi,  
> I need to send request to a dynamically constructed URL list which provides
> RESTful web services. So my simplest need is to send POST requests with
> fixed JSON body, later I may need to construct different JSON body for each
> URL in the list as well, and since it's RESTful service, DELETE/PUT are also
> possible. how should I do it?
>  
> This is standard recipientList pattern from document:
> <route>
> <from uri="direct:a" />
> <recipientList delimiter=",">
> <header>myHeader</header>
> </recipientList>
> </route>
>  
> Should I do:
> <route>
> <from uri="servlet:///sendToRecipients" />
> <setHeader headerName="WEB_SERVICE_URLS">
> <constant>construct my urls here</constant>
> </setHeader>
> <setHeader headerName="CamelHttpMethod">
> <constant>POST</constant>
> </setHeader>
> <setHeader headerName="Content-Type">
> <constant>application/json</constant>
> </setHeader>
> <setBody>
> <constant>{"name":"fixed text"}</constant>
> </setBody>
> <recipientList delimiter=",">
> <header>WEB_SERVICE_URLS</header>
> </recipientList>
> </route>
>  
> Thanks for advice.
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/recipientList-with-POST-and-request-body-tp5725142.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).



Reply | Threaded
Open this post in threaded view
|

Re: recipientList with POST and request body

Zemin Hu
Willem,
Thanks, I read some of your posts in the past, they were very helpful. I appreciate your advice.
My currently situation is: I used beans for complicated business logic, to send different requests to different resources and to aggregate the results in the past. But now our company is moving to cloud computing environment, our platform (modified/enhanced camel environment) moved to cloud environment. So Bean implementation is strongly discouraged since (auto/versioned) bean deployment could be very complicated in the environment.

I am moving to write all the code in groovy within the route instead of bean as best practice in our group. ProducerTemplate could be good solution if bean implementation is allowed. I tried a simple test by sending single request in groovy(I need to aggregate the final response as part of requirement, also I used setBody tag to cheat route to send request which may not be best practice):
<setBody>
        <groovy>
                import org.apache.camel.ProducerTemplate
                import org.apache.camel.impl.DefaultProducerTemplate
               
                def template = context.createProducerTemplate()
                def endpoint = "myendpoint"
                def body = ${header.REST_REQUEST_BODY}
                def headers = ["Content-Type":"application/json", CamelHttpMethod:"POST"]
                def response = template.requestBodyAndHeader(endpoint, body, headers, java.lang.String.class)
                return response
        </groovy>
</setBody>
I got expected exception: context is missing since context is NOT default build-in variable. How do I get context in "simple" DSL, or how do I get a producerTemplate without using context?
If not, is there other solutions/patterns that I can use for this situation without using beans?
I am looking at [splitter][broadcast] pattern, but have not found way to resolve it. Maybe this is too demanding for Camel without bean: dynamic URI list, dynamic HTTP method(optional), dynamic request body(optional), and aggregate all responses. I am using Spring DSL plus groovy only, java DSL is not allowed.
Reply | Threaded
Open this post in threaded view
|

Re: recipientList with POST and request body

Zemin Hu
In reply to this post by Willem.Jiang
I tried producerTemplate for bean approach (in groovy) too. I got exception when I tried to POST to an HTTP endpoint:
        def template = context.createProducerTemplate()

        def endpointUri = headers.END_POINT
        def xheaders = ["Content-Type":"application/json", "CamelHttpMethod":"POST"]
        def xbody ='''{"id":["48792683442"],"index":"0"}'''

        def response = template.requestBodyAndHeaders(endpointUri, xbody, xheaders, java.lang.String.class)
        exchange.in.setBody(response)
the exception is:

org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[Message: {"id":["48792683442"],"index":"0"}]
        at org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1237)[camel-core-2.9.1.jar:2.9.1]
        at org.apache.camel.util.ExchangeHelper.extractResultBody(ExchangeHelper.java:509)[camel-core-2.9.1.jar:2.9.1]
        at org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:442)[camel-core-2.9.1.jar:2.9.1]
        at org.apache.camel.impl.DefaultProducerTemplate.sendBodyAndHeaders(DefaultProducerTemplate.java:247)[camel-core-2.9.1.jar:2.9.1]
        at org.apache.camel.impl.DefaultProducerTemplate.requestBodyAndHeaders(DefaultProducerTemplate.java:296)[camel-core-2.9.1.jar:2.9.1]
        at org.apache.camel.impl.DefaultProducerTemplate.requestBodyAndHeaders(DefaultProducerTemplate.java:292)[camel-core-2.9.1.jar:2.9.1]
        at org.apache.camel.impl.DefaultProducerTemplate.requestBodyAndHeaders(DefaultProducerTemplate.java:329)[camel-core-2.9.1.jar:2.9.1]
        at org.apache.camel.ProducerTemplate$requestBodyAndHeaders.call(Unknown Source)

I changed to use template.sendBodyAndHeaders(endpointUri, xbody, xheaders) in case the result is causing problem, I got same exception.
Can anybody help to use producerTemplate to POST/PUT/DELETE HTTP request? It should not be limited to do only GET, isn't it? no document says anything about setting HTTP methods for producerTemplate. It would be tedious to write my own httpClient based code.
Reply | Threaded
Open this post in threaded view
|

Re: recipientList with POST and request body

Willem.Jiang
Administrator
In reply to this post by Zemin Hu
I just checked the camel-script code, it will bind the camel context within the script context.
But it should be more easy to write a custom bean[1] and inject the camel context to it, then you can get full control of it.  


[1]http://camel.apache.org/bean.html
--  
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem





On Thursday, January 10, 2013 at 1:00 AM, Zemin Hu wrote:

> Willem,
> Thanks, I read some of your posts in the past, they were very helpful. I
> appreciate your advice.
> My currently situation is: I used beans for complicated business logic, to
> send different requests to different resources and to aggregate the results
> in the past. But now our company is moving to cloud computing environment,
> our platform (modified/enhanced camel environment) moved to cloud
> environment. So Bean implementation is strongly discouraged since
> (auto/versioned) bean deployment could be very complicated in the
> environment.
>  
> I am moving to write all the code in groovy within the route instead of bean
> as best practice in our group. ProducerTemplate could be good solution if
> bean implementation is allowed. I tried a simple test by sending single
> request in groovy(I need to aggregate the final response as part of
> requirement, also I used setBody tag to cheat route to send request which
> may not be best practice):
> <setBody>
> <groovy>
> import org.apache.camel.ProducerTemplate
> import org.apache.camel.impl.DefaultProducerTemplate
>  
> def template = context.createProducerTemplate()
> def endpoint = "myendpoint"
> def body = ${header.REST_REQUEST_BODY}
> def headers = ["Content-Type":"application/json", CamelHttpMethod:"POST"]
> def response = template.requestBodyAndHeader(endpoint, body, headers,
> java.lang.String.class)
> return response
> </groovy>
> </setBody>
> I got expected exception: context is missing since context is NOT default
> build-in variable. How do I get context in "simple" DSL, or how do I get a
> producerTemplate without using context?
> If not, is there other solutions/patterns that I can use for this situation
> without using beans?
> I am looking at [splitter][broadcast] pattern, but have not found way to
> resolve it. Maybe this is too demanding for Camel without bean: dynamic URI
> list, dynamic HTTP method(optional), dynamic request body(optional), and
> aggregate all responses. I am using Spring DSL plus groovy only, java DSL is
> not allowed.
>  
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/recipientList-with-POST-and-request-body-tp5725142p5725192.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).



Reply | Threaded
Open this post in threaded view
|

Re: recipientList with POST and request body

Willem.Jiang
Administrator
In reply to this post by Zemin Hu
Oh, you need to start the template before using it to send the request.


--  
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem





On Thursday, January 10, 2013 at 4:42 AM, Zemin Hu wrote:

> I tried producerTemplate for bean approach (in groovy) too. I got exception
> when I tried to POST to an HTTP endpoint:
> def template = context.createProducerTemplate()
>  
> def endpointUri = headers.END_POINT
> def xheaders = ["Content-Type":"application/json",
> "CamelHttpMethod":"POST"]
> def xbody ='''{"id":["48792683442"],"index":"0"}'''
>  
> def response = template.requestBodyAndHeaders(endpointUri, xbody, xheaders,
> java.lang.String.class)
> exchange.in.setBody(response)
> the exception is:
>  
> org.apache.camel.CamelExecutionException: Exception occurred during
> execution on the exchange: Exchange[Message:
> {"id":["48792683442"],"index":"0"}]
> at
> org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1237)[camel-core-2.9.1.jar:2.9.1]
> at
> org.apache.camel.util.ExchangeHelper.extractResultBody(ExchangeHelper.java:509)[camel-core-2.9.1.jar:2.9.1]
> at
> org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:442)[camel-core-2.9.1.jar:2.9.1]
> at
> org.apache.camel.impl.DefaultProducerTemplate.sendBodyAndHeaders(DefaultProducerTemplate.java:247)[camel-core-2.9.1.jar:2.9.1]
> at
> org.apache.camel.impl.DefaultProducerTemplate.requestBodyAndHeaders(DefaultProducerTemplate.java:296)[camel-core-2.9.1.jar:2.9.1]
> at
> org.apache.camel.impl.DefaultProducerTemplate.requestBodyAndHeaders(DefaultProducerTemplate.java:292)[camel-core-2.9.1.jar:2.9.1]
> at
> org.apache.camel.impl.DefaultProducerTemplate.requestBodyAndHeaders(DefaultProducerTemplate.java:329)[camel-core-2.9.1.jar:2.9.1]
> at org.apache.camel.ProducerTemplate$requestBodyAndHeaders.call(Unknown
> Source)
>  
> I changed to use template.sendBodyAndHeaders(endpointUri, xbody, xheaders)
> in case the result is causing problem, I got same exception.
> Can anybody help to use producerTemplate to POST/PUT/DELETE HTTP request? It
> should not be limited to do only GET, isn't it? no document says anything
> about setting HTTP methods for producerTemplate. It would be tedious to
> write my own httpClient based code.
>  
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/recipientList-with-POST-and-request-body-tp5725142p5725201.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).



Reply | Threaded
Open this post in threaded view
|

Re: recipientList with POST and request body

Zemin Hu
I added a line:
template.start()
before sending request, it did not help, got same exception. I changed to context.start() it did not work either.
The code is within bean implementation, so context is build-in variable, and started already, why do I need to start it again? From other example code, the pattern to use it should be simple as 2 lines:

def template = context.createProducerTemplate()
def response = template.requestBodyAndHeaders(endpointUri, xbody, xheaders, java.lang.String.class)

Can someone post working code to use producerTemplate to POST request?
Reply | Threaded
Open this post in threaded view
|

Re: recipientList with POST and request body

Zemin Hu
In reply to this post by Willem.Jiang
Can you be more specific how to reference the context the script since I encountered exception regarding context is not found?
Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: recipientList with POST and request body

Willem.Jiang
Administrator
In reply to this post by Zemin Hu
You just need to start the ProducerTemplate, you don't need to start the camel context as it is already started.
Can you check the camel log to see if there is any information shows what's the cause exception?  


--  
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem





On Thursday, January 10, 2013 at 10:43 PM, Zemin Hu wrote:

> I added a line:
> template.start()
> before sending request, it did not help, got same exception. I changed to
> context.start() it did not work either.
> The code is within bean implementation, so context is build-in variable, and
> started already, why do I need to start it again? From other example code,
> the pattern to use it should be simple as 2 lines:
>  
> def template = context.createProducerTemplate()  
> def response = template.requestBodyAndHeaders(endpointUri, xbody, xheaders,
> java.lang.String.class)  
>  
> Can someone post working code to use producerTemplate to POST request?
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/recipientList-with-POST-and-request-body-tp5725142p5725283.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).



Reply | Threaded
Open this post in threaded view
|

Re: recipientList with POST and request body

Zemin Hu
I posted the exception before, let me copy the exception again:
the exception is:

org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[Message: {"id":["48792683442"],"index":"0"}]
        at org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1237)[camel-core-2.9.1.jar:2.9.1]
        at org.apache.camel.util.ExchangeHelper.extractResultBody(ExchangeHelper.java:509)[camel-core-2.9.1.jar:2.9.1]
        at org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:442)[camel-core-2.9.1.jar:2.9.1]
        at org.apache.camel.impl.DefaultProducerTemplate.sendBodyAndHeaders(DefaultProducerTemplate.java:247)[camel-core-2.9.1.jar:2.9.1]
        at org.apache.camel.impl.DefaultProducerTemplate.requestBodyAndHeaders(DefaultProducerTemplate.java:296)[camel-core-2.9.1.jar:2.9.1]
        at org.apache.camel.impl.DefaultProducerTemplate.requestBodyAndHeaders(DefaultProducerTemplate.java:292)[camel-core-2.9.1.jar:2.9.1]
        at org.apache.camel.impl.DefaultProducerTemplate.requestBodyAndHeaders(DefaultProducerTemplate.java:329)[camel-core-2.9.1.jar:2.9.1]
        at org.apache.camel.ProducerTemplate$requestBodyAndHeaders.call(Unknown Source)
Reply | Threaded
Open this post in threaded view
|

Re: recipientList with POST and request body

Willem.Jiang
Administrator
In reply to this post by Zemin Hu
I just recheck the code, the camel context is bind with the variable name of "camelContext".


--  
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem


Sent with Sparrow (http://www.sparrowmailapp.com/?sig)


On Thursday, January 10, 2013 at 10:47 PM, Zemin Hu wrote:

> Can you be more specific how to reference the context the script since I
> encountered exception regarding context is not found?
> Thanks.
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/recipientList-with-POST-and-request-body-tp5725142p5725284.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).



Reply | Threaded
Open this post in threaded view
|

Re: recipientList with POST and request body

Willem.Jiang
Administrator
In reply to this post by Zemin Hu
You should be able to get the cause Exception from the log. That is what I'm asking for.
Can you check the log below the exception that you just showed?


--  
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem





On Thursday, January 10, 2013 at 11:01 PM, Zemin Hu wrote:

> I posted the exception before, let me copy the exception again:
> the exception is:
>  
> org.apache.camel.CamelExecutionException: Exception occurred during
> execution on the exchange: Exchange[Message:
> {"id":["48792683442"],"index":"0"}]
> at
> org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1237)[camel-core-2.9.1.jar:2.9.1]
> at
> org.apache.camel.util.ExchangeHelper.extractResultBody(ExchangeHelper.java:509)[camel-core-2.9.1.jar:2.9.1]
> at
> org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:442)[camel-core-2.9.1.jar:2.9.1]
> at
> org.apache.camel.impl.DefaultProducerTemplate.sendBodyAndHeaders(DefaultProducerTemplate.java:247)[camel-core-2.9.1.jar:2.9.1]
> at
> org.apache.camel.impl.DefaultProducerTemplate.requestBodyAndHeaders(DefaultProducerTemplate.java:296)[camel-core-2.9.1.jar:2.9.1]
> at
> org.apache.camel.impl.DefaultProducerTemplate.requestBodyAndHeaders(DefaultProducerTemplate.java:292)[camel-core-2.9.1.jar:2.9.1]
> at
> org.apache.camel.impl.DefaultProducerTemplate.requestBodyAndHeaders(DefaultProducerTemplate.java:329)[camel-core-2.9.1.jar:2.9.1]
> at
> org.apache.camel.ProducerTemplate$requestBodyAndHeaders.call(Unknown Source)  
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/recipientList-with-POST-and-request-body-tp5725142p5725288.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).



Reply | Threaded
Open this post in threaded view
|

Re: recipientList with POST and request body

Zemin Hu
This post was updated on .
Thanks. The camelContext is not causing exception anymore.
The cause of the exception is:
Caused by: org.apache.camel.component.http.HttpOperationFailedException: HTTP operation failed invoking https://.... with statusCode: 302, redirectLocation: https://...

        at org.apache.camel.component.http.HttpProducer.populateHttpOperationFailedException(HttpProducer.java:222)

        at org.apache.camel.component.http.HttpProducer.process(HttpProducer.java:157)

        at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)

        at org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)

        at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)

        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99)

        at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:86)

        at org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:63)

        at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:352)

        at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:324)

        at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:223)

        at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:324)

        at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:186)

        at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:115)

        at org.apache.camel.impl.DefaultProducerTemplate.sendBodyAndHeaders(DefaultProducerTemplate.java:238)

        ... 107 more
Reply | Threaded
Open this post in threaded view
|

Re: recipientList with POST and request body

Willem.Jiang
Administrator
Hi,  

It looks like the URL you want to access need you to login first.
Can you double check it?


--  
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem





On Thursday, January 10, 2013 at 11:26 PM, Zemin Hu wrote:

> Thanks. The camelContext is not causing exception anymore.
> The cause of the exception is:
> Caused by: org.apache.camel.component.http.HttpOperationFailedException:
> HTTP operation failed invoking
> https://locker.att.net/service/content/1/playlists/158040465976 with
> statusCode: 302, redirectLocation:
> https://cprodctnxsf.att.net/commonLogin/igate_edam/controller.do?TAM_OP=login&USERNAME=unauthenticated&ERROR_CODE=0x00000000&ERROR_TEXT=HPDBA0521I%20%20%20Successful%20completion&METHOD=POST&URL=%2Fservice%2Fcontent%2F1%2Fplaylists%2F158040465976&REFERER=&HOSTNAME=locker.att.net&AUTHNLEVEL=&FAILREASON=&PROTOCOL=https&OLDSESSION=
>  
> at
> org.apache.camel.component.http.HttpProducer.populateHttpOperationFailedException(HttpProducer.java:222)
>  
> at
> org.apache.camel.component.http.HttpProducer.process(HttpProducer.java:157)
>  
> at
> org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
>  
> at
> org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)
>  
> at
> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)
>  
> at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99)
>  
> at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:86)
>  
> at
> org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:63)
>  
> at
> org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:352)
>  
> at
> org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:324)
>  
> at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:223)
>  
> at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:324)
>  
> at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:186)
>  
> at
> org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:115)
>  
> at
> org.apache.camel.impl.DefaultProducerTemplate.sendBodyAndHeaders(DefaultProducerTemplate.java:238)
>  
> ... 107 more
>  
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/recipientList-with-POST-and-request-body-tp5725142p5725296.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).



Reply | Threaded
Open this post in threaded view
|

Re: recipientList with POST and request body

Zemin Hu
This post was updated on .
I think I understand now why I can't do this with producerTemplate:
yes, there is intensive security checks for our web service site, at this point to use producerTemplate I already logged in and got session in previous steps in the same route, the problem is that the security token with session information is not passed to this site correctly since producerTemplate is passing simple body and headers without security tokens, that's why it failed. Do you have way to take tokens with the template?
For security reason, I removed some site information from previous post.