Question

I am working on parsing the request. I developed route in Java for parsing incoming request.

I am using Camel 2.9 with FuseESB 7.0.1.0.84.

I used simple(“{body}”).getText() to fetch incoming request as per Camel Manual

So I am checking the incoming request by using the code as:

if (xmlStringToParse == null || xmlStringToParse.equals("") || xmlStringToParse.equals("${body}")) {

            parsedXMLPath = "<error>Incoming request is as folows:"
                    + "\nValue of xmlStringToParse: " + xmlStringToParse
                    + "\n xmlStringToParse is empty: " + (xmlStringToParse.equals(""))
                   + "\n xmlStringToParse equals ${body}: " + (xmlStringToParse.equals("${body}"))
                    + "\nAgain checking incoming request:\n" + xmlStringToParse
                    + "</error>";
        }

Where xmlStringToParse = simple(“${body}”).getText()

The strange outcoming observed:

Value of xmlStringToParse is changed in just one line from soap request to "". Also “xmlStringToParse equals ${body} “ is printed as “xmlStringToParse equals” without printing ${body}. ${body} is not printed in logs.

You can find the log output follows:

   <error>
    Value of xmlStringToParse: <somesoapRequest>
    xmlStringToParse is empty: false
   xmlStringToParse equals : true
  Again checking incoming request:
 </error>

Can anyone tell me how to solve this issue and the reason for this strange behavior?

Was it helpful?

Solution

I used simple(“{body}”).getText() to fetch incoming request as per Camel Manual

Where did you see that? Do you have a link?

You should get the message body in another way than what you do, such as

String body = exchange.getIn().getBody(String.class);

Or if you use bean parameter binding, you can bind the message body and just declare the parameter to be of String type

public void foo(String body) {
   ...
}

See more details at the Camel docs such at: http://camel.apache.org/bean-binding.html

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