【发布时间】:2012-08-06 05:46:43
【问题描述】:
按照下面的代码 sn-p,我有一个 WCF Rest 服务
[ServiceContract]
public interface IService
{
[OperationContract]
[WebInvoke(UriTemplate="/SaveList/Foos/",Method="POST")]
bool SaveList(List<Foo> myFoos);
}
该服务是自托管服务,并使用 webHttpBinding 公开一个端点。我有一个客户端控制台应用程序,它具有以下代码 sn-p:
public void Send()
{
var myObj = new Foo{Id=1, Name="Test"};
using (WebChannelFactory<OurService.Services.IOurService> cf = new WebChannelFactory<IOurService>("WebHttpBinding_IService"))
{
IUtranetService channel = cf.CreateChannel();
using (new OperationContextScope(channel as IContextChannel))
{
var status = channel.SaveList(new[] { myObj });
}
}
}
客户端代码抛出异常如下: 在“http://localhost:1133/Service/SaveList”处没有可以接受消息的端点侦听。
我不确定我哪里出错了。如果我从服务合同中删除 UriTemplate,客户端会返回正确的响应。
任何帮助将不胜感激。
问候 鲁奇特拉
【问题讨论】:
-
你不需要 method=post - webinvoke 已经是一个帖子
-
但删除 method=post 并不能解决问题。我在这里做错什么了吗?
标签: wcf rest uritemplate webchannelfactory