Using Visual C++ 6.0

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

Visual C++ 6.0 COM developers can use the Microsoft UDDI SDK after performing the following steps.

To use the Microsoft UDDI SDK with Visual C++ 6.0, perform the following steps.

To Use Visual C++ 6.0

  1. Create a new project.

  2. Use the following statements to import the required component definitions, where PATH is the path to the type library files.

    #import "PATH\mscorlib.tlb"
    #import "PATH\Microsoft.Uddi.tlb" no_namespace named_guids
    

    The first import statement includes information about every type in the .NET Framework. This type library is required since several of the classes in the UDDI SDK use these types. The second import statement includes the information about the Microsoft.Uddi components and the no_namespace option instructs the preprocessor to discard the namespace present in the .tlb file when it generates the .tlh file.

Example Code

The following example shows how to use the C++ programming language to save a new business.

#include "stdafx.h"
#include <windows.h&gt;
 
#import "<file path goes here&gt;\mscorlib.tlb"
#import "<file path goes here&gt;Microsoft.Uddi.tlb" no_namespace named_guids
 
int main(int argc, char* argv[])
{
    try
    {
        CoInitialize( NULL );
 
        //
        // Info for UddiConnection.
        //
        OLECHAR *pwszUsername = L"*** your username ***";
        OLECHAR *pwszPassword = L"*** your password ***";
        OLECHAR *pwszPublishUrl = L"** your publish url ***";
 
        //
        // Info for the new BusinessEntity we're about to make.
        //
        OLECHAR *pwszBusinessName = L"test business from C++/COM";
        OLECHAR *pwszContactName = L"contact name";
        OLECHAR *pwszEmailAddress = L"asdf@fabrikam.com";
 
        //
        // Create the UddiConnection, set it to Uddi Authentication, and supply it
        // with a username, password, and Url to the Publish API.
        //
        _UddiConnectionPtr spConn;
        spConn.CreateInstance( CLSID_UddiConnection );
        spConn->Username = pwszUsername;
        spConn->Password = pwszPassword;
        spConn->PublishUrl = pwszPublishUrl;
        spConn->AuthenticationMode = AuthenticationMode_UddiAuthentication;
 
        //
        // Setup the contact.
        //
        _ContactPtr spContact;
 
        spContact.CreateInstance( CLSID_Contact );
        spContact->PersonName = pwszContactName;
        spContact->Emails-&gt;Add_3( pwszEmailAddress );
 
        //
        // Create the business, and set its name & primary contact.
        //
        _NamePtr spName;
        spName.CreateInstance( CLSID_Name );
        spName->Text = pwszBusinessName;
 
        _BusinessEntityPtr spBusiness;
        spBusiness.CreateInstance( CLSID_BusinessEntity );
        spBusiness->Names-&gt;Add( spName );
        spBusiness->Contacts-&gt;Add( spContact );
 
        //
        // Put our new business in a SaveBusiness message, and send
        // it to the UDDI Server.
        //
        _SaveBusinessPtr spSaveBusiness;
        spSaveBusiness.CreateInstance( CLSID_SaveBusiness );
        spSaveBusiness->BusinessEntities-&gt;Add( spBusiness );
 
        _BusinessDetailPtr spBusinessDetail = spSaveBusiness->Send( spConn );
 
        //
        // Get the UUID of our newly created business, and show it
        // to the world.
        //
        _bstr_t key = spBusinessDetail->BusinessEntities-&gt;Item[ 0 ]-&gt;BusinessKey;
        wprintf( L"new business's key = %s\n", static_cast<wchar_t *&gt;(key) );
 
        CoUninitialize();
        return 0;
    }
    catch( _com_error comError ) 
    {
        _bstr_t desc = comError.Description();
        wprintf( L"The following UDDI error occurred:\n%s\n", static_cast<wchar_t *&gt;(desc) );
        CoUninitialize();
        return 0;
    }
 catch( ... )
    {
        wprintf( L"some other exception occurred.\n" );
        CoUninitialize();
        return 0;
    }
}

Send comments about this topic to Microsoft.