0

我有一个 WCF 服务,我正在使用一个 azure 服务总线中继。我正在尝试公开 mex 端点,但遇到此错误

找不到与绑定 NetTcpRelayBinding 的端点的方案 sb 匹配的基地址。注册的基地址方案是 [http]。

我的配置文件看起来像这样,我在这里做错了什么?

<system.serviceModel>
      <bindings>
         <netTcpRelayBinding>
            <binding name="default">
               <security mode="None" />
            </binding>
         </netTcpRelayBinding>
      </bindings>
      <extensions>
         <behaviorExtensions>
            <add name="transportClientEndpointBehavior" type="Microsoft.ServiceBus.Configuration.TransportClientEndpointBehaviorElement, Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
            <add name="serviceRegistrySettings" type="Microsoft.ServiceBus.Configuration.ServiceRegistrySettingsElement, Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
         </behaviorExtensions>
         <bindingExtensions>
            <!--<add name="basicHttpRelayBinding" type="Microsoft.ServiceBus.Configuration.BasicHttpRelayBindingCollectionElement, Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>-->
            <add name="netTcpRelayBinding" type="Microsoft.ServiceBus.Configuration.NetTcpRelayBindingCollectionElement, Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
         </bindingExtensions>
      </extensions>
      <services>
         <service behaviorConfiguration="serviceMetadata" name="Namespace.TestService">
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            <endpoint address="sb://[my namespace].servicebus.windows.net/Test" behaviorConfiguration="sbTokenProvider" binding="netTcpRelayBinding" bindingConfiguration="default" contract="Namespace.ITestContract" />
            <endpoint name="MexEndpoint" contract="IMetadataExchange" binding="netTcpRelayBinding" bindingConfiguration="default" address="mex" />       
      </service>
      </services>
      <behaviors>
         <serviceBehaviors>
            <behavior name="serviceMetadata">
               <serviceMetadata />
            </behavior>
         </serviceBehaviors>
         <endpointBehaviors>
            <behavior name="sbTokenProvider">
               <transportClientEndpointBehavior>
                  <tokenProvider>
                     <sharedAccessSignature keyName="RootManageSharedAccessKey" key="[key]" />
                  </tokenProvider>
               </transportClientEndpointBehavior>
               <serviceRegistrySettings discoveryMode="Public" />
            </behavior>
         </endpointBehaviors>
      </behaviors>
   </system.serviceModel>
4

2 回答 2

1

这有点棘手,因为在 WCF 中暴露 mex 端点的模型有点不幸,因为它被内联到服务本身。使用服务总线,您不能让端点侦听器在另一个侦听器的范围内进行侦听。

诀窍是让服务端点和 mex 端点并排而不是嵌套,共享一个共同的基地址,例如在https://example.servicebus.windows.net/mysvc下,您将拥有“服务" 和 "mex" 并排。

我正在更新 Relay 示例,因此该示例的 README 仍然需要重写,并且还不能保证它可以正常工作,但是您可能想看看App.config 和 Program.cs在这里。如果您想为 NetTcp 服务公开 MEX,您将需要一个 https:// 和一个 sb:// 前缀的基地址。

该示例还展示了如何修复服务调试行为的帮助页面。

于 2016-01-05T11:33:32.623 回答
0

您需要声明一个与 mexHttpBinding 兼容的基地址(顺便说一下 http)。2个解决方案是可能的:

1 /在服务内的主机部分添加一个baseAddress,如下所示:

<service ...>
   ...
   <host>
      <baseAddresses>
          <add baseAddress="http://localhost:8080/Test" />
      </baseAddresses>
   </host>
</service>

您的 mex 端点将侦听http://localhost:8080/Test/mex

2/ - 或 - 只需在您的 mex 端点中添加一个完整地址。

<endpoint address="http://[namespace].servicebus.windows.net/Test/mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
于 2015-12-29T15:18:31.360 回答