Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Soap response as:

<?xml version="1.0" encoding="utf-8"?>
<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>
    <TASIntegrationRequestResponse xmlns="http://tempuri.org/">
      <TASIntegrationRequestResult>
        <status>true</status>
        <resMsg>Profile integrated to TAS.</resMsg>
      </TASIntegrationRequestResult>
    </TASIntegrationRequestResponse>
  </soap:Body>
</soap:Envelope>


What I have tried:

I'm trying to read it as:

XmlNamespaceManager xmlnsManager = new System.Xml.XmlNamespaceManager(xmlDoc.NameTable);

xmlnsManager.AddNamespace("soap", "http://schemas.xmlsoap.org/soap/envelope/");
xmlnsManager.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
xmlnsManager.AddNamespace("xsd", "http://www.w3.org/2001/XMLSchema");
xmlnsManager.AddNamespace("si", "http://tempuri.org/");

// You'd access the full path like this
XmlNode node = xmlDoc.SelectSingleNode("/soap:Envelope/soap:Body/
si:TASIntegrationRequestResponse/si:TASIntegrationRequestResult/si.status", xmlnsManager);
string strstatus = node.InnerText;

But it's getting exception and it is not reading the status values.
Please help me.
Posted
Updated 27-May-20 5:59am
v3
Comments
MadMyche 27-May-20 10:55am    
How about telling us what the Exception is?

1 solution

When you want help with an exception, remember to include the full details of the exception you're trying to fix.

In this case, you're getting a NullReferenceException, because SelectSingleNode is returning null.

That's because you have an invalid XPath expression:
/soap:Envelope/soap:Body/si:TASIntegrationRequestResponse/si:TASIntegrationRequestResult/si.status
That final . should be a :
/soap:Envelope/soap:Body/si:TASIntegrationRequestResponse/si:TASIntegrationRequestResult/si:status
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900