我已经写了方法契约:
[OperationContract]
[WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Xml, UriTemplate = "TestEchoWithTemplate/{message}", BodyStyle = WebMessageBodyStyle.Bare)]
string TestEchoWithTemplate(string s);
以及实现方法:
public string TestEchoWithTemplate(string s)
{
return "You said " + s;
}
当我浏览到 URL 时:
http://localhost:52587/VLSContentService.svc/rest/TestEchoWithTemplate/HelloWorld
我收到以下错误:
合同“IVLSContentService”中的操作“TestEchoWithTemplate”有一个 UriTemplate,它需要一个名为“MESSAGE”的参数,但操作中没有具有该名称的输入参数。
以下产生相同的错误:
http://localhost:52587/VLSContentService.svc/rest/TestEchoWithTemplate/MESSAGE=HelloWorld http://localhost:52587/VLSContentService.svc/rest/TestEchoWithTemplate?MESSAGE=HelloWorld
我究竟做错了什么?