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

发布于 2024-09-26 00:09:21 字数 1758 浏览 6 评论 0原文

大家好,

在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烟雨扶苏 2024-10-03 00:09:21

尝试将其添加到 web.config 中。

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

Try adding this to the web.config.

<behaviors>
  <serviceBehaviors>
    <behavior name="">
      <serviceMetadata httpGetEnabled="True"/>
      <serviceDebug includeExceptionDetailInFaults="False"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
静若繁花 2024-10-03 00:09:21

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

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

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

上面的配置片段将向您的 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 your system.serviceModel configuration section because you are required to explicitly add the discovery endpoint to each service you wish to make discoverable.

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文