DataPower

 View Only
  • 1.  Filtering SOAP response in Datapower Gateway

    Posted Sun March 17, 2024 09:30 AM
    Hi Team...
     
    My Datapower Web service proxy backend is receiving the below response from backend web service. However, the response returned is having repeatitive complex type elements. I wanted to basically always filter only the first instance of complex type in XSLT and send it to the front end as below. Please advise how it can be easily achieved in Datapower XSLT
     
    <SoapEnv>
    ....
    <SoapBody>
    <CheckResponse>
    <CheckResult>
    <Message>abc</Message>
    <Result>NO</Result>
    </CheckResult>
    <CheckResult>
    <Message>def</Message>
    <Result>YES</Result>
    </CheckResult>
    <CheckResult>
    <Message>ghi</Message>
    <Result>NO</Result>
    </CheckResult>
    <CheckResult>
    <Message>lmn</Message>
    <Result>YES</Result>
    </CheckResult>
    ..........
    </CheckResponse>
    </SoapBody>
    </SoapEnv>
     
    The output after striping the first complex should be as below,
     
    <SoapEnv>
    ....
    <SoapBody>
    <CheckResponse>
    <CheckResult>
    <Message>abc</Message>
    <Result>NO</Result>
    </CheckResult>
    </CheckResponse>
    </SoapBody>
    </SoapEnv>


    ------------------------------
    Ashok Beshra
    ------------------------------


  • 2.  RE: Filtering SOAP response in Datapower Gateway

    Posted Mon March 18, 2024 03:44 AM
    Edited by Hermann Stamm-Wilbrandt Mon March 18, 2024 03:51 AM

    What you want is some kind of element removal.
    I always start with this Wikipedia example for such kind of task:
    https://en.wikipedia.org/wiki/Identity_transform#Using_XSLT_3

    This would just remove all CheckResult entries:

    <xsl:template match="CheckResult"/>


    Since you want to keep the 1st one, this is what you want:

      <xsl:template match="CheckResult[position() > 1]"/>


    This might work as for simple example. But in case you only want to remove all but 1st CheckResult children of CheckResponse and keep them elsewhere, you need to adjust the XPath expression accordingly.


    DataPower has XSLT 1.0 compiler with XPath 1.0, here is spec on XPath position() function used:
    https://www.w3.org/TR/1999/REC-xpath-19991116/#function-position


    P.S:
    xsltproc is an old command line XSLT 1.0 processor and can be used for this example:

    $ xsltproc soa.xsl inp.xml 
    <SoapEnv>
    <SoapBody>
    <CheckResponse>
    <CheckResult>
    <Message>abc</Message>
    <Result>NO</Result>
    </CheckResult>

    </CheckResponse>
    </SoapBody>
    </SoapEnv>
    $

     
    ------------------------------
    Hermann Stamm-Wilbrandt
    Compiler Level 3 support, IBM DataPower Gateways
    IBM
    Boeblingen Germany
    ------------------------------



  • 3.  RE: Filtering SOAP response in Datapower Gateway

    Posted Sat March 23, 2024 03:34 AM

    Great Mr.Hermann! I am able to get the output after your suggestion. Thanks



    ------------------------------
    Ashok Beshra
    ------------------------------