Topic
  • 7 replies
  • Latest Post - ‏2012-10-08T05:38:50Z by devdp
devdp
devdp
37 Posts

Pinned topic How to implement error handling?

‏2012-10-03T09:45:24Z |
Hi,

How can I implement the error handling in MPG for JSON type of request messages?

dp
Updated on 2012-10-08T05:38:50Z at 2012-10-08T05:38:50Z by devdp
  • swlinn
    swlinn
    1348 Posts

    Re: How to implement error handling?

    ‏2012-10-03T13:00:12Z  
    You could have an error rule that would have a stylesheet to produce a custom error JSON response. Since this response is non-XML, your stylesheet would need a xsl:output element to specify text as the type.

    Regards,
    Steve
  • devdp
    devdp
    37 Posts

    Re: How to implement error handling?

    ‏2012-10-04T05:15:38Z  
    • swlinn
    • ‏2012-10-03T13:00:12Z
    You could have an error rule that would have a stylesheet to produce a custom error JSON response. Since this response is non-XML, your stylesheet would need a xsl:output element to specify text as the type.

    Regards,
    Steve
    Hi Steve,

    Thanks for the reply...
    My scenario is as below
    Reqrule: Source Request(JSON)->DPaction(convert query params JSON2JSONX)->DPXSL(JSONX to SOAP)->Target
    Resprule: Target Response(SOAP)->DPaction(SOAP to JSONX)->DPaction(store://JSONXtoJSON)->Source
    If any error occurs in the above transaction then error rule will get triggered and JSONrequest(source) is sent to error rule...
    Now how to customize the error...
    I tried as you asked me to use xsl:ouput as text...
    I am getting error in logs as "illegal character '{' at offset 0 of" as JSON message is going as input to error rule.
    I guess xsl:ouput as text is to get the response as text...

    I also tried using the DPaction(convert query params JSON2JSONX)whatever I used in my request rule.. I am getting the error as below
    "convert-http: 'Converting INPUT with map JSON2JSONX results stored in PIPE' failed: Convert HTTP produced invalid XML: Incomplete markup or missing document element at offset 39 of"

    dp
  • devdp
    devdp
    37 Posts

    Re: How to implement error handling?

    ‏2012-10-04T07:50:32Z  
    • devdp
    • ‏2012-10-04T05:15:38Z
    Hi Steve,

    Thanks for the reply...
    My scenario is as below
    Reqrule: Source Request(JSON)->DPaction(convert query params JSON2JSONX)->DPXSL(JSONX to SOAP)->Target
    Resprule: Target Response(SOAP)->DPaction(SOAP to JSONX)->DPaction(store://JSONXtoJSON)->Source
    If any error occurs in the above transaction then error rule will get triggered and JSONrequest(source) is sent to error rule...
    Now how to customize the error...
    I tried as you asked me to use xsl:ouput as text...
    I am getting error in logs as "illegal character '{' at offset 0 of" as JSON message is going as input to error rule.
    I guess xsl:ouput as text is to get the response as text...

    I also tried using the DPaction(convert query params JSON2JSONX)whatever I used in my request rule.. I am getting the error as below
    "convert-http: 'Converting INPUT with map JSON2JSONX results stored in PIPE' failed: Convert HTTP produced invalid XML: Incomplete markup or missing document element at offset 39 of"

    dp
    Hi,

    Now I am able to do the customization for erroes after making the input as NULL in the error rule.

    dp
  • swlinn
    swlinn
    1348 Posts

    Re: How to implement error handling?

    ‏2012-10-04T14:19:57Z  
    • devdp
    • ‏2012-10-04T07:50:32Z
    Hi,

    Now I am able to do the customization for erroes after making the input as NULL in the error rule.

    dp
    Correct, NULL is required since passing a non-XML message to your standard transformation action will fail when it attempts to parse the message as XML. If you need access to the original JSON request, you'll need to use a HTTP Convert action with a JSON encoding on your error rule to get a JSONX representation you can use in building your JSON output.

    Regards,
    Steve
  • devdp
    devdp
    37 Posts

    Re: How to implement error handling?

    ‏2012-10-05T09:44:17Z  
    • swlinn
    • ‏2012-10-04T14:19:57Z
    Correct, NULL is required since passing a non-XML message to your standard transformation action will fail when it attempts to parse the message as XML. If you need access to the original JSON request, you'll need to use a HTTP Convert action with a JSON encoding on your error rule to get a JSONX representation you can use in building your JSON output.

    Regards,
    Steve
    Hi Steve,

    I tried using the convert action in the error rule but I am getting the below error.
    "* convert-http: 'Converting INPUT with map errjson results stored in PIPE' failed: Convert HTTP produced invalid XML: Incomplete markup or missing document element at offset 39 of*"

    The same message and convert action is working fine in the request rule.
    It is failing only in error rule

    dp
  • swlinn
    swlinn
    1348 Posts

    Re: How to implement error handling?

    ‏2012-10-05T14:22:51Z  
    • devdp
    • ‏2012-10-05T09:44:17Z
    Hi Steve,

    I tried using the convert action in the error rule but I am getting the below error.
    "* convert-http: 'Converting INPUT with map errjson results stored in PIPE' failed: Convert HTTP produced invalid XML: Incomplete markup or missing document element at offset 39 of*"

    The same message and convert action is working fine in the request rule.
    It is failing only in error rule

    dp
    Hi dp,

    I was able to recreate a similar result. You should open a PMR as the INPUT context to your error rule does have valid JSON, but the HTTP Convert action does not appear to work in an error rule. What you will need to do as a workaround is to output the result of the convert action in your request rule into a named context, and then consume that context (containing jsonx) in your error rule instead of doing the convert there.

    Regards,
    Steve
  • devdp
    devdp
    37 Posts

    Re: How to implement error handling?

    ‏2012-10-08T05:38:50Z  
    • swlinn
    • ‏2012-10-05T14:22:51Z
    Hi dp,

    I was able to recreate a similar result. You should open a PMR as the INPUT context to your error rule does have valid JSON, but the HTTP Convert action does not appear to work in an error rule. What you will need to do as a workaround is to output the result of the convert action in your request rule into a named context, and then consume that context (containing jsonx) in your error rule instead of doing the convert there.

    Regards,
    Steve
    Hi Steve,

    Thanks for the suggestion.I will try to open the PMR.

    dp