WCF/Rest/UriTemplate 变长查询字符串参数列表?
WCF 将匹配以下内容:
http://localhost:8888/test/blahFirst/blahSecond/sdfsdf, wwewe
对此:
[OperationContract]
[WebGet( UriTemplate = "test/{first}/{second}/{val1},{val2}" )]
string GetVal( string first, string second, string val1, string val2 );
有没有办法使 va11、val2 成为可变长度参数列表?那么它可能是 val1, ...., valN?最终得到一个服务方法,例如:
string GetVal( string first, string second, List<string> params );
或者类似的东西?
WCF will match this:
http://localhost:8888/test/blahFirst/blahSecond/sdfsdf,wwewe
to this:
[OperationContract]
[WebGet( UriTemplate = "test/{first}/{second}/{val1},{val2}" )]
string GetVal( string first, string second, string val1, string val2 );
Is there a way to make the va11, val2 be a variable length list of parameters? So it could be val1, ...., valN? And end up with a service method such as:
string GetVal( string first, string second, List<string> params );
Or something along those lines?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需获取一个简单的字符串,然后使用 split 方法将其转换为方法中的数组(或列表)即可。
您的界面应如下所示:
您的实现:
并在浏览器中这样称呼它:
查看 MSDN 论坛以获得详细答案
Just GET a simple string and then convert it to an Array (or a list) in the method, using the split method.
Your Interface should look something like this:
Your implementation:
And call it like this in your browser:
Take a look at the MSDN forum for a detailed answer