为什么在';获取';ing
本文关键字:ing 获取 为什么 | 更新日期: 2023-09-27 17:59:41
我已经写了方法合同:
[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
我得到以下错误:
中的操作"TestEchoWithTemplate"合同"IVLSContentService"具有需要参数的UriTemplate名为"MESSAGE",但没有输入上具有该名称的参数活动
以下会产生相同的错误:
http://localhost:52587/VLSContentService.svc/rest/TestEchoWithTemplate/MESSAGE=HelloWorldhttp://localhost:52587/VLSContentService.svc/rest/TestEchoWithTemplate?MESSAGE=HelloWorld
我做错了什么?
将模板定义为
"TestEchoWithTemplate/{s}"
由于您的方法具有s
而不是message
。或者,在您的界面中将名称更改为message
:
[OperationContract]
[WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Xml, UriTemplate = "TestEchoWithTemplate/{message}", BodyStyle = WebMessageBodyStyle.Bare)]
string TestEchoWithTemplate(string message);