// 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; }
}
我打電話給我的REST的服務與後上http://example.com/MyService/Send/ {COUNTRY}/
我希望能夠給一個IFoo的實現像文本/ XML參數:如何使用WCF REST公開接口?
<FooImpl xmlns="http://schemas.datacontract.org/2004/07/Hello">
<firstMember>Hello</firstMember>
<secondMember>World</secondMember>
<SpecificMember>!</SpecificMember>
</FooImpl>
它當我在發送方法聲明中聲明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問題...
好的,謝謝你的幫助! – Spilarix 2011-04-20 05:31:16
您是否找到解決方案? – Spilarix 2011-05-12 06:08:57
@Spilarix我做了一些實驗,包括一些可怕的代碼,以修改設置注入數據合約序列化程序。這並沒有達到預期的效果。不幸的是我到目前爲止還沒有能夠進一步調查:( – Thorarin 2011-05-12 09:14:52