extract variable policy - extract variable from XML does not extract value

Hi,

I am trying to extract a variable from XML and set it to ms.cert, when I access ms.cert in an assign message policy. it is empty, though the Extract Variable Policy returns success.

Below is my Extract Variable policy code and attached is an sample xml - meta.txt

Can you please help, where I am missing the configuration ?

<ExtractVariables name="Extract-MsCert">
    <DisplayName>Extract-MsCert</DisplayName>
    <FaultRules/>
    <Properties/>
    <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
    <Source clearPayload="false">msCert.content</Source>
    <VariablePrefix>ms</VariablePrefix>
    <XMLPayload stopPayloadProcessing="false">
        <Namespaces/>
        <Variable name="cert" type="string">
            <XPath>/EntityDescriptor/Signature/KeyInfo/X509Data/X509Certificate/text()</XPath>
        </Variable>
    </XMLPayload>
</ExtractVariables>

@Pranay Aitha , Have you set content-type : application/xml header in your request ?

You are not considering the XML Namespaces in the XPath. Your XPath expression will not work without namespaces that refer to those used in the original document.

This ought to work:

<ExtractVariables name='Extract-1'>
    <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
    <Source clearPayload="false">msCert.content</Source>
    <VariablePrefix>ms</VariablePrefix>
    <XMLPayload stopPayloadProcessing="false">
      <Namespaces>
        <Namespace prefix='saml'>urn:oasis:names:tc:SAML:2.0:metadata</Namespace>
        <Namespace prefix='sig'>http://www.w3.org/2000/09/xmldsig#</Namespace>
      </Namespaces>
        <Variable name="cert" type="string">
            <XPath>/saml:EntityDescriptor/sig:Signature/sig:KeyInfo/sig:X509Data/sig:X509Certificate/text()</XPath>
        </Variable>
    </XMLPayload>
</ExtractVariables>

Thank you @Dino, Adding the Namespaces fixed the issue.

thank you Anil, I am passing the Header as application/xml.