Would XPath or XQuery work for you? Something like

<from uri="xxx"/>
<setHeader headerName="myHeader">
  <xpath>/ns:order/ns:id/text()</xpath>
</setHeader>
<to uri="xxx"/>

[1] http://camel.apache.org/xpath.html
[2] http://camel.apache.org/xquery.html

Best,
Christian

On Tue, Oct 2, 2012 at 7:51 AM, suralk <[email protected]> wrote:

> Hi All,
> I have a route that gets some data from a remote we service and writes to a
> file:
>  from("file:src/data?noop=true")
>
> .to("cxf://
> http://www.webservicex.net/stockquote.asmx?wsdlURL=src/main/resources/META-INF/stockquote.wsdl&serviceName={http://www.webserviceX.NET/}StockQuote&portName={http://www.webserviceX.NET/}StockQuoteSoap&dataFormat=MESSAGE
> ")
>  .to("file:src/dataout?fileName=t.xml");
>
> This works fine, but I want to access only some of the elements in this
> SOAP
> message. I tried a processor like the one shown below, but it is returning
> null. Can someone point out what is wrong in this route?
> I am assuming that I should not cast the SoapBody to Cxfpayload because the
> dataformat at the endpoint is MESSAGE. However, I do not know an
> alternative.
>
> .process(new Processor() {
>                     @SuppressWarnings("unchecked")
>                     public void process(final Exchange exchange) throws
> Exception {
>                         CxfPayload<SoapBody> requestPayload =
> exchange.getIn().getBody(CxfPayload.class);
>                         List<Source> inElements =
> requestPayload.getBodySources();
>                         List<Source> outElements = new ArrayList<Source>();
>                         for(Source element:inElements)
>                         {
>                                 Element in = new
> XmlConverter().toDOMElement(element);
>                                 System.out.println("++++++++++++++" +
> in.getNodeValue());// prints null
>                         }
>
>                     }
>                 })
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/how-to-access-a-SOAP-message-part-inside-a-route-tp5720345.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



--

Reply via email to