申请机构应该如何?

时间:2009-03-17 11:16:54

标签: wcf json request fiddler

我有一个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;
}

我正在尝试使用Fiddler向该方法发出请求,但无法理解正确的Request Body应该是什么。如果效果更好,我可以将Dictionary参数更改为其他参数。

在请求标题中,我通过了:

  

User-Agent:Fiddler
  Content-Type:application / json;字符集= UTF-8

我应该把什么放在体内?

1 个答案:

答案 0 :(得分:7)

我认为这就是你所追求的目标。

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

字典序列化为键值数组。