2013-04-26 167 views
0

我試圖使用HTTPS連接到Windows服務總線。這裏是我的應用程序配置設置:無法通過HTTPS連接到Windows ServiceBus

<appSettings> 
    <add key="Microsoft.ServiceBus.ConnectionString" value="Endpoint=https://example-service.servicebus.windows.net/;SharedSecretIssuer=owner;SharedSecretValue=example-shared-secret-value"/> 
    </appSettings> 

這裏是試圖建立連接的代碼:

return SubscriptionClient.CreateFromConnectionString(ConnectionString, RequestTopicName, 
                   SubscriptionName, ReceiveMode.ReceiveAndDelete); 

但是,它不工作,引發此錯誤:

Unable to create MessagingFactory using connection string. The provided URI scheme 'https' is invalid; expected 'sb'. See inner exception for details. Check your connection string and then try again. For more information please see http://go.microsoft.com/fwlink/?LinkID=249089

內部例外:

提供的URI方案'https'是inv alid;預計'sb'。在Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessagingFactory..ctor(IEnumerable的1 baseAddresses, NetMessagingTransportSettings settings) at Microsoft.ServiceBus.Messaging.NetMessagingTransportSettings.Microsoft.ServiceBus.Messaging.ITransportSettings.BeginCreateFactory(IEnumerable 1 physicalUriAddresses,AsyncCallback的回調,對象狀態) 在Microsoft.ServiceBus.Messaging.MessagingFactorySettings.OnBeginCreateFactory(IEnumerable的1 uriAddresses, AsyncCallback callback, Object state) at Microsoft.ServiceBus.Messaging.MessagingFactorySettings.BeginCreateFactory(IEnumerable 1 uriAddresses,AsyncCallback的回調,對象狀態) 在Microsoft.ServiceBus.Messaging.MessagingFactory.CreateMessagingFactoryAsyncResult..ctor(MessagingFactorySettings設置,IEnumerable的1 addresses, TimeSpan timeout, AsyncCallback callback, Object state) at Microsoft.ServiceBus.Messaging.MessagingFactory.BeginCreate(IEnumerable 1地址,MessagingFactorySettings factorySettings,時間跨度超時回調的AsyncCallback,對象狀態) 在Microsoft.ServiceBus.Messaging.MessagingFactory.BeginCreate(IEnumerable的1 addresses, MessagingFactorySettings factorySettings, AsyncCallback callback, Object state) at Microsoft.ServiceBus.Messaging.MessagingFactory.BeginCreate(IEnumerable 1個地址, TokenProvider tokenProvider,AsyncCallback回調,對象狀態) at Microsoft.ServiceBus.Messaging.MessagingFactory.Creat E(IEnumerable的1 addresses, TokenProvider tokenProvider) at Microsoft.ServiceBus.Messaging.Configuration.KeyValueConfigurationManager.CreateFactory(IEnumerable 1端點,IEnumerable`1 stsEndpoints,字符串operationTimeout,字符串CA證書中issuerName,字符串issuerKey,字符串域,字符串用戶,SecureString的密碼)

如果我更改連接字符串使用SB。實施例服務.servicebus.windows.net而不是https .example-service.servicebus.windows.net它會工作,但我真的需要使用HTTPS而不是SB。

任何想法爲什麼客戶期待'sb'?我如何配置客戶端使用'https'。

回答

0

下面是解決方案:將連接字符串的「https」部分更改回「sb」,即必須是「sb」。現在添加這行代碼:

ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.Http;