Retrieving metadata from SOAP Wrapper

Post Reply
ezninnovation
Newbie
Posts: 4
Joined: Tue May 14, 2024 8:46 pm

Retrieving metadata from SOAP Wrapper

Post by ezninnovation »

I am having trouble retrieving metadata from a xml returned with the SOAP wrapper. Specifically, I am trying to retrieve a PDF file from a URL that is in the XML. When I use the "Define single-line text with variables" it returns a null value after digging down into the XML tree. I tested with a non SOAP xml and it returns the variable correctly. I have tried with a http request and with an inject job module.
User avatar
magnussandstrom
Advanced member
Posts: 443
Joined: Thu Jul 30, 2020 6:34 pm
Location: Sweden
Contact:

Re: Retrieving metadata from SOAP Wrapper

Post by magnussandstrom »

Hi, I tried to pickup a SOAP-wrapped XML with XML pickup and I'm getting a similar result as you.

To fix this I used the Saxon-app to convert the SOAP-xml to a generic XML using XSLT.

I use ChatGPT to create the XSLT-code.

This is an example of the XSLT that works in my case:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                xmlns:int="urn:microsoft-dynamics-schemas/codeunit/IntegrationV1"
                exclude-result-prefixes="soapenv int">

    <!-- Match the root of the document -->
    <xsl:template match="/soapenv:Envelope">
        <!-- Apply templates to the Body node -->
        <xsl:apply-templates select="soapenv:Body"/>
    </xsl:template>

    <!-- Match the Body node -->
    <xsl:template match="soapenv:Body">
        <!-- Apply templates to the inRequestXML node containing CDATA -->
        <xsl:apply-templates select="int:PlaceOrder/int:inRequestXML"/>
    </xsl:template>

    <!-- Match the inRequestXML node containing CDATA -->
    <xsl:template match="int:inRequestXML">
        <!-- Use xsl:value-of to extract and process the CDATA content as XML -->
        <xsl:value-of select="." disable-output-escaping="yes"/>
    </xsl:template>

</xsl:stylesheet>
freddyp
Advanced member
Posts: 1077
Joined: Thu Feb 09, 2012 3:53 pm

Re: Retrieving metadata from SOAP Wrapper

Post by freddyp »

Without seeing it the most likely explanation I can think of is that the XPath is not correct because you did not include the namespace prefix. Please share the SOAP XML and the XPath to extract the URL to the PDF so I can judge.

If you prefer the approach suggested by Magnus, then know that you can also do that with the default "XSLT transform" app. Saxon is only required if you have to do stuff with XSL2.0.
Post Reply