Deleting a Business

Note: The Microsoft UDDI SDK is not supported by or included in Microsoft Windows versions after Microsoft Windows Server 7. The Microsoft UDDI V3 SDK is included with Microsoft BizTalk Server. For more information about the Microsoft UDDI V3 SDK, see Microsoft BizTalk Server documentation

To delete a business, use the DeleteBusiness class, as shown in the following example.

Be aware that this example also demonstrates the ToString method. The resulting string is the exact XML that is sent to the UDDI server by the Send method.

Note

For this example, you can use the business key that the UDDI server returned in the Saving a Business example.

Example Code

The following example shows how to use the C# programming language to delete a business with the given business key.

using System;

using Microsoft.Uddi;

public class DeleteMyBiz
{

    public static void Main(string [] args)
    {
        try 
        {
            // Create a connection to the UDDI server that is to be accessed. Contoso.com is used is a placeholder.
            UddiConnection myConn = new UddiConnection("http://test.uddi.contoso.com/inquire",
                "https://test.uddi.contoso.com/publish");

            // Create authentication credentials for the delete operation.
            myConn.AuthenticationMode = AuthenticationMode.UddiAuthentication;
            myConn.Username = " *** insert your username *** ";
            myConn.Password = " *** insert your password *** ";

            // Provide the key to the business that you want to delete.
            DeleteBusiness delBiz = new DeleteBusiness(" *** insert your business key *** ");

            // Display XML sent to UDDI server.
            Console.WriteLine(delBiz.ToString());
            Console.WriteLine();

            // Send the delete business request.
            DispositionReport dispRep = delBiz.Send(myConn);
            Console.WriteLine("Disposition report: " + dispRep.Results[0].ErrInfo.ErrCode);
        }
        catch (Microsoft.Uddi.UddiException e)
        {
            Console.WriteLine("UDDI error: " + e.Message);
        }
        catch (Exception gen)
        {
            Console.WriteLine("General exception: {0}", gen.Message);
        }
    }
} 
// Use the following commands to compile and run this example after replacing
// "C:\MyUddiAssemblyDirectory\" with the full path to the Microsoft.Uddi assembly.
// To compile: csc.exe /r:C:\MyUddiAssemblyDirectory\microsoft.uddi.dll /out:DeleteMyBiz.exe DeleteMyBiz.cs
// To run:     DeleteMyBiz.exe

Send comments about this topic to Microsoft.