Search code examples
xmlweb-servicessharepoint-2010xml-parsingnintex-workflow

Parsing XML - Get value from XML tree


I am using Nintex workflow. I added Web Service and configured to retrieve data from GetUserProfile.asmx. After adding the web service nintex let you see how would the soap look like. here is the soap.

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
        <GetUserPropertyByAccountName xmlns="http://microsoft.com/webservices/SharePointPortalServer/UserProfileService">
            <accountName>{WorkflowVariable:tmpApprover}</accountName>
            <propertyName>PreferredName</propertyName>
        </GetUserPropertyByAccountName>
    </soap:Body>
</soap:Envelope>

Nintex also let you see how the Results looks like in xml:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <GetUserPropertyByAccountNameResponse xmlns="http://microsoft.com/webservices/SharePointPortalServer/UserProfileService">
      <GetUserPropertyByAccountNameResult>
        <IsPrivacyChanged>false</IsPrivacyChanged>
        <IsValueChanged>false</IsValueChanged>
        <Name>PreferredName</Name>
        <Privacy>Public</Privacy>
        <Values>
          <ValueData>
            <Value xsi:type="xsd:string">Holmberg, Nancy</Value>
          </ValueData>
        </Values>
      </GetUserPropertyByAccountNameResult>
    </GetUserPropertyByAccountNameResponse>
  </soap:Body>
</soap:Envelope> 

The I added a "Query XML" and tried some variation of xpath to the PreferredName from user Profile database and it's giving me "falsefalsePreferredNamePublicHolmberg, Nancy".

Here are some of the code I tried

/soap:Envelope/soap:Body/defaultNS:GetUserPropertyByAccountNameResponse/defaultNS:GetUserPropertyByAccountNameResult/defaultNS:Values/defaultNS:ValueData/defaultNS:Value/@xsi:type

or

//defaultNS:xml/defaultNS:Values/defaultNS:ValueData/defaultNS:Value

or

//defaultNS:xml/defaultNS:Name

or

//@PreferredName 

But they all give me falsefalsePreferredNamePublicHolmberg, Nancy. I should give me Holmberg, Nancy.

Please suggest.


Solution

  • I followed this and it solved the issue.

    if your variable which contains the xml is called textXML, in your Query XML action you could then insert a reference to the workflow variable and it'd look like this:

    <xml xmlns="http://microsoft.com/webservices/SharePointPortalServer/UserProfileService">
      {WorkflowVariable:textXML}
    
    </xml>