从Web服务返回一个的XElement [英] Returning an XElement from a web service
问题描述
是否有可能从一个web服务返回的XElement(在C#/ asp.net)?
Is it possible to return an XElement from a webservice (in C#/asp.net)?
尝试返回一个的XElement一个简单的Web服务:
Try a simple web service that returns an XElement:
[WebMethod]
public XElement DoItXElement()
{
XElement xe = new XElement("hello",
new XElement("message", "Hello World")
);
return xe;
}
这编译正常,但如果你尝试运行它,你会得到
This compiles fine but if you try and run it you get
Cannot use wildcards at the top level of a schema.
我发现这篇文章暗示,这是一个错误在.net中。
所以...我可以从Web服务返回的XElement?如果是这样,怎么样?
So... Can I return an XElement from a web service? If so, how?
感谢。
推荐答案
有似乎是用的XElement是如何序列化的问题,检查的这里 ...
There appears to be an issue with how an XElement is serialized, check here...
您可以尝试郊游的XElement作为一个字符串或作为文章建议你可以只使用一类包装,里面放上你的XElement。如果点是输出你会返回一个字符串被卡在通用格式的数据。
You can try outing the XElement as a string or as the article suggests you could just use a class wrapper and place your XElement inside. If the point is to output the data in a universal format you'll be stuck with returning a string.
这篇关于从Web服务返回一个的XElement的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!