0

我在.net 中有一个非常简单的网络服务

[WebInvoke(Method = "POST",
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "xml?id={id}")]

string XMLData(string id);

当我通过传递以下 URL 在 Fiddler 中检查它时,它工作正常

http://localhost:60104/IO_100_Service.svc/xml?id=123}

但是当我在提琴手的请求正文中传递参数时,它不起作用

URL
http://localhost:60104/IO_100_Service.svc/xml

Request Header
Content-Type: application/x-www-form-urlencoded

Request Body
id=123

如果有人对此有任何想法,请帮助我。

4

1 回答 1

1

You have specified URI template for your paramerter, threrfore to call this method you should request exactly that URL with parameter in it.

You can pass additionaly some data in body. But with such URI template paramter also should be passed through URI.

When you want you can change URI template and pass your data only on body

于 2012-04-21T19:55:44.250 回答