【问题标题】:How to enable WCF Service Discovery when using file-less activation?使用无文件激活时如何启用 WCF 服务发现?
【发布时间】:2011-04-20 06:01:54
【问题描述】:

G'day 伙计们,

在使用 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>

【问题讨论】:

  • 服务是否在运行? (即您可以浏览服务页面吗)

标签: wcf activation service-discovery


【解决方案1】:

尝试将此添加到 web.config。

<behaviors>
  <serviceBehaviors>
    <behavior name="">
      <serviceMetadata httpGetEnabled="True"/>
      <serviceDebug includeExceptionDetailInFaults="False"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

【讨论】:

  • 哈!不,我很确定我的服务行为名称空字符串不会解决我的问题...
【解决方案2】:

这个问题已经有一年了,但为了其他可能有这个问题的人,这里是答案:

尽管您使用的是 WCF 无文件激活,但您仍然需要在您的 system.serviceModel 配置部分中添加一个 services 节点,因为您需要将发现端点显式添加到您希望使其可发现的每个服务。

<services>
  <service name="RegistrationService">
    <endpoint binding="wsHttpBinding" contract="IRegistrationService"/>
    <endpoint kind="udpDiscoveryEndpoint"/>
  </service>
</services>

上述配置 sn-p 将为您的 RegistrationService 添加一个发现端点(我假设您有一个名为 IRegistrationService 的显式服务合同)。

另请注意,为 RegistrationService 添加服务配置节点后,您将需要显式添加任何数据端点。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-04-15
    • 2020-01-04
    • 2015-01-06
    • 1970-01-01
    • 1970-01-01
    • 2012-01-01
    相关资源
    最近更新 更多