我已經創建了一個方法的WCF服務,它返回一個System.Xml.XmlElement
:VS2010將System.Xml.XmlElement與System.Xml.Linq.XElement混淆?
接口:
[ServiceContract]
public interface IWCFService
{
[OperationContract]
XmlElement Execute(...);
}
服務:
public XmlElement Execute(...)
{
XmlNode node = ...;
return (XmlElement)node;
}
當我嘗試訪問該服務部署在我的服務器上
WCFServiceClient service = new WCFServiceClient("WSHttpBinding_IWCFService");
XmlElement node = service.Execute(...);
我得到的錯誤:
Cannot implicitly convert type 'System.Xml.Linq.XElement' to 'System.Xml.XmlElement'
搜索我的服務解決方案,我看不到任何參考System.Xml.Linq.XElement
。我期望得到System.Xml.XmlElement
還是VS 2010與我混戰?
嘗試使用wcftestclient.exe調用服務。你有任何錯誤? – 2010-05-18 09:32:56
@Raj:這是不可能的,因爲'wcftestclient'不支持'System.Xml.XmlElement'。但有趣的是,它沒有提及任何有關'System.Xml.Linq.XmlElement'的內容。 – Chau 2010-05-18 09:48:11
看看這篇文章是否有幫助:http://social.msdn.microsoft。com/Forums/zh-CN/wcf/thread/2f29bdab-a3ab-41b9-980a-692e7bb7e133 – 2010-05-18 10:43:07