Want to build a route which will check contents of Soap request and pass the request to appropriate URI

StackOverflow https://stackoverflow.com/questions/14073234

Question

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

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top