【发布时间】:2009-05-13 19:41:10
【问题描述】:
在过去的几个小时里,我一直在碰壁,这就是我们正在尝试做的事情:一个方法需要一个原始/简单类型作为请求主体。最初我们尝试使用布尔值,但这不起作用,所以我们尝试使用字符串和对象。一样的。
这是服务器端代码
[OperationContract]
[WebInvoke(UriTemplate = "/foo/{foo_id}/bar", Method = "POST", ResponseFormat=WebMessageFormat.JSON)]
string G(string foo_id, string content);
这是 Fiddler 中的请求:
标题:
User-Agent: Fiddler
Host: localhost
Content-Type: 'application/json',
Content-Length: 19
主体:
"hello_world"
我们尝试将 "hello_world" 包装在 json 对象中,例如 {"content":"hello_world"} 但没有成功。
有什么想法吗?
【问题讨论】:
-
忘了提及行为:如果我在方法中放置断点,它不会被命中。相反,我只是收到一个 400 错误返回给 Fiddler。
标签: wcf json rest primitive-types