命名空间中的多个中继端点,用于通过服务总线公开服务?

时间:2012-09-04 14:38:05

标签: azure servicebus azureservicebus

我无法激活由同一个NAMESPACE中具有不同地址的两个不同中继端点公开的服务。如果我删除其中一个服务激活正常,所以配置很好。我尝试更改绑定的类型,更改命名空间,添加两个行为配置而不是只有一个,但我总是得到相同的错误(在底部)。

有人知道我错过了什么吗?我可以在同一名称空间中有两个中继端点吗?

<service name="Service">    
        <endpoint contract="IService"  binding="basicHttpRelayBinding" name="b1 "
                  address="http://**NAMESPACE**.servicebus.windows.net/s1"  behaviorConfiguration="credentials"/>    
        <endpoint contract="IService" binding="webHttpRelayBinding" name="wh1"
                  address="https://**NAMESPACE**.servicebus.windows.net/s2"  behaviorConfiguration="credentials"/>                                       
</service>    
<behavior name="credentials">
            <serviceRegistrySettings discoveryMode="Public" displayName="Auxiliar" />
            <transportClientEndpointBehavior>
                <tokenProvider>
                    <sharedSecret issuerName="owner" issuerSecret="**KEY**" />
                </tokenProvider>
            </transportClientEndpointBehavior>
   </behavior>

错误是:

  

ExceptionDetail,可能由IncludeExceptionDetailInFaults = true创建,其值为:   System.ArgumentException:无法将值添加到集合中,因为集合已包含相同类型的项:'Microsoft.ServiceBus.NameSettings'。此集合仅支持每种类型的一个实例。   参数名称:item      在System.Collections.Generic.KeyedByTypeCollection 1.InsertItem(Int32 index, TItem item) at Microsoft.ServiceBus.ServiceRegistrySettings.System.ServiceModel.Description.IEndpointBehavior.AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters) at System.ServiceModel.Description.DispatcherBuilder.AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection parameters) at System.ServiceModel.Description.DispatcherBuilder.GetBindingParameters(ServiceHostBase serviceHost, Collection 1个端点)      在System.ServiceModel.Description.ServiceMetadataBehavior.MetadataExtensionInitializer.GenerateMetadata()      在System.ServiceModel.Description.ServiceMetadataExtension.EnsureInitialized()      在System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.InitializationData.InitializeFrom(ServiceMetadataExtension扩展)      在System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.GetInitData()      at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.TryHandleDocumentationRequest(Message httpGetRequest,String [] queries,Message&amp; replyMessage)      在System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.ProcessHttpRequest(消息httpGetRequest)      在SyncInvokeGet(Object,Object [],Object [])      在System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(对象实例,对象[]输入,对象[]和输出)      在System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp; rpc)      在System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp; rpc)      在System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&amp; rpc)      在System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)

1 个答案:

答案 0 :(得分:1)

您发现的问题是/behavior/serviceRegistrySettings/@displayName与两个服务定义发生冲突。如果要控制每个端点的displayName,则需要创建单独的命名行为。在复制端点合同时,您需要确保显示名称是唯一的。

选项#1 - 删除displayName

   <behavior name="credentials">
     <serviceRegistrySettings discoveryMode="Public" />
       <transportClientEndpointBehavior>
         <tokenProvider>
           <sharedSecret issuerName="owner" issuerSecret="**KEY**" />
         </tokenProvider>
       </transportClientEndpointBehavior>
   </behavior>

选项#2 - 创建重复的行为配置

   <service name="Service">    
        <endpoint contract="IService"  binding="basicHttpRelayBinding" name="b1 "
                  address="http://**NAMESPACE**.servicebus.windows.net/s1"  behaviorConfiguration="basicCredentials"/>    
        <endpoint contract="IService" binding="webHttpRelayBinding" name="wh1"
                  address="https://**NAMESPACE**.servicebus.windows.net/s2"  behaviorConfiguration="webHttpCredentials"/>                                       
   </service>   
   <behavior name="basicCredentials">
     <serviceRegistrySettings discoveryMode="Public" displayName="AuxiliarBasic"/>
       <transportClientEndpointBehavior>
         <tokenProvider>
           <sharedSecret issuerName="owner" issuerSecret="**KEY**" />
         </tokenProvider>
       </transportClientEndpointBehavior>
   </behavior>
   <behavior name="webHttpCredentials">
     <serviceRegistrySettings discoveryMode="Public" displayName="AuxiliarWebHttp"/>
       <transportClientEndpointBehavior>
         <tokenProvider>
           <sharedSecret issuerName="owner" issuerSecret="**KEY**" />
         </tokenProvider>
       </transportClientEndpointBehavior>
   </behavior>