Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
hvanderheyden
Partner - Contributor
Partner - Contributor

[resolved] Problem with Simple

Hello,
I'have somes trouble with Simple code.
We're using AMQ to transit XML message to process:
<?xml version="1.0"?>
<response>
<sender>CP2</sender>
<method>createThreshold</method>
<userId>monmail@mondomaine.fr</userId>
<threshold>
<oldId>SA01</oldId>
<startDate>1996-01-01</startDate>
<endDate>1996-12-31</endDate>
<amount>78,206.35</amount>
</threshold>
</response>

I would like create a simple expression to process "method" field when the value is 'createThreshold'. So i've written the following expression
"${body.response.method} == 'createThreshold'"

At the route execution, i've that stacktrace in log:
Démarrage du job QueueRouter a 11:22 20/06/2014.
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Fou


To see the whole post, download it here
Labels (4)
1 Solution

Accepted Solutions
Anonymous
Not applicable

Hi Hervé,
Simple doesn't understand XML - that syntax works when the body is a Java Bean instead of just a String of XML. The most direct way to do this with your XML is to use XPath rather than Simple. I'll give you a couple of options.
Option 1: Just use XPath
For your predicates on your router paths, you can select the XPath language. Select it and use an XPath expression something like this:
"/response/method"
and
"/response/method"

Option 2: Pull value with XPath, evaluate with Simple
Step 1: Add a cSetHeader component after your JMS listener and add a property to be set
- Choose the XPath Language
- Name the new header property (for instance, Response_Method)
- Set the expression to: "/response/method/text()"
Step 2: Evaluate with Simple
- In your Router predicate choose the Simple language
- Set it like this: "${header.Response_Method} == 'createThreshold'"

Deciding which option is better really depends on your end use case, but either should get the job done 0683p000009MACn.png
Best Regards,
Ben

View solution in original post

2 Replies
Anonymous
Not applicable

Hi Hervé,
Simple doesn't understand XML - that syntax works when the body is a Java Bean instead of just a String of XML. The most direct way to do this with your XML is to use XPath rather than Simple. I'll give you a couple of options.
Option 1: Just use XPath
For your predicates on your router paths, you can select the XPath language. Select it and use an XPath expression something like this:
"/response/method"
and
"/response/method"

Option 2: Pull value with XPath, evaluate with Simple
Step 1: Add a cSetHeader component after your JMS listener and add a property to be set
- Choose the XPath Language
- Name the new header property (for instance, Response_Method)
- Set the expression to: "/response/method/text()"
Step 2: Evaluate with Simple
- In your Router predicate choose the Simple language
- Set it like this: "${header.Response_Method} == 'createThreshold'"

Deciding which option is better really depends on your end use case, but either should get the job done 0683p000009MACn.png
Best Regards,
Ben
hvanderheyden
Partner - Contributor
Partner - Contributor
Author

Hi Ben,
Thanks for your answser. I will using xpath expression.
I was looking for the best method to evalute the method tag content, that can contains values like "*Threshold". I knew how doing that with simple... now i'know with xpath 0683p000009MACn.png
"response/method"

Regards