Udostępnij za pośrednictwem


Development How To

 

Applies To: Service Bus for Windows Server 1.0

This section contains a set of common how-to tasks related to development using the Service Bus for Windows Server.

Service Bus Development How-to

  • How to use REST with the Service Bus

  • How to use Service Bus while offline (for example, from your laptop)

How to use REST with the Service Bus

The Service Bus for Windows Server offers REST API for runtime and management operations similar to the API offered by the Microsoft Azure Service Bus. For a detailed description of Service Bus REST support, see the Service Bus REST API Reference [SB]. There are some differences in using REST with the Service Bus for Windows Server.

How to use Service Bus while offline (for example, from your laptop)

The Service Bus for Windows Server enables developers to develop and test applications while being offline or without access to the domain. With the Service Bus for Windows Server, you can use the credentials of a local user, similar to domain users.

To use a local user with your application, do the following:

  1. Modify your service namespace (or create a new one) and add the local user as one of the manageUsers by calling the Set-SBNamespace cmdlet. Note that this call overrides the existing manageUsers list.

  2. Modify your code to create a TokenProvider object with credentials for the local user. For example:

    TokenProvider localUserTokenProvider = WindowsTokenProvider.CreateWindowsTokenProvider(
                    connBuilder.StsEndpoints,
                    new System.Net.NetworkCredential (userName, password));
    
    MessagingFactory factory = MessagingFactory.Create(
                connBuilder.GetAbsoluteRuntimeEndpoints(), localUserTokenProvider);
    NamespaceManager namespaceManager = new NamespaceManager(
                connBuilder.GetAbsoluteManagementEndpoints(), localUserTokenProvider);