Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.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
Wcf 设置服务路由时是否可以设置默认操作_Wcf_Rest - Fatal编程技术网

Wcf 设置服务路由时是否可以设置默认操作

Wcf 设置服务路由时是否可以设置默认操作,wcf,rest,Wcf,Rest,我正在评估使用WCF设置REST系统与使用MVC(我目前拥有)的情况。我已经让它运行了,但是我希望能够复制一些我通过MVC获得的功能 也就是说,我需要能够指定相当于“默认操作”的WCF。虽然ServiceRoute有一个defaults属性,但我还没有找到任何关于在这里设置什么的文档(假设它甚至在WCF中使用) 我可以看到,下一步将是编写自己的服务主机工厂,并拥有一个自定义属性,但这需要一步,因为我已经在使用Autofac来DI服务依赖项 是否可以通过WCF与REST签订默认的“运营合同” 好的

我正在评估使用WCF设置REST系统与使用MVC(我目前拥有)的情况。我已经让它运行了,但是我希望能够复制一些我通过MVC获得的功能

也就是说,我需要能够指定相当于“默认操作”的WCF。虽然ServiceRoute有一个defaults属性,但我还没有找到任何关于在这里设置什么的文档(假设它甚至在WCF中使用)

我可以看到,下一步将是编写自己的服务主机工厂,并拥有一个自定义属性,但这需要一步,因为我已经在使用Autofac来DI服务依赖项


是否可以通过WCF与REST签订默认的“运营合同”

好的,我觉得有点愚蠢,因为WebGet属性中的URI模板满足了我的需要,即:

[OperationContract]
[WebGet(BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, UriTemplate = "{id}")]
User GetUser(String id);

为我的深夜编码服务。

好的,我觉得有点愚蠢,因为WebGet属性中的URI模板满足了我的需要,即:

[OperationContract]
[WebGet(BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, UriTemplate = "{id}")]
User GetUser(String id);

为我的深夜编码服务。

使用REST 4.0模板创建新项目包括以下内容:

[WebGet(UriTemplate = "")]
public List<SampleItem> GetCollection()
{
 // TODO: Replace the current implementation to return a collection of SampleItem instances
 return new List<SampleItem>() { new SampleItem() { Id = 1, StringValue = "Hello" } };
}
Uri Method                                       Description

GET Service at http://localhost:60888/Service1/

因此,默认的“操作”是使用空模板指定的操作。

使用REST 4.0模板创建新项目包括以下内容:

[WebGet(UriTemplate = "")]
public List<SampleItem> GetCollection()
{
 // TODO: Replace the current implementation to return a collection of SampleItem instances
 return new List<SampleItem>() { new SampleItem() { Id = 1, StringValue = "Hello" } };
}
Uri Method                                       Description

GET Service at http://localhost:60888/Service1/

因此,默认的“操作”是使用空模板指定的。

您还需要禁用该服务的WCF帮助页面-您还需要禁用该服务的WCF帮助页面-