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.
- 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 new 'application/x-ssds+xml' MIME type replaces ‘application/xml’.
- 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.
From the project’s ReadMeSSDS.txt File:
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.
- 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 Update Orders toggles the presence of a datetime Timestamp property.
- 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).
Performance Data: Uploading tables generates CSV-formatted test data in the ...\bin\Debug folder (see Figure 4). Exiting the program saves the data. Notice that the SOAP protocol executes considerably faster than the REST wire format.
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.