Topic
  • 3 replies
  • Latest Post - ‏2012-10-10T11:18:34Z by kilikil
kilikil
kilikil
8 Posts

Pinned topic issue when mixing xml and non xml request in same service

‏2012-10-09T09:14:41Z |
Hi,

I have a processing rule which looks like:

AAA ---> Transform1 ---> SLM ---> Results

This rule doesn't parse or process data of the request and it works well with both XML and Non-XML requests.

The issue relates to Non-XML requests only after updating the rule:
AAA ---> Transform1 ---> SLM ---> Transform2 ---> Results

The code below is in the Transform2 stylesheet:

<!-- Define the input content as Non-XML (binary) --> <dp:input-mapping href=
"store:///pkcs7-convert-input.ffd" type=
"ffd" />   <!-- base64 encode Non-XML input data --> <xsl:variable name=
"input64" select=
"dp:binary-encode(/object/message/node())" />   <xsl:when test=
"isInputContentXML()"> <xsl:variable name=
"input_xml"> <dp:parse select=
"$input64" encoding=
"base-64" /> </xsl:variable> ... </xsl:when> <xsl:otherwise> ... </xsl:otherwise>


No problem with XML requests but Non-XML fail (eg with the string 'test') :
illegal character 't' at offset 0 of http://.../test

With the probe, I can see the content of the message processed as binary data before the first AAA action which attempts to parse a XML document and throws an error.

Why stylesheets defined in the AAA policy try to parse the data ? and how to avoid the parsing before the Transform2 action ?
Thanks.
Updated on 2012-10-10T11:18:34Z at 2012-10-10T11:18:34Z by kilikil
  • kilikil
    kilikil
    8 Posts

    Re: issue when mixing xml and non xml request in same service

    ‏2012-10-09T12:23:35Z  
    I have a solution but not sure it is the best way.
    I added one binary Transform at the begining of the rule to wrap binary data into an XML tree and a Transform at the end to unwrap:
    AAA ---> Binary Transform (wrap) ---> Transform1 ---> SLM ---> Transform2 ---> Transform (unwrap)

    The content of the binary Transform (wrap) is:
    
    <?xml version=
    "1.0" encoding=
    "utf-8"?> <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" exclude-result-prefixes=
    "dp">   <!-- Define the input content as non-XML (binary) --> <dp:input-mapping href=
    "store:///pkcs7-convert-input.ffd" type=
    "ffd" />   <xsl:template match=
    "/"> <xsl:copy-of select=
    "node()" /> </xsl:template> </xsl:stylesheet>
    


    with the Input and Output of the action set to INPUT
    And I removed the input-mapping from the Tranform2 (see my previous message)

    The second Transform (unwrap) is:
    
    <?xml version=
    "1.0" encoding=
    "utf-8"?> <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" exclude-result-prefixes=
    "dp">   <xsl:template match=
    "/"> <xsl:value-of select=
    "dp:decode(dp:binary-encode(/object/message/node()), 'base-64')" disable-output-escaping=
    "yes" /> </xsl:template> </xsl:stylesheet>
    


    I would like to avoid adding these 2 actions if it possible and understand the parsing issue.
  • HermannSW
    HermannSW
    4651 Posts

    Re: issue when mixing xml and non xml request in same service

    ‏2012-10-09T18:18:12Z  
    • kilikil
    • ‏2012-10-09T12:23:35Z
    I have a solution but not sure it is the best way.
    I added one binary Transform at the begining of the rule to wrap binary data into an XML tree and a Transform at the end to unwrap:
    AAA ---> Binary Transform (wrap) ---> Transform1 ---> SLM ---> Transform2 ---> Transform (unwrap)

    The content of the binary Transform (wrap) is:
    <pre class="jive-pre"> <?xml version= "1.0" encoding= "utf-8"?> <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" exclude-result-prefixes= "dp"> <!-- Define the input content as non-XML (binary) --> <dp:input-mapping href= "store:///pkcs7-convert-input.ffd" type= "ffd" /> <xsl:template match= "/"> <xsl:copy-of select= "node()" /> </xsl:template> </xsl:stylesheet> </pre>

    with the Input and Output of the action set to INPUT
    And I removed the input-mapping from the Tranform2 (see my previous message)

    The second Transform (unwrap) is:
    <pre class="jive-pre"> <?xml version= "1.0" encoding= "utf-8"?> <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" exclude-result-prefixes= "dp"> <xsl:template match= "/"> <xsl:value-of select= "dp:decode(dp:binary-encode(/object/message/node()), 'base-64')" disable-output-escaping= "yes" /> </xsl:template> </xsl:stylesheet> </pre>

    I would like to avoid adding these 2 actions if it possible and understand the parsing issue.
    Hi,

    > ...
    > I would like to avoid adding these 2 actions if it possible and understand the parsing issue.
    >
    the parse error occurs because you ask DataPower to parse in stylesheet of your 1st posting ...
    ...
    <dp:parse select="$input64" encoding="base-64" />
    ...
    


     
    Hermann <myXsltBlog/> <myXsltTweets/>
    Updated on 2014-03-25T02:48:17Z at 2014-03-25T02:48:17Z by iron-man
  • kilikil
    kilikil
    8 Posts

    Re: issue when mixing xml and non xml request in same service

    ‏2012-10-10T11:18:34Z  
    • HermannSW
    • ‏2012-10-09T18:18:12Z
    Hi,

    > ...
    > I would like to avoid adding these 2 actions if it possible and understand the parsing issue.
    >
    the parse error occurs because you ask DataPower to parse in stylesheet of your 1st posting ...
    <pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr">... <dp:parse select="$input64" encoding="base-64" /> ... </pre>

     
    Hermann <myXsltBlog/> <myXsltTweets/>
    Hi Hermann,

    Thanks for your reply.
    However, if I delete the dp:parse instruction, the parsing problem is still there.
    Actually, even with a stylesheet (Transform2 - binary processing action) which contains
    <xsl:template match="/"></xsl:template>
    


    After extra tests, what I understand is that the instruction
    <dp:input-mapping href="store:///pkcs7-convert-input.ffd" type="ffd" />
    
    means that the stylesheet is a binary stylesheet and the transform action has to be set as Binary Transform.
    So, a Binary Transform in a processing rule forces an XML parsing by other standard processing actions (stylesheets without an input-mapping instruction) even if no processing/parsing of request data is performed.

    Any advice to handle this right ?
    Updated on 2014-03-25T02:47:41Z at 2014-03-25T02:47:41Z by iron-man