You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Michael Prieß <ma...@googlemail.com> on 2011/04/29 09:23:21 UTC

HTTP request

Hello,

I like to request some data from a soap service and after receiving
the response I like to convert the received data in another route. But
I not understand how to use the http component to send a http request
to the server. Is this the right way to do that?

    <route id="Webservice" autoStartup="true">
      <from uri="direct:requestWebservice" />
      <setBody><constant><![CDATA[<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body />
</soap:Envelope>]]></constant></setBody>
      <setHeader headerName="Content-Type">
        <constant>text/xml;</constant>
      </setHeader>
      <setHeader headerName="CamelHttpMethod">
        <constant>POST</constant>
      </setHeader>
      <to uri="http://myserver.com?authUsername=myuser&amp;authPassword=myPassword&amp;authMethod=Basic"
/>
      <to uri="file://d:/opt/output" />
    </route>

Regards,

Michael

Re: HTTP request

Posted by Christian Schneider <ch...@sopera.com>.
I would even propose to use:
template = camelContext.createProducerTemplate();
template.sendBody("direct:requestWebservice",
"<?xml version=\"1.0\" encoding=\"utf-8\"?> ....");

Christian



Am 29.04.2011 10:38, schrieb Willem Jiang:
> Hi,
>
> You can put the request into the message body instead of using setBody
> DSL. Here is the code snippet.
>
>          template.send("direct:requestWebservice", new Processor() {
>
>               public void process(Exchange exchange) throws Exception {
>                   exchange.getIn().setBody("<?xml version=\"1.0\"
> encoding=\"utf-8\"?>  ....");
>               }
>
>           });
> On 4/29/11 3:23 PM, Michael Prieß wrote:
>> Hello,
>>
>> I like to request some data from a soap service and after receiving
>> the response I like to convert the received data in another route. But
>> I not understand how to use the http component to send a http request
>> to the server. Is this the right way to do that?
>>
>>       <route id="Webservice" autoStartup="true">
>>         <from uri="direct:requestWebservice" />
>>         <setBody><constant><![CDATA[<?xml version="1.0" encoding="utf-8"?>
>> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>> xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
>>     <soap:Body />
>> </soap:Envelope>]]></constant></setBody>
>>         <setHeader headerName="Content-Type">
>>           <constant>text/xml;</constant>
>>         </setHeader>
>>         <setHeader headerName="CamelHttpMethod">
>>           <constant>POST</constant>
>>         </setHeader>
>>         <to uri="http://myserver.com?authUsername=myuser&amp;authPassword=myPassword&amp;authMethod=Basic"
>> />
>>         <to uri="file://d:/opt/output" />
>>       </route>
>>
>> Regards,
>>
>> Michael
>>
>


-- 
Christian Schneider
CXF and Camel Architect
SOPERA - The Application Integration Division of Talend
http://www.talend.com


Re: HTTP request

Posted by Willem Jiang <wi...@gmail.com>.
Hi,

You can put the request into the message body instead of using setBody 
DSL. Here is the code snippet.

        template.send("direct:requestWebservice", new Processor() {

             public void process(Exchange exchange) throws Exception {
                 exchange.getIn().setBody("<?xml version=\"1.0\" 
encoding=\"utf-8\"?> ....");
             }

         });
On 4/29/11 3:23 PM, Michael Prieß wrote:
> Hello,
>
> I like to request some data from a soap service and after receiving
> the response I like to convert the received data in another route. But
> I not understand how to use the http component to send a http request
> to the server. Is this the right way to do that?
>
>      <route id="Webservice" autoStartup="true">
>        <from uri="direct:requestWebservice" />
>        <setBody><constant><![CDATA[<?xml version="1.0" encoding="utf-8"?>
> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
>    <soap:Body />
> </soap:Envelope>]]></constant></setBody>
>        <setHeader headerName="Content-Type">
>          <constant>text/xml;</constant>
>        </setHeader>
>        <setHeader headerName="CamelHttpMethod">
>          <constant>POST</constant>
>        </setHeader>
>        <to uri="http://myserver.com?authUsername=myuser&amp;authPassword=myPassword&amp;authMethod=Basic"
> />
>        <to uri="file://d:/opt/output" />
>      </route>
>
> Regards,
>
> Michael
>


-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
          http://jnn.javaeye.com (Chinese)
Twitter: willemjiang

Connect at CamelOne May 24-26
The Open Source Integration Conference
http://camelone.com