Topic
  • 8 replies
  • Latest Post - ‏2013-01-01T23:56:33Z by SystemAdmin
SystemAdmin
SystemAdmin
6772 Posts

Pinned topic HTTP Convert action is not working

‏2012-12-14T21:01:51Z |
The scenario is

Request Rule(Client to Server): input(XML) -> transform (XML to JSONX) -> transform (JSON) -> result
Response Rule(Server to Client): input (JOSN) -> Call a sub processing rule (ResponseSubRule) -> result

Response SubRule(Server to Client): convertQueryAction (to convert JSON to JSON)

It's failing in subRule at HTTP ConvertQueryAction.
Convert HTTP produced invalid XML: Incomplete markup or missing document element at offset 39 of"

If I move the convertQueryAction into main response rule from subRule, it works fine.

I see same problem has been reported for error rule as well.

https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14893405&#14893405

Do we know if this is resolved?

Thanks
RG
Updated on 2013-01-01T23:56:33Z at 2013-01-01T23:56:33Z by SystemAdmin
  • HermannSW
    HermannSW
    4885 Posts

    Re: HTTP Convert action is not working

    ‏2012-12-15T15:44:32Z  
    Hi,

    couldn't you do the ConvertQueryAction in response rule before calling SubRule?
    If not, can you attach a small sample export?
    (there are many settings whose value is not clear from your description)

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

    Re: HTTP Convert action is not working

    ‏2012-12-16T04:28:40Z  
    • HermannSW
    • ‏2012-12-15T15:44:32Z
    Hi,

    couldn't you do the ConvertQueryAction in response rule before calling SubRule?
    If not, can you attach a small sample export?
    (there are many settings whose value is not clear from your description)

     
    Hermann<myXsltBlog/> <myXsltTweets/>
    It was working in response rule but my requirement is to call it in subRule.

    The output type I used is "Default" in convert query action.

    One important difference that I noticed between these 2 ways.. when I used convert action in response rule, the content type was same as input. For example the content type passed was "text/javascript" and output was also "text/javascript". But when I forwarded the request to subRule, the content type was changed to "text/xml".
    RG
  • HermannSW
    HermannSW
    4885 Posts

    Re: HTTP Convert action is not working

    ‏2012-12-16T13:21:09Z  
    It was working in response rule but my requirement is to call it in subRule.

    The output type I used is "Default" in convert query action.

    One important difference that I noticed between these 2 ways.. when I used convert action in response rule, the content type was same as input. For example the content type passed was "text/javascript" and output was also "text/javascript". But when I forwarded the request to subRule, the content type was changed to "text/xml".
    RG
    > ... but my requirement is to call it in subRule.
    >
    as said why not call ConvertQueryParams in response rule, and then call SubRule with the output of ConvertQueryParam?
    You would still do the processing in SubRule by that.

    You did not attach a small sample export as requested.

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

    Re: HTTP Convert action is not working

    ‏2012-12-17T00:01:18Z  
    • HermannSW
    • ‏2012-12-16T13:21:09Z
    > ... but my requirement is to call it in subRule.
    >
    as said why not call ConvertQueryParams in response rule, and then call SubRule with the output of ConvertQueryParam?
    You would still do the processing in SubRule by that.

    You did not attach a small sample export as requested.

     
    Hermann<myXsltBlog/> <myXsltTweets/>
    Hi Herman

    Please find the attachment. I created a XML firewall with 2 rules. One is calling another. Subrule has the convert query action which is failing. I am attaching the sample JSON request too.

    {
    "Ss": {
    "vaue": null,
    "coe": 0
    },
    "cId": null,
    "accs": {"acc": [
    {
    "cAcc": "1",
    "bID": "1000",
    "bName": "Fuon",
    "no": "5",
    "nName": "Pukes",
    "rNumber": "6610",
    "cCode": "USD",
    "cBalance": 3054,
    "type": 1,
    "stus": 0
    }
    ]}
    }

    About using the action in response rule, we can do that but the design pattern that we are trying to put want it in subRule.

    Thanks
    Rohit Goyal
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: HTTP Convert action is not working

    ‏2012-12-18T20:09:40Z  
    Hi Herman

    Please find the attachment. I created a XML firewall with 2 rules. One is calling another. Subrule has the convert query action which is failing. I am attaching the sample JSON request too.

    {
    "Ss": {
    "vaue": null,
    "coe": 0
    },
    "cId": null,
    "accs": {"acc": [
    {
    "cAcc": "1",
    "bID": "1000",
    "bName": "Fuon",
    "no": "5",
    "nName": "Pukes",
    "rNumber": "6610",
    "cCode": "USD",
    "cBalance": 3054,
    "type": 1,
    "stus": 0
    }
    ]}
    }

    About using the action in response rule, we can do that but the design pattern that we are trying to put want it in subRule.

    Thanks
    Rohit Goyal
    Hi Herman, any lead on this?

    Thanks
    RG
  • HermannSW
    HermannSW
    4885 Posts

    Re: HTTP Convert action is not working

    ‏2012-12-20T13:14:11Z  
    Hi Herman, any lead on this?

    Thanks
    RG
    Hi Rohit,

    thanks for your export.
    It seems that DataPower convert-http(json) action has a problem reading from context INPUT in a called rule.
    Please create a PMR on this.

    OK, so what can you do right now?
    You may use the following simple workaround to "make INPUT accessible" to convert-http(json) action in called rule!
    This is stylesheet binary-passthru.xsl (from this posting).
    
    <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"/> <dp:output-mapping href=
    "store:///pkcs7-convert-input.ffd" type=
    "ffd"/>   <xsl:template match=
    "object"> <xsl:copy-of select=
    "."/> </xsl:template>   </xsl:stylesheet>
    


    Just
    • insert a Transform Binary Action as very first action in rule
    • referencing binary-passthru.xsl
    • input context INPUT
    • output context INPUT (!!)

    By this the INPUT context gets corrected for processing by "INPUT--convert-http(json)-..." in called rule.

     
    Hermann<myXsltBlog/> <myXsltTweets/>
  • HermannSW
    HermannSW
    4885 Posts

    Re: HTTP Convert action is not working

    ‏2012-12-20T13:52:43Z  
    • HermannSW
    • ‏2012-12-20T13:14:11Z
    Hi Rohit,

    thanks for your export.
    It seems that DataPower convert-http(json) action has a problem reading from context INPUT in a called rule.
    Please create a PMR on this.

    OK, so what can you do right now?
    You may use the following simple workaround to "make INPUT accessible" to convert-http(json) action in called rule!
    This is stylesheet binary-passthru.xsl (from this posting).
    <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"/> <dp:output-mapping href= "store:///pkcs7-convert-input.ffd" type= "ffd"/> <xsl:template match= "object"> <xsl:copy-of select= "."/> </xsl:template> </xsl:stylesheet> </pre>

    Just
    • insert a Transform Binary Action as very first action in rule
    • referencing binary-passthru.xsl
    • input context INPUT
    • output context INPUT (!!)

    By this the INPUT context gets corrected for processing by "INPUT--convert-http(json)-..." in called rule.

     
    Hermann<myXsltBlog/> <myXsltTweets/>
    Ooops, please do not create a PMR.

    And you do not need above workaround -- just
    • go to "Object->XML Processing->Procesing Rule"
    • select your main processing rule (not the called rule)
    • set "Non-XML Processing" to "On"

    Then everything works fine, and convert-http(json) action can access INPUT from within called rule.

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

    Re: HTTP Convert action is not working

    ‏2013-01-01T23:56:33Z  
    • HermannSW
    • ‏2012-12-20T13:52:43Z
    Ooops, please do not create a PMR.

    And you do not need above workaround -- just
    • go to "Object->XML Processing->Procesing Rule"
    • select your main processing rule (not the called rule)
    • set "Non-XML Processing" to "On"

    Then everything works fine, and convert-http(json) action can access INPUT from within called rule.

     
    Hermann<myXsltBlog/> <myXsltTweets/>
    Thanks Herman. It worked fine.

    RG