AppFabric Service Bus webHttpRelayBinding

advertisement

Demo Script

AppFabric Service Bus webHttpRelayBinding

Lab version: 2.0.0

Last updated: 4/13/2020

Contents

OVERVIEW ................................................................................................................................................... 3

Key Messages ........................................................................................................................................... 3

Key Technologies ...................................................................................................................................... 3

Time Estimates ......................................................................................................................................... 4

SETUP AND CONFIGURATION .................................................................................................................. 4

Task 1 –Running Dependency Checker ................................................................................................. 4

Task 2 – Creating a Windows Azure Service project ............................................................................. 4

Task 3 – Opening the WebHttpRelayBinding Sample ........................................................................... 5

DEMO FLOW ................................................................................................................................................ 6

OPENING STATEMENT ............................................................................................................................... 7

STEP-BY-STEP WALKTHROUGH .............................................................................................................. 7

Looking at the code in Visual Studio ......................................................................................................... 7

Run the code and show the image in a browser ....................................................................................... 8

SUMMARY .................................................................................................................................................... 9

KNOWN ISSUES ........................................................................................................................................ 10

Overview

This demo shows the Service Bus webHttpRelayBinding. This allows HTTP requests to be sent to a service over the Service Bus.

The code is part of the Windows Azure platform AppFabric SDK and is located at:

%ProgramFiles%\Windows Azure platform AppFabric SDK\V1.0\Samples\ServiceBus\ExploringFeatures\Bindings\WebHttp\CS35\WebHttpSample.sln

The readme for the sample is here:

%ProgramFiles%\Windows Azure platform AppFabric SDK\V1.0\Samples\ServiceBus\ExploringFeatures\Bindings\WebHttp\Readme.htm

Note: In order to run through this complete demo, you must have network connectivity and a Service Bus namespace.

Key Messages

1.

It is very simple for a .NET developer to modify a typical WCF app to use the relay

2.

This binding allows clients to connect to a service over HTTP

Key Technologies

This demo uses the following technologies:

1.

.NET Framework 3.5 SP1

2.

Visual Studio 2010

3.

Windows Azure platform AppFabric SDK

4.

AppFabric Service Bus (i.e. internet connectivity is required)

Time Estimates

Estimated time for setting up and configuring the demo: 5 min

Estimated time to complete the demo: 5 min

Setup and Configuration

This demo does not have any advanced configuration requirements. You simply need to have the prerequisites installed and have an account for AppFabric. For more information on how to purchase an account, visit the AppFabric Portal at http://appfabric.azure.com

.

Task 1 –Running Dependency Checker

The following steps describe how to run the Dependency Checker utility included with the demo to verify that you have the prerequisite components. You can skip this exercise if you are confident that the prerequisites are properly installed and configured.

1.

Open a Windows Explorer window and browse to the demo’s Source\Script folder.

2.

Double-click the Dependencies.dep file in this folder to launch the Dependency Checker tool and install any missing prerequisites.

3.

If the User Account Control dialog is shown, confirm the action to proceed.

Note: This process may require elevation. The .dep extension is associated with the Dependency Checker tool during its installation. For additional information about the setup procedure and how to install the Dependency Checker tool, refer to the Setup.docx document in the Assets folder of the training kit.

Task 2 – Creating a Windows Azure Service project

1.

You must create a Windows Azure Services project and one or more service namespaces inside it. To create and manage your project and service namespaces, log in to the AppFabric portal and select the solution you want to manage.

Task 3 – Opening the WebHttpRelayBinding Sample

1.

Open Visual Studio running as administrator and open %ProgramFiles%\Windows Azure platform AppFabric

SDK\V1.0\Samples\ServiceBus\ExploringFeatures\Bindings\WebHttp\ CS35\WebHttpSample.sln.

Note: The Windows Azure AppFabric SDK samples are available as Visual Studio 2008 solutions (C# and VB) and require

Microsoft .NET Framework 3.5 SP1 or higher to run. In order to run the samples with Visual Studio 2010 open the solutions with Visual Studio 2010 and follow the Conversion Wizard instructions. Notice that the solutions will work as expected but will be still targeting .Net Framework 3.5 (not 4.0).

Demo Flow

The following diagram illustrates the high-level flow for this demo and the steps involved:

Figure 1

Diagram

Opening Statement

This demo shows how a service can return binary data – in this case, an image, over the Service Bus to a client using HTTP.

Step-by-Step Walkthrough

This demo is composed of the following segments:

1.

Show the code in Visual Studio

2.

Run the code and show the image in a browser

Looking at the code in Visual Studio

Action

1. Open the WebHttpSample in Visual

Studio.

2. Open the (service) ImageContract.cs

Script

This is the service contract. A message is returned from an HTTP

GET

Screenshot

3. Open ImageService.cs

The service implementation loads a jpeg from a file and then streams it back to the client.

4. Open the App.config.

5. Complete the sharedSecret placeholders (ISSUER_NAME and

ISSUER_SECRET).

The App.config uses the webHttpRelayBinding and

SharedSecret to authenticate.

6. Open service Program.cs 

In the main program, the service host uses an “https://”-based URI.

Run the code and show the image in a browser

Action Script Screenshot

7. Right click Service in the Solution

Explorer and select Debug > Start new instance

8. Enter the service namespace domain.

 Now we’ll run the application.

9. Copies the URI displayed in the console window and paste it into a browser.

10. [Picture is displayed]

And here is the image displayed in the browser with a URL of https://

<domain>.servicebus.windows.net/G etImage/

Summary

This demo showed how you can have a client and a service connect using HTTP over the Service Bus.

Known Issues

Please note the following known issues with this demo: None

Download