September 17, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

Enterprise UDDI Services

  • November 12, 2003
  • By Thiru Thangarathinam
  • Send Email »
  • More Articles »

Web Services Discovery with UDDI

As mentioned before, apart from using the Web-based interface provided by the Enterprise UDDI Services to register/query Web services, you can also use the programmatic API for performing the same set of operations. In this section, we will take a look at an example application that uses the UDDI SDK for querying the Enterprise UDDI Services to search for a specific Web service. Before we take a look at the code required to implement this, let us understand the role of UDDI Services in the development steps that one will follow for consuming a Web service.

  • A Web services consumer seeks an application functionality that is provided by another application. The consumer can use the UDDI discovery methods provided by the Enterprise UDDI Services.
  • Consumer searches the Enterprise UDDI Services for the desired functionality. The consumer can do this programmatically or declaratively.
  • After locating the required Web service, the consumer retrieves the WSDL service description using the information found on the Enterprise UDDI services.
  • The consumer then creates a client application, which uses SOAP messaging, from the WSDL service description.
  • Run the client application that will connect to the Web service.

Let us start by creating a new Visual C# Windows Application named UddiQueryExample. Once the project is created, we will add a label control, a command button, and a textbox to the form and name them lblSearch, btnSearch, and txtName, respectively. Because we are going to be using the UDDI SDK for querying the Enterprise UDDI Services, you also need to download and install the UDDI SDK. Once installed, you can then reference it from within the project by using the Add Reference option from Visual Studio.NET.

After that, add the following lines of code to import the required UDDI namespaces.

using Microsoft.Uddi;
using Microsoft.Uddi.Services;
using Microsoft.Uddi.TModels;

Then, modify the Click event of the btnSearch control to look like the following.

private void btnSearch_Click(object sender, System.EventArgs e)
{
  try
  {
    // Create a connection to the UDDI node that is to be accessed.
    UddiConnection conn = new
      UddiConnection("http://localhost/uddi/inquire.asmx");
    // Create an object to find a business.
    FindService fs = new FindService(txtName.Text);
    // Send the prepared FindBusiness request over the connection.
    ServiceList servList = fs.Send(conn);
    // Display the service name and unique identifying key.
    foreach (ServiceInfo servInfo in servList.ServiceInfos)
    {
      MessageBox.Show("Service: " + servInfo.Names[0].Text + "
        " + servInfo.ServiceKey);
    }
  }
  catch (Microsoft.Uddi.UddiException ex)
  {
    MessageBox.Show("UDDI Exception: " + ex.Message);
  }
  catch (Exception gen)
  {
    MessageBox.Show("General Exception: " +  gen.Message);
  }
}

Let us walk through the above lines of code. We start by creating an instance of the UddiConnection object and specifying the Inquire Web service of the Enterprise UDDI Services to the constructor of the UddiConnection object. Then, we create an instance of the FindService object, passing in the keyword of the Web service to search. Then, we invoke the Send method of the FindService object, passing in the previously created UddiConnection object as an argument. The Send method returns the list of available services in the form of a ServiceList object. The ServiceList object exposes a property named ServiceInfos that basically returns an array of ServiceInfo objects.

Once we have a reference to this array, we then manually loop through all the individual elements in the array and display them in the message box. If there is an exception while executing the try block, the control is then transferred to the catch block where we catch both the UDDI specific exceptions as well as general exceptions. If you execute the code by pressing F5, and then enter "Simple Service" in the search textbox, the code will invoke the Enterprise UDDI Services Inquire Web service and display information about the Web service named "Simple Service" that we created in the previous section. To download and install the UDDI SDK, please go to the following MSDN link (http://msdn.microsoft.com/library/default.asp?url=/downloads/list/websrvuddi.asp).

Enterprise UDDI Services Usage Scenarios

There are several common business scenarios that will benefit from the Enterprise UDDI Services. These scenarios fall into two categories:

  • Performing inquiries to find information about services offered—Here you can use the features supplied by the UDDI SDK to programmatically query UDDI for Web services or you can also directly go to the Enterprise UDDI Services Web interface and search for available Web services that meet your criteria.
  • Registering software that uses Web services—The main purpose of the UDDI registry is to let others know you exist and that you have Web services exposed that can be used to interact with your business. Common examples of these services will be for business document interchange—for documents such as purchase orders, invoices, shipping notices, and so forth. Depending on the tools and products you use to manage your exposed services, you'll want to use the UDDI registry to advertise technical information about your service.

Many times, software will need to interact with a UDDI registry to find out information about Web services exposed by existing or potential business partners. For example, given a choice between two potential partners that offer equivalent goods or services, a business might choose the one that already has compatible software. Sometimes, the business need is to locate a service that you can use, regardless of the business that provides it. For a certain class of base services, such as ticker price, time check, or basic math calculations, any good implementation of a well-known service will suffice. For these types of service requests, software may simply want to find an available implementation of a service that implements a particular widely used specification, and invoke it. By using Enterprise UDDI Services, you can enable these kinds of scenarios.

For the developers, Microsoft offers UDDI client support through several tools including Visual Studio .NET, the Office XP Web Services Toolkit, and the UDDI software development kit (SDK). Microsoft Visual Studio .NET provides native support for UDDI Services through "Add Web Reference," enabling developers to easily discover Web services and other programmatic resources in UDDI for use in building dynamic applications.

Download of Files

Conclusion

As you can see, Enterprise UDDI Services allows organizations to manage their Web services by making them available in a centralized location that can be easily searched. And for the developers, now they have an easy way to search for Web services, and reuse them by leveraging the rich client-side support offered by various Microsoft tools. This can improve developer and IT productivity, resulting in lower total cost of ownership (TCO) and more reliable and manageable applications.

About the Author

Thiru Thangarathinam has six years of experience in architecting, designing, developing, and implementing applications using Object Oriented Application development methodologies. He also possesses a thorough understanding of the software life cycle (design, development, and testing). He holds several certifications, including MCAD for .NET, MCSD, and MCP. Thiru is an expert with ASP.NET, .NET Framework, Visual C# .NET, Visual Basic .NET, ADO.NET, XML Web Services, and .NET Remoting and holds. Thiru has authored numerous books and articles. He can be reached at thiruthangarathinam@yahoo.com.

# # #





Page 2 of 2



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel