0
I am building a Webservice that returns status of an object, so I get the data of the object to search in the base via SOAP message:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:agr="http://site.temp.br/">
<soapenv:Header/>
<soapenv:Body>
<agr:getObjeto_V1>
<arg0>
<TipoObjeto>C</TipoObjeto>
<CodigoObjeto>999999</CodigoObjeto>
<Valor>9999999999999</Valor>
<NomeObjeto>xxxxxxxxxxxx</NomeObjeto>
</arg0>
</agr:getObjeto_V1>
</soapenv:Body>
</soapenv:Envelope>
This is the Soap message sent to the webservice, in the service I take this message quietly, but, I’m picking up a little bit to get the values of the nodes that are inside the arg0 node, I’m trying so:
XmlDocument xml = new XmlDocument();
xml.LoadXml(xmlSoapRequest.InnerXml);
XmlNodeList xnList = xml.SelectNodes("/Envelope/Body/getObjeto_V1/arg0");
foreach (XmlNode xn in xnList)
{
char TipoObjeto = (char)xn["TipoObjeto"].InnerText[0];
string CodigoObjeto = xn["CodigoObjeto"].InnerText;
string valor = xn["Valor"].InnerText;
string NomeObjeto = xn["NomeObjeto"].InnerText;
}
How can I do that? If there is another way where I don’t need to manually select attributes, but do the conversion directly to a class, I also accept.
It would not be an option to work with serialization and deserialization of your Xml https://answall.com/a/44245/5846 https://answall.com/q/13087/5846
– Pablo Tondolo de Vargas