【发布时间】:2014-03-10 20:59:34
【问题描述】:
我的 xml 看起来像:
<?xml version="1.0" encoding="UTF-8"?>
<items>
<item>1</item>
<item>2</item>
<item>3</item>
</items>
还有一份 wcf 服务合同:
[ServiceContract(Namespace = "", Name = "MyService", SessionMode = SessionMode.NotAllowed)]
public interface IMyService
{
[OperationContract]
[WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Xml, RequestFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Bare)]
void DoWork(IEnumerable<int> items);
}
服务绑定是基本的http。
但是当我尝试将该 xml 发布到 wcf 方法时,我收到了错误:
Unable to deserialize XML message with root name "items" and root namespace ""
wcf 方法应该如何正确使用该 xml?
【问题讨论】:
-
尝试获取服务的 WSDL。合同模式是否与您的 XML 匹配?
-
@MauriceStam 出于与问题stackoverflow.com/questions/21127021/… 相同的原因,我无法看到 wsdl。我只需要让服务了解我提供的 xml 格式
标签: c# .net xml web-services wcf