Sunday, July 27, 2008

The SSDSNwindEntitiesCS.sln sample project for my “Test-Drive SQL Server Data Services” cover article for the July 2008 issue of Visual Studio Magazine has been updated to SSDS Sprint 3, adds a couple of features, and has a few start-up bugs excised.

New Features:

The program attempts to create an authority if you haven’t added one.

A splash screen opens during the initial query for ACE container and entity object because the process is very slow with a moderate number of objects.

The containerUri = response.Headers[HttpResponseHeader.Location]; instruction which now returns null has been replaced with concatenated constants as the containerUri value. This eliminates a problem when creating new containers with REST operations.

Note: This project is designed for use with v1 (Sprint #3) of the beta versions. It has been updated for Sprint #3 and uses the new 'application/x-ssds+xml' mime type for REST operations. A number of minor improvements, changes, and bug-fixes have been added.

This code might require VS 2008 SP1 Beta 1 and will be updated for later SSDS/SP1 versions, if breaking changes occur.

This project will install in a \SSDSNwindEntitiesCS folder by default.

TIP: If you have a problem with the default SOAP protocol and have verified your UserName, Password, and AuthorityId, refresh the Service Reference. Alternatively, mark the Use REST check box to use the REST protocol temporarily.

Instructions:

This project requires the user to have a beta account for SQL Server Data Services (SSDS), which you can obtain by registering at http://www.microsoft.com/sql/dataservices/default.mspx, and an instance of the Northwind sample database attached to SQL Server 2005+ [Express].

It's recommended that you set your userId, AuthorityId, and, optionally, password as the Text value of the three corresponding text boxes.

To create and populate a Northwind container with all sample tables with the SOAP protocol, run the project and click the Create and Load Entities button (see Figure 1.)

To do the same with the REST protocol, mark the Use REST check box (see Figure 2.).

If you want to substitute Guids for alphanumeric Ids, mark the Use Guid for Id check box. SSDS will sort the entities in random (Guid string) order.

If you want to base64Encode and upload the Employees and Categories tables' image fields, mark the base64Binary-Encode images check box.

To create and populate a container for each table, mark the Container per Entity check box.

Clicking Bail Out terminates upload operations.

Clicking Get Orders retrieves (GETs) 83 orders having Brazil as the ShipCountry value.

Clicking Delete Orders (SOAP only) deletes the Brazilian orders and offers the option to replace them after deletion.

After creating containers, when you close and restart the program a message box opens to let you decide what to do (see Figure 3.)

Figure 1. It’s not practical to display the SOAP message for adding entities in the text box, so the program lists the property values. You can view SOAP messages by enabling message logging with the WCF Service Configuration Editor.

Figure 2: When you select the REST wire protocol the entire POST template appears in the text box.

Figure 3. The text box displays containers and entities (indented) by name in alphabetic Id order. When you reopen the project a message box lets you choose to keep the existing containers intact (Yes), delete and recreate empty containers as required (No), or delete the existing containers (Cancel).

Figure 4. The auto-generated log file for all entities uploaded by the SOAP and REST protocols with total elapsed time rows added for both protocols over a DSL connection tested at 2,583 bps download, 431 bps upload to Seattle, WA.

The project has minimal error trapping so you can more easily determine where the problem occurred.

The dual Web role application has been running in Microsoft's South Central US (San Antonio) data center since September 2009. I believe it is the oldest continuously running Windows Azure application.

About Me

I'm a Windows Azure Insider, a retired Windows Azure MVP, the principal developer for OakLeaf Systems and the author of 30+ books on Microsoft software. The books have more than 1.25 million English copies in print and have been translated into 20+ languages.

Full disclosure: I make part of my livelihood by writing about Microsoft products in books and for magazines. I regularly receive free evaluation software from Microsoft and press credentials for Microsoft Tech•Ed and PDC. I'm also a member of the Microsoft Partner Network.