2

伙计们,

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

2 回答 2

0

尝试将此添加到 web.config。

<behaviors>
  <serviceBehaviors>
    <behavior name="">
      <serviceMetadata httpGetEnabled="True"/>
      <serviceDebug includeExceptionDetailInFaults="False"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
于 2010-12-23T05:04:57.847 回答
0

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

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

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

上面的配置片段将向您的 RegistrationService 添加一个发现端点(我假设您有一个名为 IRegistrationService 的显式服务合同)。

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

于 2012-01-16T15:55:53.570 回答