2
votes

I cant activate a service that is exposed by two different relay endpoints in the same NAMESPACE but with different addresses. If i delete one of them the service activates fine, so the configuration is fine. I tried changing the type of the binding, changing the namespace, adding two behavior configuration instead of only one but i get always the same error (at the bottom).

Anybody knows if i am missing something? Can i have two relay endpoints in the same 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>

The error is:

An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is: System.ArgumentException: The value could not be added to the collection, as the collection already contains an item of the same type: 'Microsoft.ServiceBus.NameSettings'. This collection only supports one instance of each type. Parameter name: item at System.Collections.Generic.KeyedByTypeCollection1.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, Collection1 endpoints) at System.ServiceModel.Description.ServiceMetadataBehavior.MetadataExtensionInitializer.GenerateMetadata() at System.ServiceModel.Description.ServiceMetadataExtension.EnsureInitialized() at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.InitializationData.InitializeFrom(ServiceMetadataExtension extension) at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.GetInitData() at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.TryHandleDocumentationRequest(Message httpGetRequest, String[] queries, Message& replyMessage) at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.ProcessHttpRequest(Message httpGetRequest) at SyncInvokeGet(Object , Object[] , Object[] ) at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)

1
Are you using WebServiceHost? You need to use that for WebHttpRelayBinding.TheDude

1 Answers

1
votes

The issue you discovered is that /behavior/serviceRegistrySettings/@displayName is colliding for both service definitions. If you want control over the displayName for each endpoint, then you need to create separate named behaviors. You need to be ensure display name is unique when duplicating endpoint contracts.

Option #1 - Remove displayName

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

Option #2 - Create duplicate Behavior config

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