Topic
  • 4 replies
  • Latest Post - ‏2013-07-15T13:19:05Z by swlinn
NILAY97
NILAY97
224 Posts

Pinned topic MPGW to parse XML and Non XML both

‏2013-07-14T04:23:26Z |

Hi All,

I have a MPGW with Request Type and Response Type set to Non XML. The situation is that:--

Client sends in  different request to this MPGW.

a) Login request. Here, the client sends in just a url e.g www.google.com. The backend returns a Security Challenge back to client. Here, DataPower is acting as a pass through. The Security challenge sent by Backend is somewhat like this

<Security Challenege="PressSTART"/>

b) Client signs the challenge and sends it back to Backend. Once the authentication is done, the backend returns the list of urls in XML form.

The problem faced here is when MPGW receives the list of urls in XML form. SInce the Request and Response type is set to NON  XML. The XML returned does not get parsed and fails in DataPower with message < Illegal Character at offset.....

Is there a way in DataPower where i can process the Request and Response Type as received by Client/Backend.

Note:- MPGW is currently configured as a Dynamic backend where Iam routing the request using an XSL. I have tried selecting the Request and Response Type as Pass Through but this fails in the first request itself.

Please help me with this.

  • HermannSW
    HermannSW
    4740 Posts

    Re: MPGW to parse XML and Non XML both

    ‏2013-07-14T10:59:01Z  

    > SInce the Request and Response type is set to NON  XML. The XML returned does not get parsed and fails in DataPower with message < Illegal Character at offset....
    >

    that does not make sense, in case of Non-XML DataPower will NOT parse and you cannot see the parse error.

    Where do you see the parse error, request or response rule of MPGW?
    What is the corresponding request/response type?

    In addition, please do a packet capture and let us know what "really" gets send (by client or backend) that fails parsing as XML.

     

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

  • NILAY97
    NILAY97
    224 Posts

    Re: MPGW to parse XML and Non XML both

    ‏2013-07-15T04:32:33Z  
    • HermannSW
    • ‏2013-07-14T10:59:01Z

    > SInce the Request and Response type is set to NON  XML. The XML returned does not get parsed and fails in DataPower with message < Illegal Character at offset....
    >

    that does not make sense, in case of Non-XML DataPower will NOT parse and you cannot see the parse error.

    Where do you see the parse error, request or response rule of MPGW?
    What is the corresponding request/response type?

    In addition, please do a packet capture and let us know what "really" gets send (by client or backend) that fails parsing as XML.

     

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

    Hermann,

    I see this Error in Response Rule of MPGW. My Response rule is configured as:-

     

    Match(all)--->>>Results. Could you please let me know the steps to do a packet capture as iam really new to DataPower?

  • PradeepMalineni
    PradeepMalineni
    31 Posts

    Re: MPGW to parse XML and Non XML both

    ‏2013-07-15T08:36:12Z  
    • NILAY97
    • ‏2013-07-15T04:32:33Z

    Hermann,

    I see this Error in Response Rule of MPGW. My Response rule is configured as:-

     

    Match(all)--->>>Results. Could you please let me know the steps to do a packet capture as iam really new to DataPower?

    Make sure back end sending the well-formed xml file as a response, if it's not DataPower will throw parsing error.

    Packet Capture : Login to Default Domain -->From Control Panel --> Trouble Shooting (Click on this ICON) -->Locate the Packet Capture Tab Select the interface where your service is listening --> Mode--> Click the Start Packet Capture.

    Send transaction to your service and collect the pcap file from the temporary directory.

     

  • swlinn
    swlinn
    1348 Posts

    Re: MPGW to parse XML and Non XML both

    ‏2013-07-15T13:19:05Z  
    • NILAY97
    • ‏2013-07-15T04:32:33Z

    Hermann,

    I see this Error in Response Rule of MPGW. My Response rule is configured as:-

     

    Match(all)--->>>Results. Could you please let me know the steps to do a packet capture as iam really new to DataPower?

    If your response rule only has a matching rule and a result action with input context INPUT, this makes no sense unless your response type is XML.  If you are doing anything else on the response rule, if the backend is not sending XML and INPUT is the input context to an action, you'll get this type of error.  The packet capture will reveal what you are getting from the backend, assuming your backend is http.  If https you have the have the backend server's private key to decrypt the capture which I've found problematic as the owner of the backend service doesn't want to share their private key.  If that is the case, another approach would be to temporarily place a binary transformation action as your first action of the rule.  The xsl executed, which doesn't handle all of the encoding issues I'm sure Hermann's similar posts do handle, may do the trick by outputting what came into the response rule in your default log.

    File name: wrapper.ffd

    <File name="input">
        <Field name="wrapper"/>
    </File>
     

    File name wrapper.xsl

    <?xml version="1.0" encoding="utf-8"?>

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
                    xmlns:dp="http://www.datapower.com/extensions"
                    extension-element-prefixes="dp"
                    exclude-result-prefixes="dp">

        <!-- This stylesheet simply copies the binary input to XML output -->
        <dp:input-mapping href="wrapper.ffd" type="ffd"/>
        <xsl:output method="xml"/>

        <xsl:template match="/">
           <xsl:message dp:priority="debug">Response = <xsl:copy-of select="."/></xsl:message>
        </xsl:template>

    </xsl:stylesheet>

    The binary transformation action should reference wrapper.xsl.

    Regards,
    Steve