I read this and other forums for several hours and days and could not find a solution for my answer to the soap. I tried all kinds of answers here, but could not parse my answer :(
my answer:
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<getLocationsResponse xmlns="http://getlocations.ws.hymedis.net">
<locs>
<loc>
<name>Zeebrugge Wielingen Zand</name>
<abbr>ZWZ</abbr>
<RDX>1435.8</RDX>
<RDY>378678.6</RDY>
<params>
<param>GHs</param>
<param>SS10</param>
</params>
</loc>
</locs>
</getLocationsResponse>
</soapenv:Body>
</soapenv:Envelope>
My C # code is still (param soapresponse is the whole soapresponse in string format), my answer is correct, so the full answer is xml soap, but cannot parse it well
public void readXml(string soapresponse){
XmlDocument xmlresponse = new XmlDocument();
xmlresponse.LoadXml(soapresponse);
XmlNamespaceManager nsmanager = new XmlNamespaceManager(xmlresponse.NameTable);
nsmanager.AddNamespace ("soapenv", "http://schemas.xmlsoap.org/soap/envelope/");
XmlNodeList nodes = xmlresponse.SelectNodes("/soapenv:Envelope/soapenv:Body/getLocationsResponse/locs/loc", nsmanager);
List<Locatie> locatielijst = new List<Locatie>();
foreach(XmlNode node in nodes){
string loc_naam = node["name"].InnerText;
string loc_code = node["abbr"].InnerText;
...
Locatie locatie = new Locatie();
locatie.loc_naam = loc_naam;
locatie.loc_code = loc_code;
...
locatielijst.Add (locatie);
}
Console.WriteLine(locatielijst.Count.ToString());
foreach(Locatie loc in locatielijst){
Console.WriteLine (loc.loc_code);
}
}
but every time my .count list returns 0 -> so there is no data in them. Plz help me!
source
share