Web Service 中如何传递Xml文档

我现在是这样做的:
将一个Xml文档转换成string 然后在客户端再变成Xml文档
不知道Web Service 中是否可以直接传递Xml文档,如何传

---------------------------------------------------------------

http://blog.joycode.com/qqchen/archive/2004/04/15/19595.aspx
---------------------------------------------------------------

你可以直接传一个XmlNode
---------------------------------------------------------------

[WebService(Namespace="http://joycode.com/qqchen/webservices/")]
public class MyService : System.Web.Services.WebService
{
[WebMethod]
[SoapDocumentMethod(ParameterStyle=SoapParameterStyle.Bare)]
[return: XmlAnyElement]
public XmlElement SayXml(
[XmlAnyElement]
XmlElement param)
{
XmlDocument doc = new XmlDocument();
doc.LoadXml("

1<book genre="novel" isbn="1-861001-57-5">" +   
2"<title>Pride And Prejudice</title>" +   
3"</book>

");
return doc.DocumentElement;
}
}
---------------------------------------------------------------

>> 返回到客户端的是XmlNode
>> 不是XmlElement

其实是XmlNode[],XmlElement是从XmlNode继承的,通常返回的元素就是XmlElement,可以用GetType看到。
之所以用数组,是因为XmlAnyElement支持返回多个XmlNode。
---------------------------------------------------------------

http://dotnet.aspx.cc/ShowDetail.aspx?id=6381BD5F-51F3-4339-4239-1328564A1B2A

Published At
Categories with Web编程
Tagged with
comments powered by Disqus