|
Microsoft UDDI SDK 2.0 by Joe Mitchko
WSJ Vol 03 Issue 05 - pg.29
Listing 1: C# Code Example for Publishing a Web Service
using Microsoft.Uddi;
using Microsoft.Uddi.Businesses;
// Add the following lines to the Main method:
try
{
// Create a connection to the UDDI node that is to be accessed.
UddiConnection myConn = new UddiConnection(
"http://test.uddi.microsoft.com/inquire",
"https://test.uddi.microsoft.com/publish");
// Create authentication credentials for save operation.
myConn.AuthenticationMode = AuthenticationMode.UddiAuthentication;
myConn.Username = " *** insert your username *** ";
myConn.Password = " *** insert your password *** ";
// Create a named business entity.
BusinessEntity myBiz = new BusinessEntity(" *** insert your business name *** ");
// Use business entity to create an object to save a business.
SaveBusiness sb = new SaveBusiness(myBiz);
// Send the prepared save business request.
BusinessDetail savedBiz = sb.Send(myConn);
// Interpret the returned business detail to examine the
allocated business key.
Console.WriteLine("Business: " + savedBiz.BusinessEntities[0].Names[0].Text);
Console.WriteLine(" Allocated key: " + savedBiz.BusinessEntities[0].BusinessKey);
}
catch (Microsoft.Uddi.UddiException e)
{ Console.WriteLine("UDDI error: " + e.Message); }
catch (Exception gen)
{ Console.WriteLine("General exception: {0}", gen.Message); }
Listing 2: C# Code Example for Finding a Business in UDDI
using Microsoft.Uddi;
// Add the following lines to the Main method:
try
{
// Create a connection to the UDDI node that is to be accessed.
UddiConnection myConn = new UddiConnection
("http://test.uddi.microsoft.com/inquire");
// Create an object to find a business.
FindBusiness fb = new FindBusiness("Fabrikam");
// Send the prepared FindBusiness request over the connection.
BusinessList bizList = fb.Send(myConn);
// Report the summary result.
Console.WriteLine("Found " + bizList.BusinessInfos.Count + " businesses");
}
catch (Microsoft.Uddi.UddiException e)
{ Console.WriteLine("UDDI error: " + e.Message); }
catch (Exception gen)
{ Console.WriteLine("General exception: {0}", gen.Message); }
|