Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/301.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 为什么在';获取';惯性导航与制导?_C#_Wcf_Rest_Uritemplate - Fatal编程技术网

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);