如何在使用无文件激活时启用WCF服务发现?

时间:2010-10-02 14:04:09

标签: wcf activation service-discovery

G'day伙计们,

在使用WCF的无文件服务激活时,如何启用服务发现?使用这种方法,似乎无法指定显式端点类型或behaviorConfiguration?

我目前的尝试如下,但服务发现仍无效:

<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>

2 个答案:

答案 0 :(得分:0)

尝试将此添加到web.config。

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

答案 1 :(得分:0)

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

尽管您正在使用WCF无文件激活,但您仍需要services配置部分中的system.serviceModel节点,因为您需要将发现端点明确添加到您希望制作的每个服务中可被发现的

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

上面的配置代码段会将一个发现端点添加到您的RegistrationService(我假设您有一个名为IRegistrationService的明确服务合同)。

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