现在的位置: 首页 > 综合 > 正文

Using SOAP Interface with the SQL Server Data Services

2013年08月08日 ⁄ 综合 ⁄ 共 27187字 ⁄ 字号 评论关闭

Hands-On Lab
Session 4.3 - Lab 02
Using SOAP Interface with the SQL Server Data Services

 S+S Deep Dive Training

 

Description 3
Goals and Objectives 3
IF You Have Previously Done This Lab 3
Expected Duration 3
Step 1 – Create C#  Project 3
Step 2 – Creating a Container Using SOAP 3
Step 3 – Creating a Entity Using SOAP 6
Step 4 – Retrieving and Updating an Entity Using SOAP 8
Step 5 – Querying and Deleting Entity Using SOAP 12
Step 6 – Deleting a Container Using SOAP 16
 
 

 

Information in this document, including URL and other Internet Web site references, is subject to change without notice.  Unless otherwise noted, the example companies, organizations, products, domain names, e-mail addresses, logos, people, places, and events depicted herein are fictitious, and no association with any real company, organization, product, domain name, e-mail address, logo, person, places or events is intended or should be inferred.  Complying with all applicable copyright laws is the responsibility of the user.  Without limiting the rights under copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of Microsoft Corporation.

Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document.  Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property.

2001-2006 Microsoft Corporation.  All rights reserved.

Microsoft, MS-DOS, Windows, Windows NT, Active Directory, Authenticode, IntelliSense, FrontPage, JScript, MSDN, PowerPoint, Visual Basic, Visual C++, Visual C#, Visual Studio, Win32, and Windows Media are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries.

The names of actual companies and products mentioned herein may be the trademarks of their respective owners.
Session 4.3 - Lab 01
Using SSDS Explorer

Description
This lab will show you how to use SOAP interface to manipulate data in SSDS in Visual C# 2008.

Goals and Objectives

 Understand SSDS SOAP interface.

IF You Have Previously Done This Lab

 

Expected Duration

20 Minutes

Step 1 – Create C#  Project

1. Start the Microsoft Visual Studio 2008, and then create a console application with C#.
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. 
Adding Service Reference in Visual Studio 2008
1) Click Add Service Reference from the project menu.
2) Specify address http://data.beta.mssds.com/soap/v1?wsdl.
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.Collection.Generic.List, and then click OK.
6) Enter the code, and then build and run the application.

Step 2 – Creating a Container Using SOAP

The following C# example adds a container to your existing authority. To create a working sample,
1. Update code and provide existing authority id and new container id.
Provide credentials (user name, password) when application executes.Here the credential is as below(Note: Your username is case sensitive):-
UserName:yanwang
Password: iHGR4A8Wz3dv1zZ3d0Ra
2. In the code below, the "using CreateContainerUsingSOAP.ssdsClient" statement has two parts:
a. The first part (CreateContainerUsingSOAP) is the namespace name. This namespace name must match the Default namespace of the application.
b. The second part (ssdsClient) is the name you provided when you added the service reference.
C#

using CreateContainerUsingSOAP.ssdsClient;
using System;
using System.Security.Cryptography;
using System.Text;
using System.ServiceModel;

namespace CreateContainerUsingSOAP
{
    class Program
    {
        // Provide your own values for these member variables
        private static string userName;
        private static string password;
        private const string authorityId = "<YourExistingAuthorityId>";
        private const string containerId = "<NewContainerId>";

        static void Main(string[] args)
        {
            Console.Write("Username: ");
            userName = Console.ReadLine();
            Console.Write("Password: ");
            password = ReadPassword();

            using (SitkaSoapServiceClient proxy = new SitkaSoapServiceClient("SitkaSoapEndpoint"))
            {
                proxy.ClientCredentials.UserName.UserName = userName;
                proxy.ClientCredentials.UserName.Password = password;

                // Identify scope. To create a container you need to specify an authority scope.
                Scope myAuthorityScope = new Scope();
                myAuthorityScope.AuthorityId = authorityId;

                // Add a container
                Container c1 = new Container();
                // Set metadata property
                c1.Id = containerId;

                try
                {
                    proxy.Create(myAuthorityScope, c1);

                    Console.WriteLine("Container {0} created!", c1.Id);
                }
                catch (FaultException<Error> e)
                {
                    // Suppress EntityExists errors in case user and/or authority already exists
                    if (e.Detail.StatusCode != ErrorCodes.EntityExists)
                    {
                        Console.WriteLine("Error: {0}:{1}", e.Detail.StatusCode, e.Detail.Message);
                        Console.WriteLine(e);
                        return;
                    }
                    Console.WriteLine("Container {0} already exist. Creation failed", c1.Id);
                }
            }
        }

        private static string ReadPassword()
        {
            StringBuilder retval = new StringBuilder();
            ConsoleKeyInfo keyInfo;
            while ((keyInfo = Console.ReadKey(true)).Key != ConsoleKey.Enter)
            {
                Console.Write("*");
                retval.Append(keyInfo.KeyChar);
            }
            Console.WriteLine();

            return retval.ToString();
        }
    }
}

3. To verify results, enter the container URI in the browser:

https://<YourExistingAuthorityId>.data.beta.mssds.com/v1/<NewContainerId

Sample container metadata is shown below:

<s:Container xmlns:s="http://schemas.microsoft.com/sitka/2008/03/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:x="http://www.w3.org/2001/XMLSchema">
<s:Id>NewContainerId</s:Id>
<s:Version>2233</s:Version>
</s:Container>

You can specify LINQ query with the specific authority in the scope to find all the containers in it.

http://<YourExistingAuthorityId >.data.beta.mssds.com/v1?q='from e in entities select e’ 

Step 3 – Creating an Entity Using SOAP

The following example creates a book entity in one of the existing containers. To create a working sample,
1. Update code and provide your existing authority id, container id and new entity id.
2. Provide credentials (user name, password) when application executes.
3. In the code below, the "using CreateEntityUsingSOAP.ssdsClient" statement has two parts:
1) The first part (CreateEntityUsingSOAP) is the namespace name. This namespace name must match the Default namespace of the application.
2) The second part (ssdsClient) is the name you provided when you added the service reference.
C#

using CreatingEntityUsingSOAP.ssdsClient;
using System;
using System.Collections.Generic;
using System.ServiceModel;
using System.Text;

namespace CreatingEntityUsingSOAP
{
    class Program
    {
        // Provide your own values for these member variables
        private static string userName;
        private static string password;
        private const string authorityId = "<YourExistingAuthorityId>";
        private const string containerId = "<YourExistingContainerId>";
        private const string entityId = "<NewEntityId>";

        static void Main(string[] args)
        {
            Console.Write("Username: ");
            userName = Console.ReadLine();
            Console.Write("Password: ");
            password = ReadPassword();

            using (SitkaSoapServiceClient proxy = new SitkaSoapServiceClient("SitkaSoapEndpoint"))
            {
                proxy.ClientCredentials.UserName.UserName = userName;
                proxy.ClientCredentials.UserName.Password = password;

                // Identify scope. To create an entity you need to specify container scope.
                Scope myContainerScope = new Scope();
                myContainerScope.AuthorityId = authorityId;
                myContainerScope.ContainerId = containerId;

                // Let us create a Book entity
                Entity e1 = new Entity();
                // Set requied metadata properties
                e1.Id = entityId;
                // Set optional metadata property
                e1.Kind = "UsedBookKind";
                // Set flexible properties
                e1.Properties = new Dictionary<string, object>();
                e1.Properties["Title"] = "My Book";
                e1.Properties["ISBN"] = "1-57880-066-36";
                e1.Properties["Author"] = "Mr. Author";
                e1.Properties["Publisher"] = "Mr. Publisher";
                e1.Properties["InPrint"] = false;
                e1.Properties["NumberOfCopiesSold"] = 250m; //decimal
                e1.Properties["PublicationDate"] = DateTime.Parse("01/27/2004");
                e1.Properties["CoverPhoto"] = new byte[] { 0x1, 0x2, 0x3 };    // replace with real binary data
                try
                {
                    proxy.Create(myContainerScope, e1);

                    Console.WriteLine("Entity {0} created!", e1.Id);
                }
                catch (FaultException<Error> e)
                {
                    // Suppress EntityExists errors in case user and/or authority already exists
                    if (e.Detail.StatusCode != ErrorCodes.EntityExists)
                    {
                        Console.WriteLine("Error: {0}:{1}", e.Detail.StatusCode, e.Detail.Message);
                        Console.WriteLine(e);
                        return;
                    }
                    Console.WriteLine("Entity {0} already existed", e1.Id);
                }
            }
        }

        private static string ReadPassword()
        {
            StringBuilder retval = new StringBuilder();
            ConsoleKeyInfo keyInfo;
            while ((keyInfo = Console.ReadKey(true)).Key != ConsoleKey.Enter)
            {
                Console.Write("*");
                retval.Append(keyInfo.KeyChar);
            }
            Console.WriteLine();

            return retval.ToString();
        }
    }
}

4. To verify the result, enter the entity URI in the browser to retrieve the specific entity:

https://<authority-id>.data.beta.mssds.com/v1/<container-id>/<entity-id>

The sample book entity XML is shown below:

<Book xmlns:s="http://schemas.microsoft.com/sitka/2008/03/
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance
      xmlns:x="http://www.w3.org/2001/XMLSchema">
    <s:Id>SampleBookUsingREST</s:Id>
    <s:Version>1</s:Version>
    <title xsi:type="x:string">My first used book using REST</title>
    <summary xsi:type="x:string">Some summary</summary>
    <isbn xsi:type="x:string">1-57880-057-9</isbn>
    <author xsi:type="x:string">Author A</author>
    <publisher xsi:type="x:string">Publisher B</publisher>
</Book>

5. You may specify empty query with specific container in scope to find all the entities in that container:

https://<authority-id>.data.beta.mssds.com/v1/<container-id>?q=''

Step 4 – Retrieving and Updating an Entity Using SOAP

The following example creates a sample book entity in your existing container and then updates the entity. The update includes adding a new property and changes the value of an existing property. The application performs the necessary cleanup by removing the sample entity. To create a working sample,
1. Update code and provide existing authority id, container id and new entity id.
2. Provide credentials (user name, password) when application executes.
3. In the code below, the "using UpdateEntityUsingSOAP.ssdsClient" statement has two parts:
1) The first part (UpdateEntityUsingSOAP) is the namespace name. This namespace name must match the Default namespace of the application.
2) The second part (ssdsClient) is the name you provided when you added the service reference.
C#
using UpdateEntityUsingSOAP.ssdsClient;
using System;
using System.Collections.Generic;
using System.ServiceModel;
using System.Text;

namespace UpdateEntityUsingSOAP
{
    class Program
    {
        // Provide your own values for these member variables
        private static string userName;
        private static string password;
        private const string authorityId = "<YourExistingAuthorityId>";
        private const string containerId = "<YourExistingContainerId>";
        private const string sampleEntityId = "<NewEntityId>";

        private static SitkaSoapServiceClient proxy;

        static void Main(string[] args)
        {
            Console.Write("Username: ");
            userName = Console.ReadLine();
            Console.Write("Password: ");
            password = ReadPassword();

            using (proxy = new SitkaSoapServiceClient("SitkaSoapEndpoint"))
            {
                proxy.ClientCredentials.UserName.UserName = userName;
                proxy.ClientCredentials.UserName.Password = password;

                // 1) First create a sample entity (to update later)
                // Set scope to the container where you want to create the sample entity
                Scope myContainerScope = new Scope();
                myContainerScope.AuthorityId = authorityId;
                myContainerScope.ContainerId = containerId;

                //string sampleEntityId = "SampleEntity_ForUpdate";

                CreateEntity(myContainerScope);

                // 2) Let us update the entity.
                // The scope must be set to the entity you want to update
                Scope myEntityScope = new Scope();
                myEntityScope.AuthorityId = authorityId;
                myEntityScope.ContainerId = containerId;
                myEntityScope.EntityId = sampleEntityId;

                UpdateEntity(myEntityScope);

                // clean up (specify the entity scope (entity to be deleted).
                DeleteEntity(myEntityScope);
            }
        }

        private static void UpdateEntity(Scope myEntityScope)
        {
            try
            {
                // GET the entity to update
                Entity myBook = proxy.Get(myEntityScope);

                // Let us update this entity (add new prop, update existing prop)
                // 1) Add a new flex property
                string newPropName = "NewProp";
                myBook.Properties[newPropName] = "New Prop Value";

                // 2) Change an existing flex property
                if (myBook.Properties.ContainsKey("Author"))
                {
                    myBook.Properties["Author"] = "A New Author";
                }

                // Send the update back
                proxy.Update(myEntityScope, myBook);
                Console.WriteLine("Entity {0} updated!", myEntityScope.EntityId);
            }
            catch (FaultException<Error> e)
            {
                // Suppress EntityNotFound errors in case entity doesn't exists
                if (e.Detail.StatusCode != ErrorCodes.EntityNotFound)
                {
                    Console.WriteLine("Error: {0}:{1}", e.Detail.StatusCode, e.Detail.Message);
                    Console.WriteLine(e);
                    return;
                }
                Console.WriteLine("Entity {0} not found!", myEntityScope.EntityId);
            }
        }

        static void DeleteEntity(Scope myEntityScope)
        {
            try
            {
                proxy.Delete(myEntityScope);
                Console.WriteLine("Entity {0} deleted!", myEntityScope.EntityId);
            }
            catch (FaultException<Error> e)
            {
                // Suppress EntityNotFound errors in case entity doesn't exists
                if (e.Detail.StatusCode != ErrorCodes.EntityNotFound)
                {
                    Console.WriteLine("Error: {0}:{1}", e.Detail.StatusCode, e.Detail.Message);
                    Console.WriteLine(e);
                    return;
                }
                Console.WriteLine("Entity {0} not found!", myEntityScope.EntityId);
            }
        }

        static void CreateEntity(Scope myContainerScope)
        {
            // Add a book
            Entity e1 = new Entity();
            // Set requied metadata property
            e1.Id = sampleEntityId;
            // Set optional metadata property
            e1.Kind = "UsedBookKind";

            // Set flex properties
            e1.Properties = new Dictionary<string, object>();
            e1.Properties["Title"] = "My Test Book To Update";
            e1.Properties["ISBN"] = "1-57880-066-3";
            e1.Properties["Author"] = "Mr. Author";
            e1.Properties["Publisher"] = "Mr. Publisher";
            e1.Properties["InPrint"] = true;
            e1.Properties["NumberOfCopiesSold"] = 5002m;
            e1.Properties["PublicationDate"] = DateTime.Parse("01/27/2007");
            e1.Properties["CoverPhoto"] = new byte[] { 0x1, 0x2, 0x3 }; // replace with real binary data

            try
            {
                proxy.Create(myContainerScope, e1);
                Console.WriteLine("Entity {0} created!", sampleEntityId);
            }
            catch (FaultException<Error> e)
            {
                // Suppress EntityExists errors in case entity already exists
                if (e.Detail.StatusCode != ErrorCodes.EntityExists)
                {
                    Console.WriteLine("Error: {0}:{1}", e.Detail.StatusCode, e.Detail.Message);
                    Console.WriteLine(e);
                    return;
                }
                Console.WriteLine("Entity {0} already exists!", sampleEntityId);
            }
        }

        private static string ReadPassword()
        {
            StringBuilder retval = new StringBuilder();
            ConsoleKeyInfo keyInfo;
            while ((keyInfo = Console.ReadKey(true)).Key != ConsoleKey.Enter)
            {
                Console.Write("*");
                retval.Append(keyInfo.KeyChar);
            }
            Console.WriteLine();

            return retval.ToString();
        }

    }
}

4. To verify the update, enter the entity URI in the browser.

https://<authority-id>.data.beta.mssds.com/v1/<container-id>/<entity-id>

Step 5 – Querying and Deleting Entity Using SOAP
 
The following example first creates a sample book entity and then deletes it. To illustrate simple queries, after creating a sample entity, the example queries for the entity by using the Title. The entity id of the first book found with the specific title is then deleted. To create a working sample,
1. Update code and provide existing authority id and new container id.
2. Provide credentials (user name, password) when application executes.
3. In the code below, the "using DeleteEntityUsingSOAP.ssdsClient" statement has two parts:
1) The first part (DeleteEntityUsingSOAP) is the namespace name. This namespace name must match the Default namespace of the application.
2) The second part (ssdsClient) is the name you provided when you added the service reference.
C#
using DeleteEntityUsingSOAP.ssdsClient;
using System.Collections.Generic;
using System;
using System.ServiceModel;
using System.Text;

namespace DeleteEntityUsingSOAP
{
    class Program
    {
        // Provide your own values for these member variables
        private static string userName;
        private static string password;
        private const string authorityId = "<YourExistingAuthorityId>";
        private const string containerId = "<YourExistingContainerId>";
        private const string sampleEntityId = "<SampleEntityId>";

        private static SitkaSoapServiceClient proxy;

        static void Main(string[] args)
        {
            Console.Write("Username: ");
            userName = Console.ReadLine();
            Console.Write("Password: ");
            password = ReadPassword();

            string entityIdToDelete = "";

            using (proxy = new SitkaSoapServiceClient("SitkaSoapEndpoint"))
            {
                proxy.ClientCredentials.UserName.UserName = userName;
                proxy.ClientCredentials.UserName.Password = password;

                // Set scope to the container where sample entity is
                // added (for later deletion)
                Scope myContainerScope = new Scope();
                myContainerScope.AuthorityId = authorityId;
                myContainerScope.ContainerId = containerId;

                try
                {
                    // Step 1: First create a sample entity in the "UsedBooks" container.
                    CreateEntity(myContainerScope);

                    // Step 2: Delete the entity created in step 1.
                    // You could easily set the scope using your entity id.
                    // But just to explore queries, the example first queries for the
                    // book by its title. Then uses the entity id of the first book found
                    // with the specific title.
                    string queryString = @"from e in entities where e[""Title""] == ""My Test Book To Delete"" select e";
                    List<Entity> entities = proxy.Query(myContainerScope, queryString);
                    // If there are more, we delete only the 1st one found.
                    entityIdToDelete = entities[0].Id;

                    // First set scope to the specific entity
                    Scope myEntityScope = new Scope();
                    myEntityScope.AuthorityId = myContainerScope.AuthorityId;
                    myEntityScope.ContainerId = myContainerScope.ContainerId;
                    myEntityScope.EntityId = entityIdToDelete;

                    // Now delete
                    proxy.Delete(myEntityScope);

                    Console.WriteLine("Entity {0} deleted!", sampleEntityId);
                }
                catch (FaultException<Error> e)
                {
                    // Suppress EntityExists errors in case user and/or authority already exists
                    if (e.Detail.StatusCode != ErrorCodes.EntityNotFound)
                    {
                        Console.WriteLine("Error: {0}:{1}", e.Detail.StatusCode, e.Detail.Message);
                        Console.WriteLine(e);
                        return;
                    }
                    Console.WriteLine("Entity {0} didn't exist!", entityIdToDelete);
                }
                catch (CommunicationException e)
                {
                    // Use this to echo out invalid credentials case.
                    Console.WriteLine("Unexpected error: {0}!", e.Message);
                }
            }
        }

        static void CreateEntity(Scope myContainerScope)
        {
            // Add a book
            Entity e1 = new Entity();
            e1.Id = sampleEntityId;
            // Set optional metadata property
            e1.Kind = "UsedBookKind";

            // Set flex properties
            e1.Properties = new Dictionary<string, object>();
            e1.Properties["Title"] = "My Test Book To Delete";
            e1.Properties["ISBN"] = "1-57880-066-3";
            e1.Properties["Author"] = "Mr. Author";
            e1.Properties["Publisher"] = "Mr. Publisher";
            e1.Properties["InPrint"] = true;
            e1.Properties["NumberOfCopiesSold"] = 5002m;
            e1.Properties["PublicationDate"] = DateTime.Parse("01/27/2007");
            e1.Properties["CoverPhoto"] = new byte[] { 0x1, 0x2, 0x3 }; // replace with real binary data

            try
            {
                proxy.Create(myContainerScope, e1);

                Console.WriteLine("Entity {0} created!", e1.Id);
            }
            catch (FaultException<Error> e)
            {
                // Suppress EntityExists errors in case user and/or authority already exists
                if (e.Detail.StatusCode != ErrorCodes.EntityExists)
                {
                    Console.WriteLine("Error: {0}:{1}", e.Detail.StatusCode, e.Detail.Message);
                    Console.WriteLine(e);
                    return;
                }
                Console.WriteLine("Entity {0} already exists", e1.Id);
                throw;
            }
        }

        private static string ReadPassword()
        {
            StringBuilder retval = new StringBuilder();
            ConsoleKeyInfo keyInfo;
            while ((keyInfo = Console.ReadKey(true)).Key != ConsoleKey.Enter)
            {
                Console.Write("*");
                retval.Append(keyInfo.KeyChar);
            }
            Console.WriteLine();

            return retval.ToString();
        }
    }
}

4. To verify that the entity was deleted, specify the entity URI in the browser and you will get appropriate "not found" error.

https://<authority-id>.data.beta.mssds.com/v1/<container-id>/<entity-id>
5. You can specify an empty query with the specific container in the scope to retrieve all the entities in that container.

https://<authority-id>.data.beta.mssds.com/v1/<container-id>?q=''

 

Step 6 – Deleting a Container Using SOAP

The following example first creates a sample container and then deletes it. To create a working sample,
1. Update the code and provide existing authority id, and new container id.
2. Provide credentials (user name, password) when application executes.
3. In the code below, the "using DeleteContainerUsingSOAP.ssdsClient" statement has two parts:
1) The first part (DeleteContainerUsingSOAP) is the namespace name. This namespace name must match the Default namespace of the application.
2) The second part (ssdsClient) is the name you provided when you added the service reference.

C#
using DeleteContainerUsingSOAP.ssdsClient;
using System.Collections.Generic;
using System;
using System.ServiceModel;
using System.Text;

namespace DeleteContainerUsingSOAP
{
    class Program
    {
        // Provide your own values for these member variables
        private static string userName;
        private static string password;
        private const string authorityId = "<YourExistingAuthorityId>";
        private const string containerId = "<SampleContainerId>";
        private static SitkaSoapServiceClient proxy = null;

        static void Main(string[] args)
        {
            Console.Write("Username: ");
            userName = Console.ReadLine();
            Console.Write("Password: ");
            password = ReadPassword();

            using (proxy = new SitkaSoapServiceClient("SitkaSoapEndpoint"))
            {
                proxy.ClientCredentials.UserName.UserName = userName;
                proxy.ClientCredentials.UserName.Password = password;

                // Create a test container (to be deleted below)
                CreateContainer();

                // Now delete that container
                // Identify scope. Scope identifies container to be deleted.
                Scope myContainerScope = new Scope();
                myContainerScope.AuthorityId = authorityId;
                myContainerScope.ContainerId = containerId;
                try
                {
                    proxy.Delete(myContainerScope);

                    Console.WriteLine("Container {0} deleted!", containerId);
                }
                catch (FaultException<Error> e)
                {
                    // Suppress EntityExists errors in case user and/or authority already exists
                    if (e.Detail.StatusCode != ErrorCodes.EntityNotFound)
                    {
                        Console.WriteLine("Error: {0}:{1}", e.Detail.StatusCode, e.Detail.Message);
                        Console.WriteLine(e);
                        return;
                    }
                    Console.WriteLine("Container {0} didn't exist!", containerId);
                }
            }
        }

        static void CreateContainer()
        {
            // Identify scope. It identifies authority where container will be added.
            Scope myAuthorityScope = new Scope();
            myAuthorityScope.AuthorityId = authorityId;

            // Add sample containter - to be deleted by this app.
            Container c1 = new Container();
            // Set metadata properties
            c1.Id = containerId;
            try
            {
                proxy.Create(myAuthorityScope, c1);

                Console.WriteLine("Container {0} created!", c1.Id);
            }
            catch (FaultException<Error> e)
            {
                // Suppress EntityExists errors in case user and/or authority already exists
                if (e.Detail.StatusCode != ErrorCodes.EntityExists)
                {
                    Console.WriteLine("Error: {0}:{1}", e.Detail.StatusCode, e.Detail.Message);
                    Console.WriteLine(e);
                    return;
                }
                Console.WriteLine("Container {0} already existed", c1.Id);
            }
        }

        private static string ReadPassword()
        {
            StringBuilder retval = new StringBuilder();
            ConsoleKeyInfo keyInfo;
            while ((keyInfo = Console.ReadKey(true)).Key != ConsoleKey.Enter)
            {
                Console.Write("*");
                retval.Append(keyInfo.KeyChar);
            }
            Console.WriteLine();

            return retval.ToString();
        }
    }
}

4. To verify that the container was deleted, enter the URI of the container in the Web browser. If the container was deleted, you will get the appropriate "not found" error.

https://<authority-id>.data.beta.mssds.com/v1/<container-id>

 

抱歉!评论已关闭.