Share via


Finding Categorization Schemes

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

This topic describes how to find all the categorization schemes that are used on a UDDI server.

Purpose

This topic shows how to find all the categorization schemes that are used on a UDDI server. After finding the categorization schemes, you can then find the root categories and other related categories of these categorization schemes. For more information see Finding Root Categories.

Prerequisites and Requirements

This example requires the following components:

This example also requires the following namespaces:

Example Code

The following Visual C# example shows how to find the categorization schemes on a UDDI server.

static void GetCategorizationSchemesExample( UddiConnection validConnection,
                                             StringBuilder displayText )
{

    FindTModel getTModel = new FindTModel();
    
    getTModel.CategoryBag.Add( CommonCanonical.UddiOrgTypes,
                               "categorization",
                               "Categorization (taxonomy)" );
                               
    TModelList tModelListResult = null;
    
    try
    {
    
        tModelListResult = getTModel.Send( validConnection);
    
    }
    
    catch(InvalidUrlPassedException badURL)
    {
    
        // Insert error-handling code for this exception.
        displayText.Append( "Bad URL" );
        
        return;
    
    }
    
    catch( UddiException genericUddiException)
    {
    
        // Insert error-handling code for this exception.
        displayText.Append( genericUddiException.Message);
        
        return;
    
    }
    
    catch( Exception otherException)
    {
    
        // Insert error-handling code for this exception.
        displayText.Append( otherException.Message);
        
        displayText.Append( otherException.GetType().ToString());
        
        return;
    
    }
               

    foreach( TModelInfo tModelItem in tModelListResult.TModelInfos )
    {
        
        displayText.Append( "\r\n" + tModelItem.Name.Text );
            
    }
    
}

The following Visual Basic .NET example shows how to find the categorization schemes on a UDDI server.

Sub GetCategorizationSchemesExample(ByVal validConnection As UddiConnection, _
                                    ByVal displayText As StringBuilder)

    Dim getTModel As New FindTModel

    getTModel.CategoryBag.Add(TModels.CommonCanonical.UddiOrgTypes, _
                              "categorization", _
                              "Categorization (taxonomy)")

    Dim tModelListResult As TModelList

    Try

        tModelListResult = getTModel.Send(validConnection)

    Catch badURL As InvalidUrlPassedException

        ' Insert error-handling code for this exception.
        displayText.Append("Bad URL")

        Return

    Catch genericUddiException As UddiException

        ' Insert error-handling code for this exception.
        displayText.Append(genericUddiException.Message)

        Return

    Catch otherException As Exception

        ' Insert error-handling code for this exception.
        displayText.Append(otherException.Message)

        displayText.Append(otherException.GetType().ToString())

        Return

    End Try

    Dim tModelItem As TModels.TModelInfo

    For Each tModelItem In tModelListResult.TModelInfos

        displayText.Append(vbCrLf + tModelItem.Name.Text)

    Next

End Sub

Implementation Steps

The following sections show how to implement the example code.

Implementation Steps in C#

  1. Create a method that accepts the following parameters:

    • A valid UddiConnection object.

    • A StringBuilder object. This object contains information about categorization schemes.

    static void GetCategorizationSchemesExample( UddiConnection validConnection,
    StringBuilder displayText )
    {
    }
    
  2. Create an instance of the FindTModel class. This object will be used to create the message that is sent to the UDDI server to get the categorization schemes.

    static void GetCategorizationSchemesExample( UddiConnection validConnection,
    StringBuilder displayText )
    {
    
        FindTModel getTModel = new FindTModel();
    
    
    
    }
    
  3. Using the Add method, set the CategoryBag property of the FindTModel object to a specified category reference.

    static void GetCategorizationSchemesExample( UddiConnection validConnection,
    StringBuilder displayText )
    {
    
        FindTModel getTModel = new FindTModel();
    
        getTModel.CategoryBag.Add( CommonCanonical.UddiOrgTypes,
                                   "categorization",
                                   "Categorization (taxonomy)" );
    }
    
  4. Create a TModelList variable and initialize it to null. This object will contain the results of the message from the UDDI server.

    static void GetCategorizationSchemesExample( UddiConnection validConnection,
                                                 StringBuilder displayText )
    {
    
        FindTModel getTModel = new FindTModel();
    
        getTModel.CategoryBag.Add( CommonCanonical.UddiOrgTypes,
                                   "categorization",
                                   "Categorization (taxonomy)" );
    
        TModelList tModelListResult = null;
    
    
    
    }
    
  5. Transmit the request to the UDDI server by using the Send method with the UddiConnection object passed into the method. The TModelList variable receives the results of the request.

    static void GetCategorizationSchemesExample( UddiConnection validConnection,
    StringBuilder displayText )
    {
    
        FindTModel getTModel = new FindTModel();
    
        getTModel.CategoryBag.Add( CommonCanonical.UddiOrgTypes,
                                   "categorization",
                                   "Categorization (taxonomy)" );
    
        TModelList tModelListResult = null;    
    
        tModelListResult = getTModel.Send( validConnection);
    
    
    
    }
    
  6. Handle any exceptions that might occur by using a try-catch statement. The example code shows some exceptions that you might want to handle. Wrap the request in the try statement and handle any exceptions in the catch statement.

    static void GetCategorizationSchemesExample( UddiConnection validConnection,
                                                 StringBuilder displayText )
    {
    
        FindTModel getTModel = new FindTModel();
    
        getTModel.CategoryBag.Add( CommonCanonical.UddiOrgTypes,
                                   "categorization",
                                   "Categorization (taxonomy)" );
    
        TModelList tModelListResult = null;
    
        try
        {
    
            tModelListResult = getTModel.Send( validConnection);
    
        }
    
        catch(InvalidUrlPassedException badURL)
        {
    
            // Insert error-handling code for this exception.
            displayText.Append( "Bad URL" );
    
            return;
    
        }
    
        catch( UddiException genericUddiException)
        {
    
            // Insert error-handling code for this exception.
            displayText.Append( genericUddiException.Message);
    
            return;
    
        }
    
        catch( Exception otherException)
        {
    
            // Insert error-handling code for this exception.
            displayText.Append( otherException.Message);
    
            displayText.Append( otherException.GetType().ToString());
    
            return;
    
        }
    }
    
  7. Iterate through the collection in the TModelInfos property to get information about the categorization schemes. In this example, the name of each categorization scheme is added to the StringBuilder object that displays information about categorization schemes.

    static void GetCategorizationSchemesExample( UddiConnection validConnection,
    StringBuilder displayText )
    {
    
        FindTModel getTModel = new FindTModel();
    
        getTModel.CategoryBag.Add( CommonCanonical.UddiOrgTypes,
                                   "categorization",
                                   "Categorization (taxonomy)" );
    
        TModelList tModelListResult = null;
    
        try
        {
    
            tModelListResult = getTModel.Send( validConnection);
    
        }
    
        catch(InvalidUrlPassedException badURL)
        {
    
            // Insert error-handling code for this exception.
            displayText.Append( "Bad URL" );
    
            return;
    
        }
    
        catch( UddiException genericUddiException)
        {
    
            // Insert error-handling code for this exception.
            displayText.Append( genericUddiException.Message);
    
            return;
    
        }
    
        catch( Exception otherException)
        {
    
            // Insert error-handling code for this exception.
            displayText.Append( otherException.Message);
    
            displayText.Append( otherException.GetType().ToString());
    
            return;
    
        }
    
    
        foreach( TModelInfo tModelItem in tModelListResult.TModelInfos )
        {
    
            displayText.Append( "\r\n" + tModelItem.Name.Text );
    
        }
    
    }
    
  8. Optional. To find the root categories of each categorization scheme, you can create an optional method that finds the root categories. For more information about creating a method that finds root categories, see Finding Root Categories. This example calls the optional method for the ntis-gov:naics:2002 categorization scheme only.

    static void GetCategorizationSchemesExample( UddiConnection validConnection,
                                                 StringBuilder displayText )
    {
    
        FindTModel getTModel = new FindTModel();
    
        getTModel.CategoryBag.Add( CommonCanonical.UddiOrgTypes,
                                   "categorization",
                                   "Categorization (taxonomy)" );
    
        TModelList tModelListResult = null;
    
        try
        {
    
            tModelListResult = getTModel.Send( validConnection);
    
        }
    
        catch(InvalidUrlPassedException badURL)
        {
    
            // Insert error-handling code for this exception.
            displayText.Append( "Bad URL" );
    
            return;
    
        }
    
        catch( UddiException genericUddiException)
        {
    
            // Insert error-handling code for this exception.
            displayText.Append( genericUddiException.Message);
    
            return;
    
        }
    
        catch( Exception otherException)
        {
    
            // Insert error-handling code for this exception.
            displayText.Append( otherException.Message);
    
            displayText.Append( otherException.GetType().ToString());
    
            return;
    
        }
    
    
        foreach( TModelInfo tModelItem in tModelListResult.TModelInfos )
        {
    
            if("ntis-gov:naics:2002" == tModelItem.Name.Text)
            {
    
                displayText.Append( "\r\n" + tModelItem.Name.Text );
    
                GetRootCategoriesExample(validConnection, tModelItem, displayText);
    
            }
    
        }
    
    }
    

Implementation Steps In Visual Basic .NET

  1. Create a method that accepts the following parameters:

    • A valid UddiConnection object.

    • A StringBuilder object. This object contains the information about the categorization schemes.

    Sub GetCategorizationSchemesExample(ByVal validConnection As UddiConnection, _
    ByVal displayText As StringBuilder)
    
    End Sub
    
  2. Create an instance of the FindTModel class. This object creates the message that is sent to the UDDI server to get the categorization schemes.

    Sub GetCategorizationSchemesExample(ByVal validConnection As UddiConnection, _
    ByVal displayText As StringBuilder)
    
        Dim getTModel As New FindTModel
    
    End Sub
    
  3. Using the Add method, set the CategoryBag property of the FindTModel object to a specified category reference.

    Sub GetCategorizationSchemesExample(ByVal validConnection As UddiConnection, _
                                        ByVal displayText As StringBuilder)
    
        Dim getTModel As New FindTModel
    
        getTModel.CategoryBag.Add(TModels.CommonCanonical.UddiOrgTypes, _
                                  "categorization", _
                                  "Categorization (taxonomy)")
    
    
    
    End Sub
    
  4. Create a TModelList variable that will contain the results of the message from the UDDI server.

    Sub GetCategorizationSchemesExample(ByVal validConnection As UddiConnection, _
    ByVal displayText As StringBuilder)
    
        Dim getTModel As New FindTModel
    
        getTModel.CategoryBag.Add(TModels.CommonCanonical.UddiOrgTypes, _
                                  "categorization", _
                                  "Categorization (taxonomy)")
    
        Dim tModelListResult As TModelList
    
    
    
    End Sub
    
  5. Transmit the request to the UDDI server by using the Send method with the UddiConnection object passed into the method. The TModelList variable receives the results of the request.

    Sub GetCategorizationSchemesExample(ByVal validConnection As UddiConnection, _
    ByVal displayText As StringBuilder)
    
        Dim getTModel As New FindTModel
    
        getTModel.CategoryBag.Add(TModels.CommonCanonical.UddiOrgTypes, _
                                  "categorization", _
                                  "Categorization (taxonomy)")
    
        Dim tModelListResult As TModelList
    
        tModelListResult = getTModel.Send(validConnection)
    
    
    
    End Sub
    
  6. Handle any exceptions that might occur by using a Try...Catch statement. The example code shows some exceptions that you might want to handle. Wrap the request in the Try statement and handle any exceptions in the Catch statement.

    Sub GetCategorizationSchemesExample(ByVal validConnection As UddiConnection, _
    ByVal displayText As StringBuilder)
    
        Dim getTModel As New FindTModel
    
        getTModel.CategoryBag.Add(TModels.CommonCanonical.UddiOrgTypes, _
                                  "categorization", _
                                  "Categorization (taxonomy)")
    
        Dim tModelListResult As TModelList
    
        Try
    
            tModelListResult = getTModel.Send(validConnection)
    
        Catch badURL As InvalidUrlPassedException
    
            ' Insert error-handling code for this exception.
            displayText.Append("Bad URL")
    
            Return
    
        Catch genericUddiException As UddiException
    
            ' Insert error-handling code for this exception.
            displayText.Append(genericUddiException.Message)
    
            Return
    
        Catch otherException As Exception
    
            ' Insert error-handling code for this exception.
            displayText.Append(otherException.Message)
    
            displayText.Append(otherException.GetType().ToString())
    
            Return
    
        End Try
    
    
    
    End Sub
    
  7. Iterate through the collection in the TModelInfos property to get information about the categorization schemes. In this example, the name of each categorization scheme is added to the StringBuilder object that displays information about categorization schemes.

    Sub GetCategorizationSchemesExample(ByVal validConnection As UddiConnection, _
    ByVal displayText As StringBuilder)
    
        Dim getTModel As New FindTModel
    
        getTModel.CategoryBag.Add(TModels.CommonCanonical.UddiOrgTypes, _
                                  "categorization", _
                                  "Categorization (taxonomy)")
    
        Dim tModelListResult As TModelList
    
        Try
    
            tModelListResult = getTModel.Send(validConnection)
    
        Catch badURL As InvalidUrlPassedException
    
            ' Insert error-handling code for this exception.
            displayText.Append("Bad URL")
    
            Return
    
        Catch genericUddiException As UddiException
    
            ' Insert error-handling code for this exception.
            displayText.Append(genericUddiException.Message)
    
            Return
    
        Catch otherException As Exception
    
            ' Insert error-handling code for this exception.
            displayText.Append(otherException.Message)
    
            displayText.Append(otherException.GetType().ToString())
    
            Return
    
        End Try
    
        Dim tModelItem As TModels.TModelInfo
    
        For Each tModelItem In tModelListResult.TModelInfos
    
                displayText.Append(vbCrLf + tModelItem.Name.Text)
    
        Next
    
    End Sub
    
  8. Optional. To find the root categories of each categorization scheme, you can create an optional method that finds the root categories. For more information about creating a method that finds root categories, see Finding Root Categories. This example calls the optional method for the ntis-gov:naics:2002 categorization scheme only.

    Sub GetCategorizationSchemesExample(ByVal validConnection As UddiConnection, _
                                        ByVal displayText As StringBuilder)
    
        Dim getTModel As New FindTModel
    
        getTModel.CategoryBag.Add(TModels.CommonCanonical.UddiOrgTypes, _
                                  "categorization", _
                                  "Categorization (taxonomy)")
    
        Dim tModelListResult As TModelList
    
        Try
    
            tModelListResult = getTModel.Send(validConnection)
    
        Catch badURL As InvalidUrlPassedException
    
            ' Insert error-handling code for this exception.
            displayText.Append("Bad URL")
    
            Return
    
        Catch genericUddiException As UddiException
    
            ' Insert error-handling code for this exception.
            displayText.Append(genericUddiException.Message)
    
            Return
    
        Catch otherException As Exception
    
            ' Insert error-handling code for this exception.
            displayText.Append(otherException.Message)
    
            displayText.Append(otherException.GetType().ToString())
    
            Return
    
        End Try
    
        Dim tModelItem As TModels.TModelInfo
    
        For Each tModelItem In tModelListResult.TModelInfos
    
            If tModelItem.Name.Text = "ntis-gov:naics:2002" Then
    
                displayText.Append(vbCrLf + tModelItem.Name.Text)
    
                GetRootCategoriesExample(validConnection, tModelItem, displayText)
    
            End If
    
        Next
    
    End Sub
    

See Also

Reference

FindTModel
InquireUrl
ExtensionsUrl
UddiConnection
CategoryBag
Send
TModelInfos
Name

Concepts

Specifying Access Points

Send comments about this topic to Microsoft.