// Service file
[WebInvoke(UriTemplate = "Send/{country}", Method = "POST")]
public int Send(IFoo item, string country)
// Interface file
public interface IFoo
{
string firstMember { get; set; }
string secondMember { get; set; }
}
// Implementation file
public class FooImpl : IFoo
{
string specificMember { get; set; }
}
我通过http://example.com/MyService/Send/ {COUNTRY}/上的帖子调用我的 REST 服务,
我希望能够将 IFoo 实现作为 text/xml 参数提供,例如:
<FooImpl xmlns="http://schemas.datacontract.org/2004/07/Hello">
<firstMember>Hello</firstMember>
<secondMember>World</secondMember>
<SpecificMember>!</SpecificMember>
</FooImpl>
当我在 Send 方法声明中声明 FooImpl 类型时它可以工作,但当我使用 IFoo 类型时它不起作用。(错误 400:错误请求)
服务助手显示:
<anyType xmlns:d1="http://www.w3.org/2001/XMLSchema" i:type="d1:schema" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2003/10/Serialization/" />
所以,我不知道这是我参数中的xml问题还是实现问题......