6
如何从wcf服务返回xdocument?我需要做什么来让wxf服务的方法返回xdocument的对象?从wcf服务返回xdocument
如何从wcf服务返回xdocument?我需要做什么来让wxf服务的方法返回xdocument的对象?从wcf服务返回xdocument
你不能。 XDocument不实现IXmlSerializable。 XElement实现IXmlSerializable,因此您可以通过WCF传输它。
您也可以传输字符串而不是XDocument并在本地解析它。
例:
服务器:
public string DoSomething()
{
XDocument myXDocument = new XDocument();
// Do stuff
return myXDocument.ToString();
}
客户:
XDocument doc = XDocument.Parse(myWebService.DoSomething());
您也可以返回一个的XElement对象。
public XElement DoSomething()
{
XDocument myXDocument = new XDocument();
// Load the XDocument.
return myXDocument.Root;
}
50%的编程是找到正确的咒语。谢谢! – 2017-08-28 19:45:11