Unable to Extract XML data using ExtractVariables Policy XMLPayload

I got a SOAP Response which i am using to extract XML data using ExtractVariables Policy XMLPayload. But i keep getting empty variables even after setting variable type as 'nodeset' and adding 'namespace' elements to the policy

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Header/>
    <soapenv:Body>
        <Products>
            <product>
                <productid>PMS-425-02</productid>
                <qty>234</qty>
                <storeid>201</storeid>
            </product>
        </Products>
    </soapenv:Body>
</soapenv:Envelope>
Solved Solved
0 4 967
1 ACCEPTED SOLUTION

Able to fetch the XML data by removing namespaces using XSL Policy with below xslt

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" indent="yes"/>
    <xsl:template match="*">
        <xsl:element name="{local-name(.)}">
            <xsl:apply-templates select="@* | node()"/>
        </xsl:element>
    </xsl:template>
    <xsl:template match="@*">
        <xsl:attribute name="{local-name(.)}">
            <xsl:value-of select="."/>
        </xsl:attribute>
    </xsl:template>
</xsl:stylesheet>

And in extract variables policy, i referenced only using attributes as below

<XMLPayload stopPayloadProcessing="false">
    <Variable name="availabilityResponse" type="nodeset">
        <XPath>/Envelope/Body/Products</XPath>
    </Variable>
</XMLPayload>

View solution in original post

4 REPLIES 4

Able to fetch the XML data by removing namespaces using XSL Policy with below xslt

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" indent="yes"/>
    <xsl:template match="*">
        <xsl:element name="{local-name(.)}">
            <xsl:apply-templates select="@* | node()"/>
        </xsl:element>
    </xsl:template>
    <xsl:template match="@*">
        <xsl:attribute name="{local-name(.)}">
            <xsl:value-of select="."/>
        </xsl:attribute>
    </xsl:template>
</xsl:stylesheet>

And in extract variables policy, i referenced only using attributes as below

<XMLPayload stopPayloadProcessing="false">
    <Variable name="availabilityResponse" type="nodeset">
        <XPath>/Envelope/Body/Products</XPath>
    </Variable>
</XMLPayload>

@Aswin Segu

Following code is working.

<XMLPayload>
  <Namespaces>
    <Namespace prefix="soapenv">http://schemas.xmlsoap.org/soap/envelope/</Namespace>
  </Namespaces>
  <Variable name="availabilityResponse" type="nodeset">
    <XPath>/soapenv:Envelope/soapenv:Body/Products</XPath>
  </Variable>
</XMLPayload>

Hi Amar,

Even i used the same XPath Variable in my Extract Variables Policy, but was getting empty 'availabilityResponse', but now as i implemented it as i specified above, i could not post exactly here

@Aswin Segu, You haven't posted ExtractVariables Policy, That might clarify what exactly is the reason it's not working for you.