public void Open() { if (State != CommunicationState.Created) { return; } try { Opening(this, EventArgs.Empty); ServiceBusHelper.ConfigureBinding(Binding, Anonymous); m_Proxies = new Dictionary <string, T>(); IServiceBusProperties properties = this; foreach (Uri uri in properties.Addresses) { EndpointIdentity identity = new DnsEndpointIdentity(m_ServiceCertFindValue.ToString()); EndpointAddress address = new EndpointAddress(uri, identity); ChannelFactory <T> factory = new ChannelFactory <T>(Binding, address); //Set credentials for message security (if needed) factory.Credentials.UserName.UserName = ServiceUsername; //could be null factory.Credentials.UserName.Password = ServicePassword; //could be null //Set service cert to secure message ClientCredentials behavior = factory.Endpoint.Behaviors.Find <ClientCredentials>(); behavior.ServiceCertificate.SetDefaultCertificate(m_ServiceCertLocation, m_ServiceCertStoreName, m_ServiceCertFindType, m_ServiceCertFindValue); //Set service bus creds if (properties.Credential == null) { if (m_Secret != null) { factory.SetServiceBusCredentials(m_Issuer, m_Secret); } } else { Debug.Assert(m_Secret == null); factory.Endpoint.Behaviors.Add(properties.Credential); } string methodName = uri.Segments[uri.Segments.Length - 1]; methodName = methodName.Replace("/", ""); m_Proxies[methodName] = factory.CreateChannel(); ICommunicationObject proxy = m_Proxies[methodName] as ICommunicationObject; proxy.Open(); } State = CommunicationState.Opened; Opened(this, EventArgs.Empty); } catch { State = CommunicationState.Faulted; } }
public ServiceBufferResponseBase() : base(new Uri(ResponseContext.Current.ResponseAddress)) { Header = ResponseContext.Current; //Grab the creds the host was using IServiceBusProperties properties = OperationContext.Current.Host as IServiceBusProperties; Debug.Assert(properties != null); Credential = properties.Credential; }
protected override void OnOpening() { this.AddGenericResolver(); IServiceBusProperties properties = this as IServiceBusProperties; foreach (ServiceEndpoint endpoint in Description.Endpoints) { Tuple <Uri, string> tuple = ServiceBusHelper.ParseUri(endpoint.Address.Uri); ServiceBusHelper.VerifyQueue(tuple.Item1, tuple.Item2, properties.Credential.TokenProvider, RequiresSession); } base.OnOpening(); }
public ServiceQueueResponseBase(NetMessagingBinding binding) : base(binding, ResponseAddress) { //Grab the creds the host was using IServiceBusProperties properties = OperationContext.Current.Host as IServiceBusProperties; Debug.Assert(properties != null); Tuple <Uri, string> tuple = ServiceBusHelper.ParseUri(ResponseAddress.Uri); this.SetServiceBusCredentials(properties.Credential.TokenProvider); ServiceBusHelper.VerifyQueue(tuple.Item1, tuple.Item2, properties.Credential.TokenProvider, RequiresSession); }
void PurgeQueues() { IServiceBusProperties properties = this as IServiceBusProperties; foreach (Uri queueAddress in properties.Addresses) { try { Uri baseAddress = ServiceBusHelper.ParseUri(queueAddress).Item1; string queueName = ServiceBusHelper.ParseUri(queueAddress).Item2; ServiceBusHelper.PurgeQueue(baseAddress, queueName, properties.Credential.TokenProvider); } catch {} } }
string[] DiscoverServiceBusMexAddresses(string serviceNamespace) { NetOnewayRelayBinding binding = new NetOnewayRelayBinding(); if (m_DisoveryPaths.ContainsKey(serviceNamespace) == false) { m_DisoveryPaths[serviceNamespace] = DiscoverableServiceHost.DiscoveryPath; } EndpointAddress address = new EndpointAddress(ServiceBusEnvironment.CreateServiceUri("sb", serviceNamespace, m_DisoveryPaths[serviceNamespace])); ServiceBusDiscoveryClient discoveryClient = new ServiceBusDiscoveryClient(binding, address); IServiceBusProperties properties = discoveryClient as IServiceBusProperties; properties.Credential = m_NamespaceCredentials[serviceNamespace]; FindResponse discovered = discoveryClient.Find(FindCriteria.CreateMetadataExchangeEndpointCriteria()); return(discovered.Endpoints.Select(mexEndpoint => mexEndpoint.Address.Uri.AbsoluteUri).ToArray()); }
protected override T CreateChannel() { Debug.Assert(Endpoint.Binding is NetMessagingBinding); bool requiresSession; if (SessionId == null) { requiresSession = false; } else { requiresSession = true; } IServiceBusProperties properties = this as IServiceBusProperties; Tuple <Uri, string> tuple = ServiceBusHelper.ParseUri(Endpoint.Address.Uri); ServiceBusHelper.VerifyQueue(tuple.Item1, tuple.Item2, properties.Credential.TokenProvider, requiresSession); this.AddGenericResolver(); return(base.CreateChannel()); }