Chapter 7. Establishing Connection

Interacting with a Universal Description Discovery Integration (UDDI) registry is accomplished using the UDDI eXtended Markup Language (XML)-based Application Programming Interfaces (APIs), as we discuss in Chapter 5. Once the business entity, its services, and the publisher relationships are modeled, as we describe in Chapter 6, applications can be developed to interact with the UDDI registry programmatically. Previously, we saw how manual interaction is possible using the Web-based interface provided by most UDDI implementations.

The UDDI applications in the next few chapters reflect the modeling decisions made during the design phase. The applications may be written in either .NET or Java programming paradigms. Recall that there are three language- or platform-specific APIs that relieve the developer from creating the appropriate UDDI XML messages to perform various UDDI functions:

  • UDDI .NET Software Development Kit (SDK)

  • UDDI4J

  • Java XML API for XML Registries (JAXR)

These APIs allow applications, based on a specific platform or language, to communicate with a UDDI registry. The UDDI registry could be either private or public. In the next few chapters, we explain how to use the UDDI4J and UDDI .NET SDK to perform the tasks of a service publisher and a service consumer. JAXR is a broader API that not only interacts with UDDI registries but other XML registries, for example, the ebXML Registry. JAXR is an evolving API specification and is not covered in this book. More information on JAXR can be obtained from Sun Microsystems and the Java Community Process (JCP) Web site.

In the following discussion on the UDDI .NET SDK APIs and UDDI4J, general familiarity of programming is assumed. The reader is also assumed to be well versed with Java and C# programming languages. Several resources are available for more information on these programming languages. To run the examples provided in this book, the software packages for the two APIs are required. Appendices B and D provide more information on how to obtain and install both of these packages.

Communication Points of a UDDI Registry

To demonstrate the use of the C# and Java APIs, we walk through the business case of a service provider that wishes to publish its service within the Universal Business Registry (UBR) and a service consumer that needs to find a specific service within the UBR and then caches it locally for frequent use. Figure 7.1 depicts the interaction patterns we demonstrate in the next few chapters.

Interaction patterns demonstrated through examples.

Figure 7.1. Interaction patterns demonstrated through examples.

Before the business case can be demonstrated, however, a certain familiarity with the underlying APIs is essential. In this chapter, we focus on the foundational functionality such as submitting credentials and getting information from a UDDI registry through its communication points. The APIs associated with these functionalities are used throughout the rest of the book.

Noticeably, interaction with a UDDI registry via its communication points falls in two categories — publishing and inquiry. All the UDDI APIs can be classified into these categories. The communication points of the UDDI registry are also associated with these two categories: Publish URL and Inquiry URL. These URLs receive the corresponding UDDI API calls.

Publish APIs

The publish APIs receive publish information about a business entity and the services and interaction specifications it offers. The publish APIs use a dedicated Uniform Resource Locator (URL) called publish URL. The publish URL accepts XML messages that perform tasks, including:

  • Business entity registration (including deletion)

  • Service registration (including deletion)

  • Service binding definitions (including deletion)

  • Taxonomy registration (including deletion)

  • Interaction specification registration (including deletion)

  • Business relationships assertion (including deletion)

For a complete list, refer to the latest UDDI API Specification document. Figure 7.2 depicts the role of the Publish URL in a UDDI registry. The publish URLs for the UBR operators would normally take the following form:

UDDI interactions supported on publish URL.

Figure 7.2. UDDI interactions supported on publish URL.

uddi.mycompany.com/publish 

Notice that these URLs provide secure communication because these URLs accept sensitive data such as username and password. This type of information must be encrypted when it travels over an open network such as the Internet.

Inquiry APIs

Like the publish APIs, the inquiry APIs also use a dedicated URL at a registry. This URL can be used to retrieve information about registered entities, such as businesses, services, and tModels, at the registry. The inquiry URL accepts XML messages to perform tasks, including:

  • Business entity discovery (and getting registration details)

  • Service discovery (and getting registration details)

  • Service binding discovery (and getting registration details)

  • Taxonomy discovery (and getting registration details)

  • Interaction specification discovery (and getting registration details)

  • Business relationships discovery

For a complete list, refer to the latest UDDI API Specification document. Figure 7.3 depicts the role of the inquiry URL in a UDDI registry.

UDDI interactions supported on inquiry URL.

Figure 7.3. UDDI interactions supported on inquiry URL.

The inquiry URLs for the UBR operators would normally take the following form:

uddi.mycompany.com/inquiry 

Unlike the publish URL, the inquiry URL does not use a secure mode of communication. This is because the inquiry APIs do not require any sensitive data such as usernames and passwords. The information being retrieved is also considered public domain. The publisher should be careful about the kind of data that is published at a UDDI registry. Any user that has access to the registry, whether registered with the registry or not, can access the information published by the publisher. However, a private UDDI registry with greater access control may implement more restrictive policies. An invitation-only or elaborate registration process may precede access to the registry. We discuss private registries in greater detail in Chapter 10.

Establishing Connection

The GettingStarted applications test connectivity with both publish and inquiry URLs through the UDDI .NET SDK and UDDI4J software packages and thus provide a foundation for how to programmatically interact with a UDDI registry. The publish URL test consists of getting an authentication token from the UDDI registry and the inquiry URL test comprises of testing information retrieval from the UDDI registry.

UDDI .NET SDK

The C# test application GettingStarted.exe is the application that uses the UDDI .NET APIs to connect to the Microsoft UBR and test the UBR Publish and Inquiry URLs. Before we describe applications, we need to first explain the basics of programming with the UDDI .NET SDK APIs.

Incorporating UDDI .NET APIs

UDDI .NET SDK is used by adding a reference to the Microsoft.UDDI.SDK package in your Visual Studio .NET solution. This can be done via Project → Add Reference from the Visual Studio .NET menus. Adding references provides necessary information while compiling a program that uses certain functionality from a specific library.

Let’s take a look at the GettingStarted.cs to review how to use the UDDI .NET SDK APIs in the test application. After adding the reference to the SDK, you also need to include the following declarations:

Example . GettingStarted.cs

using Microsoft.Uddi; 
using Microsoft.Uddi.Business; 
using Microsoft.Uddi.Service; 
using Microsoft.Uddi.Binding; 
using Microsoft.Uddi.ServiceType; 
using Microsoft.Uddi.Api; 
using Microsoft.Uddi.Authentication; 

These declarations ensure that the appropriate UDDI functionality is available to the application via the APIs. There is also a configuration file, app.config, that needs to be populated to run the .NET test application. Microsoft has migrated away from a text-based property file to an XML-formatted property file in the .NET environment. The properties take the following form:

<add key="settingName" value="settingValue"/> 

In the publish URL test example, the configuration values required are the UDDI UBR username and password. These are required because only registered and authorized users are allowed to publish to the UBR.

Example . App.config

<?xml version="1.0" encoding="Windows-1252"?> 
<configuration> 
  <appSettings> 
    <add key="uddiUserName" 
        value="[email protected]" /> 
    <add key="uddiPassword" value="****" /> 
  </appSettings> 
</configuration> 

The UBR URLs are not set in this configuration file. Those are explicitly stated in the application, but may also be in a configuration file.

Example . GettingStarted.cs

publishURL.Items.Add("https://uddi.rte.microsoft.com/publish"); 
inquiryURL.Items.Add("http://uddi.rte.microsoft.com/inquire"); 

We are now ready to dive into the actual code and see how to test the communication point URLs for the UBR using the UDDI .NET APIs.

Checking Publish Configuration

The APIs provided by the .NET SDK perform the same basic function as the UDDI4J APIs while being based on a different paradigm. The Publish methods are used to publish information to the registry. Publish.AuthenticationMode is required to force the authentication to happen at the UBR and not a third-party verification point. UDDI does allow integration with a stronger security mechanism as discussed in Chapter 10.

The API GetAuthToken processes and receives an authentication token from the UBR. Authentication tokens are evidence that an application has presented a valid username and password pair for use of the UBR. Subsequent interactions with the publish URL will require presentation of this token and, as such, it is important to obtain the authentication token prior to any other publish URL activity. The following code demonstrates the usage of these APIs:

Example . GettingStarted.cs

Publish.AuthenticationMode = 
   AuthenticationMode.UddiAuthentication; 
Publish.Url = publishURL.Text; 
Publish.User = 
   ConfigurationSettings.AppSettings["uddiUserName"]; 
Publish.Password = 
   ConfigurationSettings.AppSettings["uddiPassword"]; 
GetAuthToken gat = new GetAuthToken(); 
gat.UserID = Publish.User; 
gat.Credentials = Publish.Password; 
AuthToken at = gat.Send(); 
appendToMessageWindow("UDDI Operator:"+at.Operator); 
appendToMessageWindow("
Authentication Token: 

" + 
   at.AuthInfo); 

Using the above code, we retrieve the authentication token as well as the UDDI operator name that we are interacting with. There are other Publish-type APIs that support the other publishing possible with the UDDI registry. These are discussed in Chapter 8.

Checking Inquiry Configuration

The UDDI .NET SDK provides APIs for discovering resources (services, businesses, tModels) that satisfy a certain criteria. In the example to test the inquiry URL, we discover the uddi-org:inquiry v2 tModel using the FindTModel method. There are several UDDI XML messages for different types of discovery. These other Find-type APIs are discussed in Chapter 9. In this example, we focus on establishing connection with the inquiry URL.

The array of tModels returned can be displayed reading the TmodelInfos values. The relevant code is shown below:

Example . GettingStarted.cs

Inquire.Url = inquiryURL.Text; 
FindTModel ftm = new FindTModel(); 
appendToMessageWindow("Searching for tModel 
   "uddi-org:inquiry_v2""); 
ftm.Name = "uddi-org:inquiry_v2"; 
TModelList tml = ftm.Send(); 

appendToMessageWindow("
The TModel Name: " + 
   tml.TModelInfos[0].Name); 
appendToMessageWindow("
The TModel Key: " + 
   tml.TModelInfos[0].TModelKey); 

Recall from Chapter 5 that the APIs essentially prevent the developer from having to manually format the relevant UDDI XML-messages. The XML messages created by the UDDI .NET APIs are very similar to those shown in the UDDI4J discussion.

In Action

After loading GettingStarted.cs in Visual Studio .NET, simply compile and execute. Successful execution of both the Test Publisher URL and Test Inquiry URL are shown in Figures 7.4 and 7.5.

Test publisher URL results.

Figure 7.4. Test publisher URL results.

Test inquiry URL results.

Figure 7.5. Test inquiry URL results.

UDDI4J

The Java test application GettingStarted.class is the application that uses the UDDI4J APIs to connect to the Microsoft UBR and test the UBR URLs. UDDI4J needs to be configured as per the setup of your environment. For example, the firewall proxy needs to be identified, logging needs to be turned on or off, and so on. Appendix B explains properties that are used in setting up UDDI4J for all the example applications. The attributes configured are found in env.prop. Both these files are in the Shared subdirectory.

Checking Publish Configuration

There are two main UDDI4J APIs that we use to test the connectivity with the publish URL: UDDIProxy.get_authToken and UDDIProxy.get_registeredInfo.

Example . GettingStarted.java

AuthToken token = proxy.get_authToken(p.getProperty("userid"), 
   p.getProperty("password")); 
... 
RegisteredInfo ri = 
    proxy.get_registeredInfo(token.getAuthInfoString()); 
System.out.println("

UDDI Operator:"+ri.getOperator()); 

These calls get the authentication token that verifies the username and password and returns the UBR operator name you connected to. The get_authToken API forms the appropriate XML message to obtain an authentication token as discussed in the .NET example.

This API is used for UBRs or private registries that do not have some other method of obtaining an authentication token or certificate, or that choose to use username and password-based authentication. This method returns an authToken object that contains a valid authInfo object that is used in subsequent calls to publisher API calls that require an authInfo value.

Checking Inquiry Configuration

GettingStarted.class also contains the UDDI4J APIs to test the inquiry URL. To test the inquiry URL, we discover the UDDI V2 Inquiry tModel: uddi-org:inquiry v2. To discover this tModel, we use the UDDIProxy.find tModel and other APIs specifically geared for processing tModel information.

Example . GettingStarted.java

TModelList tModelList = 
  proxy.find_tModel("uddi-org:inquiry_v2", null, null, null, 5); 
Vector tModelInfoVector = 
  tModelList.getTModelInfos().getTModelInfoVector(); 
for (inti=0;i<tModelInfoVector.size(); i++) 
{ 
... 
} 

The UDDIProxy.find_tModel API formats the XML message for locating a list of tModel entries that match a set of specific criteria. This method returns the list of tModels that fit your criteria. We discuss the find APIs in more detail in Chapter 9. This test application then displays the tModel name and key associated with it. A good test would be to match the returned tModel key with the uddi-org:inquiry_v2 key published in the UDDI specification. These two keys should match exactly.

As was the case in the .NET discussion, we explain the other important publish and inquiry UDDI4J APIs in the subsequent chapters.

In Action

Now that we are familiar with GettingStarted.java, let’s run it and see it in action. To run the test application, execute the following command:

c:> java GettingStarted 

If the UBR URLs are fine and connectivity is established, you will see the authentication token, as well as the tModel described earlier. Figure 7.6 depicts successful completion of the GettingStarted application.

Successful completion of GettingStarted.

Figure 7.6. Successful completion of GettingStarted.

Now that we have seen the result of the test, we should peek behind the scenes to see what the UDDI4J APIs actually do. Recall that they create the UDDI-specified XML messages to interact with the registry. In this case, we need XML messages for the following:

  • Getting the authentication token

  • Discovering the tModels

The following XML messages were created by the get_AuthToken API to retrieve the authentication token from the UBR.

Request body: 
<get_authToken cred="****" generic="2.0" 
   [email protected] 
   xmlns="urn:uddi-org:api_v2"/> 

Response body: 
<authToken generic="2.0" operator="Microsoft Corporation" 
   xmlns="urn:uddi-org:api_v2"> 
   <authInfo> ... </authInfo> 
</authToken> 

The following XML messages were created by the get_registeredInfo API to retrieve information of all registered resources by the authenticated user from the UBR.

Request body: 
<get_registeredInfo generic="2.0" xmlns="urn:uddi-org:api_v2"> 
   <authInfo>...</authInfo> 
</get_registeredInfo> 
Response body: 
<registeredInfo generic="2.0" operator="Microsoft Corporation" 
    xmlns="urn:uddi-rg:api_v2"> 
  <businessInfos> 
    <businessInfo businessKey="..."> 
      ... 
      <serviceInfos> 
        <serviceInfo businessKey="..." serviceKey="..."> 
        ... 
        </serviceInfo> 
      </serviceInfos> 
      ... 
    </businessInfo> 
    ... 
  </businessInfos> 

  <tModelInfos> 
    <tModelInfo tModelKey="..."> 
    ... 
    </tModelInfo> 
  ... 
  </tModelInfos> 
</registeredInfo> 

The following XML messages were created by the find_tModel API to discover the UDDI V2 tModel from the UBR.

Request body: 
<find_tModel generic="2.0" maxRows="5" 
   xmlns="urn:uddi-org:api_v2"> 
  <name>uddi-org:inquiry_v2</name> 
</find_tModel> 
Response body: 
<tModelList generic="2.0" operator="Microsoft Corporation" 
   truncated="false" xmlns="urn:uddi-org:api_v2"> 
  <tModelInfos> 
     <tModelInfo tModelKey="uuid:ac104dcc-d623-
452f-88a7-f8acd94d9b2b"> 
      <name>uddi-org:inquiry_v2</name> 
    </tModelInfo> 
  </tModelInfos> 
</tModelList> 

In the next chapter, we explain how to interact with a UDDI registry as a publisher in more detail.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset