0

I am Ashish from Mumbai and very new to Apache Camel.

Currently I am building a route in XML which will scan the SOAP request and will redirect the request to appropriate URI.

My Soap request isn as follows:

  <service xmlns="http://ws.madcomum.comprova.com">
     <request>
        <keysValues>
           <item>
              <bytesValue
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
              <dateValue
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
              <doubleValue
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
              <key>validatesOriginIntegrity</key>
              <longValue
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
              <stringValue>z4x/FOOR+EPQ0vD9+itPSCBeNR4=</stringValue>
           </item>
        </keysValues>
        <actionId>1</actionId>
        <clientId>ARGO</clientId>
     </request>
  </service>

From this SOAP envelope, I want to parse out value of actionId tag using Camel Route. If actionId has value of 1 then route must be redirected to callService else to another service.

I developed logic of route as folows:

<route>
        <from uri="cxf:bean:comprovaWS?dataFormat=MESSAGE" />   

            <when>
                <xpath>//actionId=1</xpath>
                <to uri="log:input" />

                <to ref="callService" />
                <to uri="log:output" />
            </when>

            <otherwise>
                <to uri="log:input" />
                <to ref="otherService"/>
                <to uri="log:output" />
            </otherwise>

        </choice>
    </route>

But this logic is not working. Is there any error in my route?

Though I am Java guy, I don't want to use Java here. I want to rely on Camel itself.

Please help me ASAP.

Regards,

Ashish

1 Answer 1

0

When you use xpath then 95% of the times when people have trouble its often due to namespaces. Your SOAP message is defined using a namespace - "http://ws.madcomum.comprova.com". The xpath expression must use this namespace to make it work.

See more details at: http://camel.apache.org/xpath, there is an example at the section Using XML configuration

Also as you use CXF in MESSAGE mode, then read about stream caching as the message is stream based: http://camel.apache.org/stream-caching.html

3
  • Dear Claus, Thanks for your reply!!! I checked my XPATH using a Java XPATH application where it works without namespaces. Is there any change needed in route logic except namespaces? Is my route logic correct? Kindly awaiting for your reply. Dec 29, 2012 at 9:46
  • In Java the XPathExpression must have namespaces. Its required by the XPath that Camel uses from the JDK. There is a way of using local-name() style (can't remember its exact syntax, so google / check more in stackoverflow) Dec 29, 2012 at 11:57
  • Thanks for your advice... I have added namespaoces in <camelContext> tag and enabled. streamCache in <route> tag. It's now working... Thanks again... Jan 2, 2013 at 15:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.