【发布时间】:2011-07-05 10:29:52
【问题描述】:
我的 soap 服务收到一个 XML,我需要先将 soap 信封添加到 xml,然后再将它发送到 HTTP 服务,我在 行 httpDocumet.DocumentElement.AppendChild(xml.DocumentElement);
如何在我的 xml 中附加肥皂标题?
[WebMethod]
public XmlDocument HelloWorld(XmlDocument xml)
{
XmlDocument httpDocumet = new XmlDocument();
XmlElement soapEnvelope = httpDocumet.CreateElement("soap", "Header", "http://schemas.xmlsoap.org/soap/envelope/");
soapEnvelope.SetAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
soapEnvelope.SetAttribute("xmlns:xsd", "http://www.w3.org/2001/XMLSchema");
httpDocumet.AppendChild(soapEnvelope);
XmlElement soapBody =httpDocumet.CreateElement("soap", "Body", "http://schemas.xmlsoap.org/soap/envelope/");
httpDocumet.DocumentElement.AppendChild(soapBody);
httpDocumet.DocumentElement.AppendChild(xml.DocumentElement);
错误消息
System.Web.Services.Protocols.SoapException: 服务器无法处理请求。 ---> System.ArgumentException: 要插入的节点来自 不同的文档上下文。在 System.Xml.XmlNode.AppendChild(XmlNode newChild) 在 WebService1.Service1.HelloWorld(XmlDocument xml)
【问题讨论】:
标签: c# .net asp.net web-services