在web.config中添加tokenprovider的凭据

时间:2013-02-06 10:46:40

标签: wcf wcf-binding servicebus

编辑:更多详情:

关于我的问题的更多信息:

我使用Service Bus将异步事件发送到WCF服务。我有一个具有此配置的客户端:

<client>
  <endpoint address="sb://[Server].[Domain]/NameSpace/eventqueue"
    behaviorConfiguration="securityBehavior" binding="netMessagingBinding"
    bindingConfiguration="messagingBinding" contract="xxx.IEventQueueService"
    name="Subscriber" />
</client>

请注意,它是我们自己域中的虚拟服务器。

这是行为和bindingConfig:

<behavior name="securityBehavior">
          <transportClientEndpointBehavior>
            <tokenProvider>
              <windowsAuthentication>
                <stsUris>
                  <stsUri value="https://[Server].[Domain]:9355/[Namespace]" />
                </stsUris>
              </windowsAuthentication>
            </tokenProvider>
          </transportClientEndpointBehavior>
        </behavior>

      <netMessagingBinding>
        <binding name="messagingBinding" closeTimeout="00:03:00" openTimeout="00:03:00" receiveTimeout="00:03:00" sendTimeout="00:03:00" sessionIdleTimeout="00:01:00" prefetchCount="-1">
          <transportSettings batchFlushInterval="00:00:01" />
        </binding>
      </netMessagingBinding>

我的WCF服务使用相同的配置:

<services>
  <service name="xxx.EventQueueService">
    <endpoint address="sb://[SERVER].[DOMAIN]/Namespace/eventqueue"
      behaviorConfiguration="securityBehavior" binding="netMessagingBinding"
      bindingConfiguration="messagingBinding" name="EventQueueClientService"
      contract="xxx.IEventQueueService" />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8732/xxx.ExternalServices/EventQueueService" />
      </baseAddresses>
    </host>
  </service>

</services>

如果我在开发计算机上运行项目,这非常有用。但现在,我想将它部署到服务器,与我的服务总线相同。那就失败了......

旧编辑:好的,我找到了这个网页:http://msdn.microsoft.com/en-us/library/microsoft.servicebus.configuration.windowselement.aspx

但这两个选项不起作用:

<windowsAuthentication userName="xxx" password="xxx" domain="xxx">

System.ArgumentNullException: Value cannot be null.
Parameter name: s
   at System.Convert.FromBase64String(String s)
   at Microsoft.ServiceBus.SharedSecretTokenProvider.DecodeSecret(String issuerSecret)
   at Microsoft.ServiceBus.Description.SharedSecretCredential.CreateTokenProvider()
   at Microsoft.ServiceBus.Description.TransportClientCredentialBase.get_TokenProvider()
   at Microsoft.ServiceBus.TransportClientEndpointBehavior.get_TokenProvider()
   at Microsoft.ServiceBus.Messaging.NetMessagingTransportBindingElement.CreateMessagingFactorySettings(BindingContext context)
   at Microsoft.ServiceBus.Messaging.Channels.ServiceBusChannelListener`1..ctor(BindingContext context, NetMessagingTransportBindingElement transport)
   at Microsoft.ServiceBus.Messaging.NetMessagingTransportBindingElement.BuildChannelListener[TChannel](BindingContext context)
   at System.ServiceModel.Channels.Binding.BuildChannelListener[TChannel](Uri listenUriBaseAddress, String listenUriRelativeAddress, ListenUriMode listenUriMode, BindingParameterCollection parameters)
   at System.ServiceModel.Description.DispatcherBuilder.MaybeCreateListener(Boolean actuallyCreate, Type[] supportedChannels, Binding binding, BindingParameterCollection parameters, Uri listenUriBaseAddress, String listenUriRelativeAddress, ListenUriMode listenUriMode, ServiceThrottle throttle, IChannelListener& result, Boolean supportContextSession)
   at System.ServiceModel.Description.DispatcherBuilder.BuildChannelListener(StuffPerListenUriInfo stuff, ServiceHostBase serviceHost, Uri listenUri, ListenUriMode listenUriMode, Boolean supportContextSession, IChannelListener& result)
   at System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost)
   at System.ServiceModel.ServiceHostBase.InitializeRuntime()
   at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at Microsoft.Tools.SvcHost.ServiceHostHelper.OpenService(ServiceInfo info)

<windowsAuthentication>

<userName value="xxx">

=&GT;属性“userName”不是ConfigurationElement

1 个答案:

答案 0 :(得分:1)

找到解决此问题的方法。

部署应用程序时,请确保IISPool的所有者(或模拟的用户)也是Service Bus命名空间的ManagedUsers的成员。您可以使用Get-SBNamespace -Name检查它。

将用户添加到命名空间:Set-SBNamespace -Name -ManageUsers