我无法激活由同一个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)
答案 0 :(得分:1)
您发现的问题是/behavior/serviceRegistrySettings/@displayName
与两个服务定义发生冲突。如果要控制每个端点的displayName
,则需要创建单独的命名行为。在复制端点合同时,您需要确保显示名称是唯一的。
displayName
<behavior name="credentials">
<serviceRegistrySettings discoveryMode="Public" />
<transportClientEndpointBehavior>
<tokenProvider>
<sharedSecret issuerName="owner" issuerSecret="**KEY**" />
</tokenProvider>
</transportClientEndpointBehavior>
</behavior>
<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>