我有它看起来像这样的方法的WCF服务(用于与调试测试返回null,我只关心获取数据在目前):

[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "fares", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)]
public List<Fare> GetFares(Dictionary<int, int> itineraries, decimal? threshold, bool includeInternational)
{
    return null;
}

我试图让使用提琴手该方法的请求,但无法回避我的头在正确的请求体应该是什么。我如果工作得更好的字典参数更改为别的东西。

在请求报头我通过:

  

的User-Agent:提琴手结果   内容类型:应用/ JSON;字符集= UTF-8

我应该把什么在身上?

有帮助吗?

解决方案

我觉得这是你所追求的。

{
"itineraries" : [{"Key":1,"Value":2},{"Key":2,"Value":3}],
"threshold" : 1.0,
"includeInternational" : true
}

在字典作为串行化的密钥值数组。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top