使用无文件激活时如何启用 WCF 服务发现?
大家好,
在使用 WCF 的无文件服务激活时,如何启用服务发现?使用这种方法似乎不可能指定显式端点类型或行为配置?
我当前的尝试如下,但服务发现仍然无法正常工作:
<bindings>
<wsHttpBinding>
<binding name="Default" transactionFlow="true">
<security mode="Transport">
<transport clientCredentialType="None">
</transport>
</security>
</binding>
</wsHttpBinding>
</bindings>
<protocolMapping>
<clear/>
<add scheme="https" binding="wsHttpBinding" bindingConfiguration="Default" />
</protocolMapping>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceDiscovery/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior>
<endpointDiscovery enabled="true">
<scopes>
<add scope="http://XPS/MvcApplication/Service/"/>
</scopes>
</endpointDiscovery>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true">
<serviceActivations>
<add service="RegistrationService" factory="Core.ServiceModel.Activation.ServiceHostFactory" relativeAddress="RegistrationService.svc" />
<add service="EventService" factory="Core.ServiceModel.Activation.ServiceHostFactory" relativeAddress="EventService.svc" />
<add service="ShoppingService" factory="Core.ServiceModel.Activation.ServiceHostFactory" relativeAddress="ShoppingService.svc" />
</serviceActivations>
</serviceHostingEnvironment>
G'day guys,
How do I go about enabling service discovering when using WCF's file-less service activation? With this approach it doesn't seem possible to specify explicit endpoint types or a behaviorConfiguration?
My current attempt is as follows but service discovery still is not working:
<bindings>
<wsHttpBinding>
<binding name="Default" transactionFlow="true">
<security mode="Transport">
<transport clientCredentialType="None">
</transport>
</security>
</binding>
</wsHttpBinding>
</bindings>
<protocolMapping>
<clear/>
<add scheme="https" binding="wsHttpBinding" bindingConfiguration="Default" />
</protocolMapping>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceDiscovery/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior>
<endpointDiscovery enabled="true">
<scopes>
<add scope="http://XPS/MvcApplication/Service/"/>
</scopes>
</endpointDiscovery>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true">
<serviceActivations>
<add service="RegistrationService" factory="Core.ServiceModel.Activation.ServiceHostFactory" relativeAddress="RegistrationService.svc" />
<add service="EventService" factory="Core.ServiceModel.Activation.ServiceHostFactory" relativeAddress="EventService.svc" />
<add service="ShoppingService" factory="Core.ServiceModel.Activation.ServiceHostFactory" relativeAddress="ShoppingService.svc" />
</serviceActivations>
</serviceHostingEnvironment>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试将其添加到 web.config 中。
Try adding this to the web.config.
这个问题已经有一年了,但为了其他可能有这个问题的人,这里是答案:
尽管您使用的是 WCF 无文件激活,但您的
中仍然需要一个
配置部分,因为您需要将发现端点显式添加到您希望使其可发现的每个服务。services
节点system.serviceModel上面的配置片段将向您的 RegistrationService 添加一个发现端点(我假设您有一个名为 IRegistrationService 的显式服务契约)。
另请注意,通过为 RegistrationService 添加服务配置节点,您将需要显式添加任何数据端点。
This question is a year old but for the sake of others who may have this question here's the answer:
Dispite the fact that you are using WCF fileless activation, you still need a
services
node in yoursystem.serviceModel
configuration section because you are required to explicitly add the discovery endpoint to each service you wish to make discoverable.The above configuration snippet will add a discovery endpoint to your RegistrationService (I'm assuming you have an explicit service contract named IRegistrationService).
Note also, with the addition of a service configuration node for the RegistrationService you will need to add any data endpoints explicitly.