This sample demonstrates how to use the Windows Azure Service Bus Messaging Features from Silverlight through the REST Service Bus endpoint. See the Service Bus documentation for more information about the Service Bus before exploring the samples.

This sample demonstrates: Access Control Service token acquisition using a Service Identity's name and password; Namespace management operations including Queue creation and Queue deletion; Basic Messaging operations including Message Send and Message Receive (using Receive and Delete semantics).

Prerequisites

If you haven't already done so, please read the release notes document that explains how to sign up for a Windows Azure account and how to configure your environment.

Sample Flow

The sample flows in the following manner:

  1. Get a WRAP Access Token from the Access Control Service for your namespace;
  2. Create a new Queue on the Service Bus;
  3. Send a plain text message to the newly created Queue;
  4. Receive and Delete the message from the Queue;
  5. Delete the Queue from the Service Bus.

Before You Run the Sample

To run the sample, you first need to have the Silverlight 4 Tools for Visual Studio 2010 installed on your computer.

In Silverlight, cross domain networking is restricted; any services you wish to call from a Silverlight application (including the Windows Azure Service Bus) are responsible for publishing a Client Access Policy file - you can learn more about Network Security Access Restrictions in Silverlight on MSDN. This sample accesses network resources in two realms: firstly, an HTTP POST request is made to the Access Control Service; next HTTP POST, PUT and DELETE requests are made to the Service Bus. The Access Control Service publishes a default client access policy document which permits cross domain execution from all callers at the root of each namespace. The Service Bus, however, does not publish any policy by default; it is therefore necessary to upload a Client Access Policy document to the root of your service namespace - this can be done with the ClientAccessPolicyPublisher utility included with the samples. You must ensure you have a Client Access Policy in place before running the sample or you will encounter Security Exceptions.

Running the Sample

Start the sample application by clicking 'Start Debugging' on the 'Debug' menu in Visual Studio 2010. The application will open in your default browser. Follow the steps of the sample indicated by the user interface providing valid input at each stage.

  1. Type your Service Namespace name (like 'contoso') and the issuer secret for the default service identity, owner (like 'Abcdefghijklmnopqrstuvwxyz01234567890aBCDEF=') then click the 'Get Token' button.

    A request for an Access Control Service token is created and issued via HTTP POST. When the call returns successfully, the sample progresses to Step 2.

  2. Type a name for a new Queue on the Service Bus - the name must be unique within your service namespace - and click the 'Create' button. A request to create the new queue is issued as an HTTP Put to the Service Bus using the authorization token gained in step 1.
  3. Type some text to send as the body of a message and click the 'Send' button. A new message is enqueued by issuing a HTTP Post to the Service Bus using the authorization token gained in step 1.
  4. Receive and Delete the message from the Queue by clicking the 'Receive' button - the text of the message which is received is displayed in the adjacent text box.
  5. Delete the Queue from the Service Bus by clicking the 'Delete' button.


Did you find this information useful? Please send your suggestions and comments about the documentation.