SALES: 1-800-867-1380
Expand Minimize

DiscoveryType Enumeration

Describes the publishing behavior of a service in the Service Registry.

Namespace:  Microsoft.ServiceBus
Assembly:  Microsoft.ServiceBus (in Microsoft.ServiceBus.dll)

[DataContractAttribute(Name = "DiscoveryType", Namespace = "http://schemas.microsoft.com/netservices/2009/05/servicebus/connect")]
public enum DiscoveryType

Member nameDescription
PrivateThe service will not be published in the Service Registry.
PublicThe Service will be published in the Service Registry.

Windows Azure Service Bus supports only Full Trust code access security.

To set this behavior, add a ServiceRegistrySettings object as a Behavior to your service endpoint.

The Service Registry will publish your service using the format https://example.servicebus.windows.net or http://example.servicebus.windows.net, where “example” is your account name.

The Service Registry always permits anonymous access. However, only services with Service Registry Settings Behavior with a DiscoveryMode value of Public will be published here.

The Service Registry will publish your service only if you add a ServiceRegistrySettings behavior to your service.

For more information on discovering services through the Windows Azure Service Bus, see Discovering and Exposing an AppFabric Service Bus Service.

The following example sets a service to be publicly available in the Registry.

            // Determine the system connectivity mode based on the command line.
            // arguments: -http, -tcp or -auto  (defaults to auto)
            ServiceBusEnvironment.SystemConnectivity.Mode = GetConnectivityMode(args);

            Console.Write("Your Service Namespace Domain: ");
            string serviceNamespaceDomain = Console.ReadLine();
            Console.Write("Your Issuer Name: ");
            string issuerName = Console.ReadLine();
            Console.Write("Your Issuer Secret: ");
            string issuerSecret = ReadPassword();

            // Create the endpoint address in the solution's namespace.
            Uri address = ServiceBusEnvironment.CreateServiceUri("sb", serviceNamespaceDomain, "EchoService");

            // Create the credentials object for the endpoint.
            TransportClientEndpointBehavior sharedSecretServiceBusCredential = new TransportClientEndpointBehavior();
            sharedSecretServiceBusCredential.CredentialType = TransportClientCredentialType.SharedSecret;
            sharedSecretServiceBusCredential.Credentials.SharedSecret.IssuerName = issuerName;
            sharedSecretServiceBusCredential.Credentials.SharedSecret.IssuerSecret = issuerSecret;

            // Set the DiscoveryType to Public and Publish this in the Service Registry.
            ServiceRegistrySettings serviceRegistrySettings = new ServiceRegistrySettings();
            serviceRegistrySettings.DiscoveryMode = DiscoveryType.Public;
            serviceRegistrySettings.DisplayName = "My Echo Service";

            // Create the service host reading the configuration.
            ServiceHost host = new ServiceHost(typeof(EchoService), address);

            // Add the AppFabric Service Bus credentials to all endpoints specified in configuration.
            foreach (ServiceEndpoint endpoint in host.Description.Endpoints)
            {
                endpoint.Behaviors.Add(sharedSecretServiceBusCredential);
                endpoint.Behaviors.Add(serviceRegistrySettings);
            }
            
            // Open the service.
            host.Open();

            Console.WriteLine("Service address: " + address);
            Console.WriteLine("Press [Enter] to exit");
            Console.ReadLine();

            // Close the service.
            host.Close();

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft