cancel
Showing results for 
Search instead for 
Did you mean: 

Getting a specific value from an XML WebService response (HCI)

Former Member
0 Kudos

Hi experts,

I need your help to figure out know how to get a specific value from a tag coming from an XML WebService response.

This is a part of the response I get after calling w web service,

The value which I need are the serverUrl and the sessionId.

The first thing came to my mind is to use a Content Modifier with the following header parameters

but unfortunately I receive empty values.

Although it makes no sense I tried also with /result/serverUrl/@Value, /serverUrl/@Value.

I need these values to use them as input values to another web service and pass an SQL query to get data from it.

Thanks in advance.

BR.

Accepted Solutions (1)

Accepted Solutions (1)

bhavesh_kantilal
Active Contributor
0 Kudos

Hello Mohammed Amine,

Apart from what Eng Swee has mentioned, what I have noticed is that the SFDCresponse xml contains the namespace prefix: xmlns="urn:partner.soap.sforce.com" and this seems to cause an issue in HCI. This seems to be a bug but I am not too sure.

I had to write a XSLT Mapping to remove XML Namespace prefix post which the same works.

Below is the XSLT Mapping before my Content Modifier step to remove the XML Namespaces.


<?xml version="1.0"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:output indent="yes" method="xml" encoding="utf-8" omit-xml-declaration="yes"/>

    <!-- Stylesheet to remove all namespaces from a document -->

    <!-- NOTE: this will lead to attribute name clash, if an element contains

        two attributes with same local name but different namespace prefix -->

    <!-- Nodes that cannot have a namespace are copied as such -->

    <!-- template to copy elements -->

    <xsl:template match="*">

        <xsl:element name="{local-name()}">

            <xsl:apply-templates select="@* | node()"/>

        </xsl:element>

    </xsl:template>

    <!-- template to copy attributes -->

    <xsl:template match="@*">

        <xsl:attribute name="{local-name()}">

            <xsl:value-of select="."/>

        </xsl:attribute>

    </xsl:template>

    <!-- template to copy the rest of the nodes -->

    <xsl:template match="comment() | text() | processing-instruction()">

        <xsl:copy/>

    </xsl:template>

</xsl:stylesheet>

Regards,

Bhavesh

Answers (3)

Answers (3)

isudoajl
Participant
0 Kudos

Hello,
This is a request that comes with an xml, How can I get the value of <ubiNum> when it has a namespace assigned? If I remove the "NumberToWords" namespace and put in value //ubiNum it works. In the image, it returns an empty value. Can someone tell me what is the correct way to access a value that is assigned a namespace?

Thank you!

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <NumberToWords xmlns="http://www.dataaccess.com/webservicesserver/">
      <ubiNum>10257</ubiNum>
    </NumberToWords>
  </soap:Body>
</soap:Envelope>

Former Member
0 Kudos

Thank you all for your quick answers both of them were helpful, the problem is resolved, as there was a problem with the XML Namespace prefix as Bhavesh Kantilal said and using the script I was able to remove it and I got the results without using @Value.

Thanks again.

BR.

Mohammed Amine.

engswee
Active Contributor
0 Kudos

Hi Mohammed Amine

XPaths doesn't need the @Value part. So just use

/loginResponse/result/serverUrl

/loginResponse/result/sessionId

Check out a similar approach that I've covered in my following blog. The XPath stuff is in step 2.

Regards

Eng Swee