Throughout this book, each time you have used a web service within a program, you have used the Add Web Reference dialog box shown in Figure 6.5 to add a reference for a web service to your program.
If you examine the Add Web Reference dialog box, you will see references to the UDDI Directory. In general, the directory is a site on the Web that tracks information about web services that programmers have made available for others to use. The UDDI registry does
not store web services. Rather, the registry provides information about web services that reside as sites around the Web.
If you click on the directory link, the dialog box will display a form you can use to search for web services by name, development company, and category, as shown in Figure 6.6.
Figure 6.5: Using the Add Web Reference dialog box to add a web service to a program
Figure 6.6: Searching for web services using the UDDI directory
Programmers often think of the UDDI directory repository in terms of a phonebook. The directory’s “white pages” feature web services by name. The “yellow pages” group web services by type (category), and the “green pages” provide technical information on how a programmer can use a web service.
The UDDI registry was originally founded by IBM, Ariba, and Microsoft. The registry’s goal is to create a registry that contains links to millions of services created by programmers worldwide. You can learn specifics about UDDI at www.uddi.org, as shown in Figure 6.7.
Figure 6.7: Learning specifics about UDDI at the UDDI website
To help you get started, the UDDI registry provides registered users with a test registry at which they can practice the steps involved in uploading specifics about a web service. To begin, you must create a username and password at www.uddi.org. After that, you can create entries for your business and technical models.
As it turns out, UDDI.org is not the only organization whose charter is to drive the use of web services. IBM also worked with Sun Microsystems to create a web service repository at www.ebxml.org, shown in Figure 6.8. The charter of ebxml is to “enable enterprises of any size in any location to meet and conduct business through the exchange of XML-based messages.”
Figure 6.8: Learning more about XML-based content at the ebxml website
Behind the scenes, the UDDI registry consists of five key data structures, which Table 6.1 briefly describes. When programmers search the registry, the UDDI software makes extensive use of these data structures to locate and retrieve specifics about available web services.
Provides binding information (an entry point) for the service being posted
Describes the business for which information is being registered
Describes the name and description of the service being posted
Creates a relationship between two or more businessEntity structures (such as a subsidiary relationship)
A collection of data that uniquely identifies the service
The UDDI registry describes each of the data structures using XML entries. For example, the following statements show the XML definition for the businessEntity data structure:
<element name = "businessEntity"> <type content = "elementOnly"> <group order = "seq"> <element ref = "discoveryURLs" minOccurs = "0" maxOccurs = "1"/> <element ref = "name"/> <element ref = "description" minOccurs = "0" maxOccurs = "*"/> <element ref = "contacts" minOccurs = "0" maxOccurs = "1"/> <element ref = "businessServices" minOccurs = "0" maxOccurs = "1"/> <element ref = "identifierBag" minOccurs = "0" maxOccurs = "1"/> <element ref = "categoryBag" minOccurs = "0" maxOccurs = "1"/> </group> <attribute name = "businessKey" minOccurs = "1" type = "string"/> <attribute name = "operator" type = "string"/> <attribute name = "authorizedName" type = "string"/> </type> </element>
By examining the XML entries that describe the UDDI data structures, you can quickly understand each structure’s purpose and contents.
Using the UDDI registry, you can search for web services in much the same way you would use any web-based search engine. Figure 6.9, for example, shows a screen that shows the result of a query for web services that provide encryption.
Figure 6.9: Searching the UDDI registry for a web service that provides encryption
In addition to providing a search-engine interface, the UDDI website provides a software development kit (SDK) that contains an application program interface (API) that programs can use to query the site. To download the UDDI software development kit, visit the Microsoft website and search for UDDI SDK.
Using the software development kit, you can search for a web service or add or delete information about your own web service within the registry. The following Visual Basic code fragment illustrates the type of processing a program must perform to create entries within the UDDI registry. The code fragment first creates a tModel object. Then, the program creates a businessEntity, businessService, and bindingTemplate. To use the code, you must insert the specifics about your business and your web service. In addition, you must provide the username and password you established with UDDI.org:
Publish.Url = "https://test.uddi.microsoft.com/publish" Publish.User = "YourUsername" Publish.Password = "YourPassword" ' Create a tModel Dim stm As New SaveTModel() stm.TModels.Add() stm.TModels(0).Name = "Web Service URN here" stm.TModels(0).Descriptions.Add("en", "Model description") stm.TModels(0).OverviewDoc.OverviewURL = "URL of WSDL" stm.TModels(0).CategoryBag.Add("uddi-org:types", "wsdlSpec") Dim sTModelKey As String = "" Try Dim tmd As New TModelDetail() tmd = stm.Send() sTModelKey = tmd.TModels(0).TModelKey Catch ue As UddiException MessageBox.Show(ue.Message) Catch ex As Exception MessageBox.Show(ex.Message) End Try ' Create a BusinessEntity Dim sb As New SaveBusiness() sb.BusinessEntities.Add() sb.BusinessEntities(0).AuthorizedName = "Your Business Name" sb.BusinessEntities(0).Descriptions.Add("en", _ Ä "Your Business Description") ' Create a BusinessService sb.BusinessEntities(0).BusinessServices.Add() sb.BusinessEntities(0).BusinessServices(0).BusinessKey = _ Ä "Web Service Name" sb.BusinessEntities(0).BusinessServices(0).Descriptions.Add("en", _ Ä "Description of Service") ' Create a BindingTemplate sb.BusinessEntities(0).BusinessServices(0).BindingTemplates.Add() sb.BusinessEntities(0).BusinessServices(0)._ ÄBindingTemplates(0).Descriptions.Add("en", "Description of Binding") sb.BusinessEntities(0).BusinessServices(0)._ ÄBindingTemplates(0).AccessPoint.Text = "Access Point" sb.BusinessEntities(0).BusinessServices(0)._ ÄBindingTemplates(0).AccessPoint.URLType = _ ÄMicrosoft.Uddi.Api.URLType.Http ' Create a tModelInstanceInfo sb.BusinessEntities(0).BusinessServices(0).BindingTemplates(0)._ Ä TModelInstanceDetail.TModelInstanceInfos.Add() sb.BusinessEntities(0).BusinessServices(0).BindingTemplates(0)._ ÄTModelInstanceDetail.TModelInstanceInfos(0).Descriptions.Add("en", _ Ä"model Description") ' Use tModelKey string from above sb.BusinessEntities(0).BusinessServices(0).BindingTemplates(0)._ ÄTModelInstanceDetail.TModelInstanceInfos(0).TModelKey = sTModelKey Try Dim bd As New BusinessDetail() bd = sb.Send() Catch ue As UddiException MessageBox.Show(ue.Message) Catch ex As Exception MessageBox.Show(ex.Message) End Try