Obtener los datos XML de un Documento SOAP

Enero 09, 2009 :: Posted by - Emilio Torrens :: Category - , ,

Mas de mi servicio "impersonal" …

Resulta que ahora también recibe documentos SOAP, así que tengo que extraer los datos del mensaje SOAP con este código:

private XmlDocument GetSOAPBody(XmlDocument xmlSoap)
    {

              const string SOAP_NAMESPACE = "http://schemas.xmlsoap.org/soap/envelope/";
              XmlNodeList nodes = xmlSoap.GetElementsByTagName("Body", SOAP_NAMESPACE);

          if (nodes.Count == 0) return xmlSoap;

          XmlElement body = (XmlElement)nodes.Item(0);

          nodes = body.ChildNodes;
          for (int i = 0; i < nodes.Count; i++)
          {
              XmlNode node = nodes.Item(i);
              if (node is XmlElement)
              {
                  xmlSoap = new XmlDocument();
                  xmlSoap.LoadXml(node.OuterXml);
                  IsSOAP = true;
                  return xmlSoap;
              }
          }

          return xmlSoap;
      }  

Funciona bastante bien, ahora estoy con el de generar las respuestas de OK y de Error, ya lo publicare :)

Si te gusta compartelo ...
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • DotNetKicks
  • Live
  • MySpace
  • Meneame
  • Twitter

Tags: , ,

Leave a Reply