关于WCF的服务调用的问题

笑羽酣天 2010-02-21 12:20:15
问题,像如下例子,我有两个服务,模板几乎是完全一样(只是参数有些变化)
eg:
TestService实际请求的类似于 http://service.svc/abc?key1=value1
TestServiceRequired实际请求的类似于 http://service.svc/abc?key1=value1&key2=value2
这样的结果就回报错:
System.InvalidOperationException was unhandled by user code Message="UriTemplateTable does not support multiple templates that have equivalent path as template 'subscriptions?format=json' but have different query strings, where the query strings cannot all be disambiguated via literal values. See the documentation for UriTemplateTable for more detail." Source="System.ServiceModel.Web"

请问我要如何解决?

[OperationContract]
[WebGet(UriTemplate = "/abc")]
public List<string> TestService()
{

}
[OperationContract]
[WebGet(UriTemplate = "/abc")]
public List<string> TestServiceRequired()
{

}
...全文
110 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
xray2005 2010-02-21
  • 打赏
  • 举报
回复
换一下参数顺序,如:
TestService实际请求的类似于 http://service.svc/abc?key1=value1
TestServiceRequired实际请求的类似于 http://service.svc/abc?key2=value2&key1=value1


或者UriTemplate改一下,如:

[OperationContract]
[WebGet(UriTemplate = "/abc")]
public List<string> TestService()
{

}
[OperationContract]
[WebGet(UriTemplate = "/bcd")]
public List<string> TestServiceRequired()
{

}
笑羽酣天 2010-02-21
  • 打赏
  • 举报
回复
请教大虾啊。。。。~~!
笑羽酣天 2010-02-21
  • 打赏
  • 举报
回复
不行啊!
楼上的估计你还不懂这个吧
它判断UriTemplate是否一样只是判断里面 ? 以前的部分,至于后面的部分它不做比较的,老大。

12,162

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 Web Services
社区管理员
  • Web Services社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧