C# 为什么在';获取';惯性导航与制导?
我已经编写了方法合同:C# 为什么在';获取';惯性导航与制导?,c#,wcf,rest,uritemplate,C#,Wcf,Rest,Uritemplate,我已经编写了方法合同: [OperationContract] [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Xml, UriTemplate = "TestEchoWithTemplate/{message}", BodyStyle = WebMessageBodyStyle.Bare)] string TestEchoWithTemplate(string s); 以及实施方法: public
[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时:
我得到以下错误:
中的操作“TestEchoWithTemplate”
合同“IVLSContentService”具有
需要参数的模板
名为“MESSAGE”,但没有输入
参数上具有该名称的
手术
以下操作会产生相同的错误:
http://localhost:52587/VLSContentService.svc/rest/TestEchoWithTemplate?MESSAGE=HelloWorld
我做错了什么?将模板定义为
"TestEchoWithTemplate/{s}"
因为您的方法使用了s
而不是消息
。或者在界面中将名称更改为消息
:
[OperationContract]
[WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Xml, UriTemplate = "TestEchoWithTemplate/{message}", BodyStyle = WebMessageBodyStyle.Bare)]
string TestEchoWithTemplate(string message);