Share via

Examples of Using SOAP Interface with the SQL Data Services

[This document supports a preliminary release of a software product that may be changed substantially prior to final commercial release. This document is provided for informational purposes only.]

You can use the SOAP or REST interfaces to develop applications with the Microsoft® SQL Data Services (SDS). The following topics provide examples that use the SOAP interface:

Creating an Authority Using SOAP

Creating a Container Using SOAP

Deleting a Container Using SOAP

Creating an Entity Using SOAP

Retrieving and Updating an Entity Using SOAP

Querying and Deleting Entity Using SOAP

Follow these steps to create working samples:

  1. Start the Microsoft Visual Studio integrated development environment, and then create a console application.
  2. Add a reference to System.ServiceModel.
  3. To be able to send SOAP requests, you need to add a service reference to your project. There are differences in how you add a service reference in Visual Studio 2005 and in Visual Studio 2008.

Adding Service Reference in Visual Studio 2008

  1. Click Add Service Reference from the project menu.
  2. Specify address
  3. Change the default value (ServiceReference1) for Namespace to ssdsClient.
  4. Some of the samples use generic List (not Array). You will need to update the service reference settings. Click Advanced.
  5. In the Service Reference Settings dialog box, in Collection Type, click System.Collections.Generic.List, and then click OK.
  6. Enter the code, and then build and run the application.

Adding Service Reference in Visual Studio 2005

There are two ways to add a service reference in Visual Studio 2005:

  • Command line (svcutil.exe)
  • Using the Visual Studio graphical user interface

Both these approaches are described below:

Adding Service Reference at the Command Line (Visual Studio 2005)

Ensure you have following components installed (in order).

  • Visual Studio 2005
  • Visual Studio 2005 SP1
  • .NET Framework 3.0 Runtime Components
  • .NET Framework 3.0 SDK

To add a service reference, you first run svcutil.exe at the command prompt to generate the ssdsClient.cs and app.config files. You add these files to your project.


The svcutil.exe program is usually found in C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\svcutil.exe, but it may also be located in the directory where the SDK is installed, which is probably something like C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\svcutil.exe depending on which version of the SDK you installed and whether you specified a different directory during the installation. The SDK version of this program is more current. Both will produce identical output for our purposes.


  1. At the command prompt, run svcutil.exe. The ^ symbols below are added to simplify cut and paste in a command window. They are not actually part of the command syntax.  Furthermore, you must provide the project namespace that you created with your Visual Studio project in the place indicated:

    svcutil.exe /noLogo /out:"ssdsClient.cs" /language:csharp ^
                /config:app.config ^
                /n:*,<ProjectNamespace>.ssdsClient ^
                /serializable ^
                /ser:DataContractSerializer ^
                /importXmlTypes ^

    This command generates the ssdsClient.cs and app.config files.

  2. Add these files to your project. If the project already has an app.config (or a <program-name>.exe.config) file, then manually merge the content of the new app.config file in to your existing app.config.  

  3. Add a reference to the .NET Framework assembly (System.ServiceModel,

  4. Add a reference to System.Runtime.Serialization.

  5. Add the following using statement at the beginning of your code.

    using <ProjectName>.ssdsClient;

Adding Service Reference Using GUI (Visual Studio 2005)

Follow these steps to add a service reference using Visual Studio 2005 graphical user interface. In order to follow along with the examples as documented, an additional step is required (documented as step #5). This step is required as several of the examples use the List<T> for return types.

NOTE: These generated code modifications are not required if you choose to generate the service proxy from the command line as documented earlier.

  1. Right-click References, and then click Add Service Reference
  2. In the Service URI text box, enter
  3. Change Service reference name to ssdsClient.
  4. Click OK.
  5. Some of the samples use the List class instead of the Array class, and so you will need to modify ssdsClient.cs under Service References/
    1. Change in public interface ISitkaSoapService from

      YourNameSpace.ssdsClient.Entity[] Query(YourNameSpace.ssdsClient.Scope scope, [System.ServiceModel.MessageParameterAttribute(Name="query")] string query1);


      List<YourNameSpace.ssdsClient.Entity> Query(YourNameSpace.ssdsClient.Scope scope, [System.ServiceModel.MessageParameterAttribute(Name="query")] string query1);
    2. Change query method inside public partial class SitkaSoapServiceClient from

      public YourNameSpace.ssdsClient.Entity[] Query(YourNameSpace.ssdsClient.Scope scope, string query1)


      public List< YourNameSpace.ssdsClient.Entity> Query(YourNameSpace.ssdsClient.Scope scope, string query1)

Endpoint names

When interacting with SDS using the SOAP interface, both the basic authentication and token-based authentication schemes are supported. For information on using token-based authentication scheme, see SDS and .NET Access Control Service Integration.

Depending on the authentication scheme you use, appropriate endpoint name must be specified when creating a SOAP client. SOAP samples provided in this topic use basic authentication for which the endpoint name is BasicAuthEndpoint.

See Also


Getting Ready to Use SQL Data Services
Examples of Using REST Interface with the SQL Data Services