Topic
  • 9 replies
  • Latest Post - ‏2013-11-27T13:24:36Z by HermannSW
SystemAdmin
SystemAdmin
6772 Posts

Pinned topic Multi route action in a rules

‏2012-06-12T23:49:44Z |
Hi,
I have a rules with some transformation and i have a route action to send in a MQ Queue. I want to add a conditional action with a route action to send in a other MQ queue but it alway send only 1 queue. I try to add 2 results but not working. I try to call a other rule in my conditional action and this rule only have a route action and result but the xml send only in 1 queue. Anobody can help me?

Other question, a have a rule with some transformation, in one of transformation i generate a xml with a cdata balise and the output is in var2. Inthe next transformation my input is var2 and i only do a url-open to a mq queue. But my cdata doesnt appear and the xml in my cdata is escape. I do xsl:copy select "." disabled output escaping= yes but it's not work i need help

Thank
Updated on 2012-06-13T20:06:27Z at 2012-06-13T20:06:27Z by HermannSW
  • HermannSW
    HermannSW
    4654 Posts

    Re: Multi route action in a rules

    ‏2012-06-13T00:38:44Z  
    Hi,
    > I have a rules with some transformation and i have a route action to send in a MQ Queue.
    > I want to add a conditional action with a route action to send in a other MQ queue but it
    > alway send only 1 queue. I try to add 2 results but not working. I try to call a other rule
    > in my conditional action and this rule only have a route action and result but the xml send > only in 1 queue. Anobody can help me?
    >
    only one route action can be active.
    You may use a results action with Destination to the other MQ.
    A single results action may also have many destinations.

    > Other question, a have a rule with some transformation, in one of transformation i generate
    > a xml with a cdata balise and the output is in var2. Inthe next transformation my input is
    > var2 and i only do a url-open to a mq queue. But my cdata doesnt appear and the xml in my
    > cdata is escape. I do xsl:copy select "." disabled output escaping= yes but it's not work i need help
    >
    The second stylesheet parses var2 (context) again, and the parser parses(removes) that cdata section.

    So you do not want this 2nd parse to happen.
    Solution is to use a "Transform Binary" action with input context var2.

    This simple stylesheet generates CDATA section in output:
    
    <xsl:stylesheet version=
    "1.0" xmlns:xsl=
    "http://www.w3.org/1999/XSL/Transform" xmlns:dp=
    "http://www.datapower.com/extensions" extension-element-prefixes=
    "dp" > <xsl:output omit-xml-declaration=
    "yes" cdata-section-elements=
    "string" /> <xsl:template match=
    "/*"> <string><xsl:value-of select=
    "."/></string> </xsl:template> </xsl:stylesheet>
    


    And this stylesheet used in a "Transform Binary" action just converts (binary) input to base64 encoded data:
    
    <xsl:stylesheet version=
    "1.0" xmlns:xsl=
    "http://www.w3.org/1999/XSL/Transform" xmlns:dp=
    "http://www.datapower.com/extensions" extension-element-prefixes=
    "dp" > <dp:input-mapping  href=
    "store:///pkcs7-convert-input.ffd" type=
    "ffd"/>   <xsl:output omit-xml-declaration=
    "yes" /> <xsl:template match=
    "/"> <xsl:copy-of select=
    "dp:binary-encode(/object/message/node())"/> </xsl:template> </xsl:stylesheet>
    


    This demonstrates above stylesheets, 1st as "Transform" and 2nd as "Transform Binary" action in sequence:
    
    $ curl --data-binary 
    "<x>abc</x>" http:
    //dp3-l3:2084 ; echo PHN0cmluZz48IVtDREFUQVthYmNdXT48L3N0cmluZz4= $ $ curl --data-binary 
    "<x>abc</x>" http:
    //dp3-l3:2084 -s | base64 -d ; echo <string><![CDATA[abc]]></string> $
    


    Now you can send the base64 encoded (unparsed) data via <dp:url-open ...data-type="base64"> to a backend.
    data-type="base64" first decodes the base64 string and sends the result then.

    For background on Non-XML data processing in stylesheets please see this two webcasts:
    http://www-01.ibm.com/support/docview.wss?uid=swg27022977
    http://www-01.ibm.com/support/docview.wss?uid=swg27022979

     
    Hermann<myXsltBlog/> <myXsltTweets/>
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: Multi route action in a rules

    ‏2012-06-13T00:56:51Z  
    • HermannSW
    • ‏2012-06-13T00:38:44Z
    Hi,
    > I have a rules with some transformation and i have a route action to send in a MQ Queue.
    > I want to add a conditional action with a route action to send in a other MQ queue but it
    > alway send only 1 queue. I try to add 2 results but not working. I try to call a other rule
    > in my conditional action and this rule only have a route action and result but the xml send > only in 1 queue. Anobody can help me?
    >
    only one route action can be active.
    You may use a results action with Destination to the other MQ.
    A single results action may also have many destinations.

    > Other question, a have a rule with some transformation, in one of transformation i generate
    > a xml with a cdata balise and the output is in var2. Inthe next transformation my input is
    > var2 and i only do a url-open to a mq queue. But my cdata doesnt appear and the xml in my
    > cdata is escape. I do xsl:copy select "." disabled output escaping= yes but it's not work i need help
    >
    The second stylesheet parses var2 (context) again, and the parser parses(removes) that cdata section.

    So you do not want this 2nd parse to happen.
    Solution is to use a "Transform Binary" action with input context var2.

    This simple stylesheet generates CDATA section in output:
    <pre class="jive-pre"> <xsl:stylesheet version= "1.0" xmlns:xsl= "http://www.w3.org/1999/XSL/Transform" xmlns:dp= "http://www.datapower.com/extensions" extension-element-prefixes= "dp" > <xsl:output omit-xml-declaration= "yes" cdata-section-elements= "string" /> <xsl:template match= "/*"> <string><xsl:value-of select= "."/></string> </xsl:template> </xsl:stylesheet> </pre>

    And this stylesheet used in a "Transform Binary" action just converts (binary) input to base64 encoded data:
    <pre class="jive-pre"> <xsl:stylesheet version= "1.0" xmlns:xsl= "http://www.w3.org/1999/XSL/Transform" xmlns:dp= "http://www.datapower.com/extensions" extension-element-prefixes= "dp" > <dp:input-mapping href= "store:///pkcs7-convert-input.ffd" type= "ffd"/> <xsl:output omit-xml-declaration= "yes" /> <xsl:template match= "/"> <xsl:copy-of select= "dp:binary-encode(/object/message/node())"/> </xsl:template> </xsl:stylesheet> </pre>

    This demonstrates above stylesheets, 1st as "Transform" and 2nd as "Transform Binary" action in sequence:
    <pre class="jive-pre"> $ curl --data-binary "<x>abc</x>" http: //dp3-l3:2084 ; echo PHN0cmluZz48IVtDREFUQVthYmNdXT48L3N0cmluZz4= $ $ curl --data-binary "<x>abc</x>" http: //dp3-l3:2084 -s | base64 -d ; echo <string><![CDATA[abc]]></string> $ </pre>

    Now you can send the base64 encoded (unparsed) data via <dp:url-open ...data-type="base64"> to a backend.
    data-type="base64" first decodes the base64 string and sends the result then.

    For background on Non-XML data processing in stylesheets please see this two webcasts:
    http://www-01.ibm.com/support/docview.wss?uid=swg27022977
    http://www-01.ibm.com/support/docview.wss?uid=swg27022979

     
    Hermann<myXsltBlog/> <myXsltTweets/>
    Thank you. But how i can configure result to always send to a mq queue and in when the condition it's true then send to a other mq queue? Thank you so much i'm new in datapower
  • HermannSW
    HermannSW
    4654 Posts

    Re: Multi route action in a rules

    ‏2012-06-13T07:27:59Z  
    Thank you. But how i can configure result to always send to a mq queue and in when the condition it's true then send to a other mq queue? Thank you so much i'm new in datapower
    > Thank you. But how i can configure result to always send to a mq queue and in when
    > the condition it's true then send to a other mq queue? Thank you so much i'm new in datapower
    >
    The condition for conditional action is a XPath expression.
    Just use two conditional actions to achieve what you want.

    So this construct allows to conditionally select between two backend destinations:
    ...
    ctx1 -- conditional(someXPathExpression)-->results(Destination=backend1) -- ctx2 
    ctx1 -- conditional(not(someXPathExpression))-->results(Destination=backend2) -- ctx3
    ...
    


     
    Hermann <myXsltBlog/> <myXsltTweets/>
    Updated on 2014-03-25T02:54:01Z at 2014-03-25T02:54:01Z by iron-man
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: Multi route action in a rules

    ‏2012-06-13T14:30:58Z  
    • HermannSW
    • ‏2012-06-13T07:27:59Z
    > Thank you. But how i can configure result to always send to a mq queue and in when
    > the condition it's true then send to a other mq queue? Thank you so much i'm new in datapower
    >
    The condition for conditional action is a XPath expression.
    Just use two conditional actions to achieve what you want.

    So this construct allows to conditionally select between two backend destinations:
    <pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr">... ctx1 -- conditional(someXPathExpression)-->results(Destination=backend1) -- ctx2 ctx1 -- conditional(not(someXPathExpression))-->results(Destination=backend2) -- ctx3 ... </pre>

     
    Hermann <myXsltBlog/> <myXsltTweets/>
    Thank you it's working good, But I have a other problem I receive a Reponses in a mq Queue and the message have a Cdata, but when a receive the response, I want to send in a Other MQ Queue but I dont have my Cdata and the XML in my cdata is Escape.

    In my rules a have a match action, after a condition action that have a result action that send in MQ queue.

    Thank you
  • HermannSW
    HermannSW
    4654 Posts

    Re: Multi route action in a rules

    ‏2012-06-13T15:36:48Z  
    Thank you it's working good, But I have a other problem I receive a Reponses in a mq Queue and the message have a Cdata, but when a receive the response, I want to send in a Other MQ Queue but I dont have my Cdata and the XML in my cdata is Escape.

    In my rules a have a match action, after a condition action that have a result action that send in MQ queue.

    Thank you
    > Thank you it's working good, But I have a other problem I receive a Reponses in a mq Queue and the message have a Cdata,
    > but when a receive the response, I want to send in a Other MQ Queue but I dont have my Cdata and the XML in my cdata is Escape.
    >
    > In my rules a have a match action, after a condition action that have a result action that send in MQ queue.
    >
    I am not sure I correctly understand.

    Your response rule is:
    match
    INPUT -- conditional(someXPathExpression)-->results(Destination=someDestination) -- OUTPUT
    


    And the CDATA section recived from backend gets parsed/removed before results action sends to someDestination?

    If so, what is the Reponse Type of your rule?
    According what you state it is XML or SOAP.

    Try chaninging it to Non-XML to avoid the implicit parsing by XML or SOAP response types.

     
    Hermann <myXsltBlog/> <myXsltTweets/>
    Updated on 2014-03-25T02:53:38Z at 2014-03-25T02:53:38Z by iron-man
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: Multi route action in a rules

    ‏2012-06-13T16:58:47Z  
    • HermannSW
    • ‏2012-06-13T15:36:48Z
    > Thank you it's working good, But I have a other problem I receive a Reponses in a mq Queue and the message have a Cdata,
    > but when a receive the response, I want to send in a Other MQ Queue but I dont have my Cdata and the XML in my cdata is Escape.
    >
    > In my rules a have a match action, after a condition action that have a result action that send in MQ queue.
    >
    I am not sure I correctly understand.

    Your response rule is:
    <pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr">match INPUT -- conditional(someXPathExpression)-->results(Destination=someDestination) -- OUTPUT </pre>

    And the CDATA section recived from backend gets parsed/removed before results action sends to someDestination?

    If so, what is the Reponse Type of your rule?
    According what you state it is XML or SOAP.

    Try chaninging it to Non-XML to avoid the implicit parsing by XML or SOAP response types.

     
    Hermann <myXsltBlog/> <myXsltTweets/>
    yes CDATA receive from backend gets parsed/removed to someDestination. My response type of my MPG is XML when I change it to NON-XML I receive nothing.

    Thank
  • HermannSW
    HermannSW
    4654 Posts

    Re: Multi route action in a rules

    ‏2012-06-13T20:06:27Z  
    yes CDATA receive from backend gets parsed/removed to someDestination. My response type of my MPG is XML when I change it to NON-XML I receive nothing.

    Thank
    Sorry, you are right.

    Please have a Transform Binary action with this FFD stylesheet.
    Adapt target variable and yourXPathExpression to your needs.
    This stylesheet
    • takes the Non-XML input
    • parses it and determines an XPath expression
    • if true, sends the data unmodified against $target

    So no conditional and results actions needed by this approach:
    
    <xsl:stylesheet version=
    "1.0" xmlns:xsl=
    "http://www.w3.org/1999/XSL/Transform" xmlns:dp=
    "http://www.datapower.com/extensions" extension-element-prefixes=
    "dp" > <dp:input-mapping href=
    "store:///pkcs7-convert-input.ffd" type=
    "ffd"/>   <xsl:variable name=
    "target" select=
    "'dpmq://....'"/>   <xsl:template match=
    "/"> <xsl:variable name=
    "input64" select=
    "dp:binary-encode(/object/message)"/>   <xsl:
    
    if test=
    "dp:parse($input64,'base-64')/yourXPathExpression"> <xsl:variable name=
    "response"> <dp:url-open target=
    "{$target}" response=
    "responsecode" data-type=
    "base64" > <xsl:value-of select=
    "$input64"/> </dp:url-open> </xsl:variable> </xsl:if> </xsl:template> </xsl:stylesheet>
    


     
    Hermann<myXsltBlog/> <myXsltTweets/>
  • ManishJ
    ManishJ
    24 Posts

    Re: Multi route action in a rules

    ‏2013-11-27T12:49:59Z  
    • HermannSW
    • ‏2012-06-13T20:06:27Z
    Sorry, you are right.

    Please have a Transform Binary action with this FFD stylesheet.
    Adapt target variable and yourXPathExpression to your needs.
    This stylesheet
    • takes the Non-XML input
    • parses it and determines an XPath expression
    • if true, sends the data unmodified against $target

    So no conditional and results actions needed by this approach:
    <pre class="jive-pre"> <xsl:stylesheet version= "1.0" xmlns:xsl= "http://www.w3.org/1999/XSL/Transform" xmlns:dp= "http://www.datapower.com/extensions" extension-element-prefixes= "dp" > <dp:input-mapping href= "store:///pkcs7-convert-input.ffd" type= "ffd"/> <xsl:variable name= "target" select= "'dpmq://....'"/> <xsl:template match= "/"> <xsl:variable name= "input64" select= "dp:binary-encode(/object/message)"/> <xsl: if test= "dp:parse($input64,'base-64')/yourXPathExpression"> <xsl:variable name= "response"> <dp:url-open target= "{$target}" response= "responsecode" data-type= "base64" > <xsl:value-of select= "$input64"/> </dp:url-open> </xsl:variable> </xsl:if> </xsl:template> </xsl:stylesheet> </pre>

     
    Hermann<myXsltBlog/> <myXsltTweets/>

    Hi Hermann,

    Is it possible to set a conditional action based on context variable instead of some xpath? If yes, what should be given in match condition?

    I want to set a condition at DataPower context variable var://context/performance/log-target for a match of "DISK".

    Cheers

    Manish

  • HermannSW
    HermannSW
    4654 Posts

    Re: Multi route action in a rules

    ‏2013-11-27T13:24:36Z  
    • ManishJ
    • ‏2013-11-27T12:49:59Z

    Hi Hermann,

    Is it possible to set a conditional action based on context variable instead of some xpath? If yes, what should be given in match condition?

    I want to set a condition at DataPower context variable var://context/performance/log-target for a match of "DISK".

    Cheers

    Manish

    Hi Manish,

    sorry, conditional action XPath expression only works on conditional action input context.

    There is an easy workaround for what you want, though:

    ...-.NULL--xform(your.xsl)--PIPE--conditional action...

    And your.xsl just returns

    <xsl:copy-of select="dp:variable('var://context/performance/log')"/>

     

    Hermann<myXsltBlog/> <myXsltTweets/> <myCE/> <myFrameless/>