web.config应该在以下哪个代码块中使用WCF RESTful服务?
<endpoint address="" binding="webHttpBinding"contract="Wcf_Test.IMyService"
behaviorConfiguration="httpEndpointBehavour">
<identity>
<dns value="localhost"/>
<Identity>
</endpoint>
Run Code Online (Sandbox Code Playgroud)
和
<behaviors>
<serviceBehaviors>
<behavior name="httpBehaviour"> <serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False"/>
</behavior>
</serviceBehaviors>
Run Code Online (Sandbox Code Playgroud)
和
<endpointBehaviors>
<behavior name="httpEndpointBehavour">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
Run Code Online (Sandbox Code Playgroud) 尽管阅读了很多帖子,例如(这个似乎很受欢迎)我似乎无法将我的服务作为多个端点公开,这些端点兼容SOAP和REST协议 - 我的问题似乎与
Factory="System.ServiceModel.Activation.WebServiceHostFactory"
Run Code Online (Sandbox Code Playgroud)
后台服务代码中的元素.
如果我将其删除,我的SOAP端点工作正常,但找不到我的JSON端点.如果我将该行放入,我的REST端点会像鸟一样唱歌,而SOAP端点会导致Service.svc页面上出现"Endpoint not found".
我的操作似乎以标准方式设置,例如:
[OperationContract]
[WebGet(UriTemplate = "/GetData", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
string GetData();
Run Code Online (Sandbox Code Playgroud)
和配置文件
<endpoint address="rest" binding="webHttpBinding" contract=".IMeterService" behaviorConfiguration="REST" />
<endpoint address="soap" binding="wsHttpBinding" contract="IMeterService" bindingConfiguration="secureBasic" />
<behavior name="REST">
<webHttp />
</behavior>
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?有没有办法在没有 System.ServiceModel.Activation.WebServiceHostFactory属性的情况下设置REST端点?
提前致谢.