Home | | Service Oriented Architecture | UDDI - Vendor Implementations

Chapter: XML and Web Services : Building XML-Based Applications : Web Services Building Blocks: WSDL and UDDI

UDDI - Vendor Implementations

The first two public UDDI registries to be made available (for both development and beta production) are IBM’s (at http://www-3.ibm.com/services/uddi/) and Microsoft’s (at http://uddi.microsoft.com).

Vendor Implementations

 

The first two public UDDI registries to be made available (for both development and beta production) are IBM’s (at http://www-3.ibm.com/services/uddi/) and Microsoft’s (at http://uddi.microsoft.com). Both registries currently support UDDI 2.0, and both operator sites host production and test registries. As a result, it is possible to interact with both registries from either a Java or a Microsoft (Visual Basic or C#) platform.

In this section, we will focus on using the inquiry and publication APIs to interact with existing UDDI registries, starting with the Java platform.

 

UDDI4J (IBM)

 

UDDI4J is a Java-based implementation of the UDDI APIs written by IBM and released as open source. The home page for UDDI4J is http://oss.software.ibm.com/ developerworks/projects/uddi4j, but the UDDI4J package is included in IBM’s Web Services Toolkit (WSTK), which is available at http://www.alphaworks.ibm.com/ tech/webservicestoolkit. This section assumes you have installed a recent version

 

of Java as well as the WSTK.

 

The first example exercises the UDDI inquiry API. Our application, FindMyBusiness, searches the IBM test registry for all companies whose names begin with the letter T. The code for this example is provided in Listing 16.7.

 

LISTING 16.7  Inquiry API Application FindMyBusiness.java

 

import  com.ibm.uddi.*;

 

import com.ibm.uddi.datatype.business.*; import com.ibm.uddi.response.*;

 

import com.ibm.uddi.client.*; import org.w3c.dom.Element; import java.util.Vector; import java.util.Properties;

 

public  class  FindMyBusiness

 

{

 

public  static  void  main  (String  args[])

 

{

 

FindMyBusiness fmb = new FindMyBusiness (); fmb.run();

 

System.exit(0);

 

}

 

public  void  run()

 

{

 

UDDIProxy  proxy  =  new  UDDIProxy();

 

try

 

{

 

proxy.setInquiryURL (“http://www-3.ibm.com/services/uddi/testregistry/inquiryapi”);

 

}

 

catch  (Exception  e)

 

{

e.printStackTrace();

}

 

try

 

{

 

BusinessList bl = proxy.find_business(“T”, null, 0); Vector businessInfoVector =

 

bl.getBusinessInfos().getBusinessInfoVector(); for (int i = 0; i < businessInfoVector.size(); i++)

 

{

 

BusinessInfo bi = (BusinessInfo)businessInfoVector.elementAt(i); System.out.println(bi.getNameString());

 

}

 

}

 

catch  (UDDIException  e)

 

{

 

DispositionReport dr = e.getDispositionReport(); if (dr!=null)

 

{

 

System.out.println (“UDDIException” + “\n faultCode:” + e.getFaultCode() +

 

“\n  operator:”   +  dr.getOperator()  +

 

“\n  generic:”    +  dr.getGeneric()  +

 

“\n  errno:”       +  dr.getErrno()  +

 

“\n  errCode:”   +  dr.getErrCode()  +

 

“\n  errInfoText:”  +  dr.getErrInfoText());

 

}

 

e.printStackTrace();

 

}

 

catch  (Exception  e)

 

{

 

e.printStackTrace();

 

}

 

}

 

}

 

First, we initialize the UDDI Proxy object in the following line:

 

UDDIProxy  proxy  =  new  UDDIProxy();

 

The UDDI Proxy object contains all the methods we’ll need to access the UDDI registry. We then use the setInquiryURL method in the Proxy object to point to the proper reg-istry. We could have pointed to IBM’s production registry, either of Microsoft’s reg-istries, or another company’s registry. In addition, we can point to our own test registry, if we have one running.

 

Next, we call the find_business method of the Proxy object in the following line:

 

BusinessList  bl  =  proxy.find_business(“T”,  null,  0);

This takes three arguments:

 

   The search parameter (here, the letter “T”)

 

   A FindQualifiers object (here, set to null)

 

   The number of matches to return (0 indicating all matches)

 

We then place the results of this call into a Vector object. If an exception occurs, a UDDIException is thrown, which exposes a method that returns a DispositionReport object.

 

Next, let’s utilize the publication API in the application SaveMyBusiness, which is shown in Listing 16.8.

 

LISTING 16.8  Publish API Application SaveMyBusiness.java

 

import  com.ibm.uddi.*;

 

import com.ibm.uddi.datatype.business.*; import com.ibm.uddi.response.*;

 

import com.ibm.uddi.client.*; import org.w3c.dom.Element; import java.util.Vector; import java.util.Properties;

 

public  class  SaveMyBusiness  {

 

public  static  void  main  (String  args[])

 

{

 

SaveMyBusiness smb = new SaveMyBusiness (); smb.run();

 

System.exit(0);

 

}

 

public  void  run()

 

{

 

UDDIProxy  proxy  =  new  UDDIProxy();

 

try

 

{

 

proxy.setInquiryURL (“http://www-3.ibm.com/services/uddi/testregistry/inquiryapi”);

 

proxy.setPublishURL (“https://www-3.ibm.com/services/uddi/

testregistry/protect/publishapi”);

 

}

 

catch  (Exception  e)

 

{

 

e.printStackTrace();

}

 

try

 

{

 

System.out.println(“\nGet  authtoken”);

 

AuthToken token = proxy.get_authToken( “userid”, “password” ); System.out.println(“Returned authToken:” + token.getAuthInfoString()); System.out.println(“\nSave ‘My Business’”);

 

Vector  entities  =  new  Vector();

 

BusinessEntity be = new BusinessEntity(“”, “My Business”); entities.addElement(be);

 

BusinessDetail bd = proxy.save_business(token.getAuthInfoString(), entities);

 

}

 

catch  (UDDIException  e)

 

{

 

DispositionReport dr = e.getDispositionReport(); if (dr!=null)

 

{

 

System.out.println (“UDDIException” + “\n faultCode:” + e.getFaultCode() +

 

“\n  operator:”   +  dr.getOperator()  +

 

“\n  generic:”    +  dr.getGeneric()  +

 

“\n  errno:”       +  dr.getErrno()  +

 

“\n  errCode:”   +  dr.getErrCode()  +

 

“\n  errInfoText:”  +  dr.getErrInfoText());

 

}

 

e.printStackTrace();

 

}

 

catch  (Exception  e)

 

{

 

e.printStackTrace();

 

}

 

}

 

}

 

In this example, we initialize the Proxy object and the InquiryURL object as before, but now we also set the PublishURL object in the following line:

 

proxy.setPublishURL(”https://www-3.ibm.com/services/uddi/testregistry/ protect/publishapi”);

 

Recall that all publication API calls are conducted over HTTPS. Next, our application must log in to the registry by sending its username and password and obtaining an autho-rization token (AuthToken) in return:

 

AuthToken  token  =  proxy.get_authToken(  “userid”,  “password”  );

 

Next, we must create a new BusinessEntity object and populate it with the desired properties. Here, we are only defining its name:

 

Vector  entities  =  new  Vector();

 

BusinessEntity be = new BusinessEntity(“”, “My Business”); entities.addElement(be);

 

Finally, we pass our new BusinessEntity to the registry, along with our AuthToken:

 

BusinessDetail  bd  =  proxy.save_business(token.getAuthInfoString(),  entities);

 

This saves our BusinessEntity in the UDDI registry.

 

The Microsoft UDDI SDK

 

The Microsoft UDDI SDK is available at http://www.microsoft.com/downloads/ release.asp?ReleaseID=30880. The version used here is 1.5.2, which includes the UDDI SDK for Visual Studio 6, the UDDI Developer Edition 1.5 (Beta), and the UDDI

 

.NET SDK (Beta) for Visual Studio .NET. To run the UDDI SDK, you will need the fol-lowing Microsoft products:

 

   Windows 2000 Professional, Server, or Advanced Server

 

   Visual Studio .NET Beta 2

 

   SQL Server 2000 Desktop Engine (MSDE), Personal, Standard, or Enterprise Edition

 

First, let’s go through a simple Visual Basic example that uses the inquiry API, again looking for companies that begin with the letter T, as shown in Listing 16.9.

 

LISTING 16.9  Inquiry API Visual Basic Application FindMyBusiness.vb

 

Imports  Microsoft.Uddi

 

Imports  Microsoft.Uddi.Business

 

Imports  Microsoft.Uddi.Binding

 

Imports  Microsoft.Uddi.Service

 

Imports  Microsoft.Uddi.ServiceType

 

Module  SaveMyBusiness

 

Sub  Main()

 

Dim  myReq  As  New  UDDIEnv.RequestManager

 

Dim  reqEnv  As  New  UDDIEnv.Envelope

 

Dim  respEnv  As  UDDIEnv.Envelope

 

Dim  inqMsg  As  New  UDDI10.find_business

 

Dim  inqRsp  As  New  UDDI10.businessList

Dim  res  As  UDDI10.businessInfo

 

Set reqEnv.Plugin = inqMsg inqMsg.Name = “T”

 

Set respEnv = myReq.UDDIRequest(reqEnv) Set respEnv.Plugin = inqRsp

 

For Each res In inqRsp.businessInfos Debug.Print res.Name

 

Next

 

End  Sub

 

End  Module

 

First, we declare objects from the UDDI SDK, including the request manager, as well as envelopes and document objects for our request and response. Then we set up the request document with the request envelope:

 

Set  reqEnv.Plugin  =  inqMsg

 

Next, we set our search criteria:

 

inqMsg.Name  =  “T”

 

Then we send our request to the registry, obtaining a response envelope in return:

 

Set  respEnv  =  myReq.UDDIRequest(reqEnv)

 

Then we add the document object to the envelope to read the response and loop through the results:

 

Set  respEnv.Plugin  =  inqRsp

 

For  Each  res  In  inqRsp.businessInfos

 

Debug.Print  res.Name

 

Next

 

Next, we cover an example that uses the publication API to register a business in a reg-istry. The example in Listing 16.10 uses the publication API by first building a tModel.

 

LISTING 16.10 Publish API Visual Basic Application SaveMyBusiness.vb

 

Imports  Microsoft.Uddi

 

Imports  Microsoft.Uddi.Business

 

Imports  Microsoft.Uddi.Binding

 

Imports  Microsoft.Uddi.Service

 

Imports  Microsoft.Uddi.ServiceType

 

Module  SaveMyBusiness

 

Sub  Main()

 

Publish.Url  =  “https://test.uddi.microsoft.com/publish”

Publish.User  =  “username”

 

Publish.Password  =  “password”

 

Dim tm As New SaveTModel() tm.TModels.Add()

 

tm.TModels(0).Name = “URN of tModel” tm.TModels(0).Descriptions.Add(“en”, “Description of tModel”) tm.TModels(0).OverviewDoc.OverviewURL = “URL of WSDL” tm.TModels(0).CategoryBag.Add(“uddi-org:types”,

 

“wsdlSpec”, “uuid:c1acf26d-9672-4404-9d70-4863bc075ad9”) Dim sTModelKey As String

 

Try

 

Dim td As New TModelDetail() td = stm.Send()

 

sTModelKey = td.TModels(0).TModelKey Catch ue As UddiException

 

Console.WriteLine(ue.Message) Return

 

Catch e As Exception Console.WriteLine(e.Message) Return

 

End  Try

 

Dim sb As New SaveBusiness() sb.BusinessEntities.Add() sb.BusinessEntities(0).Name = “My Business” sb.BusinessEntities(0).Descriptions.Add

 

(“en”,  “Description  of  My  Business”)

 

sb.BusinessEntities(0).BusinessServices.Add() sb.BusinessEntities(0).BusinessServices(0).Name = “My Business Service” sb.BusinessEntities(0).BusinessServices(0).Descriptions.Add

 

(“en”,  “Description  of  My  Business  Service”)

 

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  =  “My  Access  Point”

 

sb.BusinessEntities(0).BusinessServices(0).BindingTemplates(0). AccessPoint.URLType = Microsoft.Uddi.Api.URLTypeEnum.Http

 

sb.BusinessEntities(0).BusinessServices(0).BindingTemplates(0).

 

TModelInstanceDetail.TModelInstanceInfos.Add() sb.BusinessEntities(0).BusinessServices(0).BindingTemplates(0).

 

TModelInstanceDetail.TModelInstanceInfos(0).Descriptions.Add (“en”, “Insert Description Here”)

sb.BusinessEntities(0).BusinessServices(0).BindingTemplates(0).

 

TModelInstanceDetail.TModelInstanceInfos(0).TModelKey  =  sTModelKey

 

Try

 

Dim  bd  As  New  BusinessDetail()

 

bd  =  sb.Send()

 

Console.WriteLine(bd)

 

Catch  ue  As  UddiException

 

Console.WriteLine(ue.Message)

 

Return

 

Catch  e  As  Exception

 

Console.WriteLine(e.Message)

 

Return

 

End  Try

 

End  Sub

 

End  Module

 

First, we prepare to log in to the registry with the following lines:

 

Publish.Url  =  “https://test.uddi.microsoft.com/publish”

 

Publish.User  =  “username”

 

Publish.Password  =  “password”

 

Next, we must build a tModel in order to publish our WSDL files:

 

Dim tm As New SaveTModel() tm.TModels.Add()

 

tm.TModels(0).Name = “URN of tModel” tm.TModels(0).Descriptions.Add(“en”, “Description of tModel”) tm.TModels(0).OverviewDoc.OverviewURL = “URL of WSDL” tm.TModels(0).CategoryBag.Add(“uddi-org:types”,

 

“wsdlSpec”, “uuid:c1acf26d-9672-4404-9d70-4863bc075ad9”) Dim sTModelKey As String

 

The CategoryBag.Add call is necessary for the proper categorization of the tModel. Finally, we send the tModel to the registry:

 

Dim td As New TModelDetail() td = stm.Send()

 

sTModelKey  =  td.TModels(0).TModelKey

 

If we are successful in saving our tModel to the registry, it will return a unique tModelKey, which we use later to bind our Web Service. In the next step, we create our business entry:

 

Dim sb As New SaveBusiness() sb.BusinessEntities.Add()

sb.BusinessEntities(0).Name = “My Business” sb.BusinessEntities(0).Descriptions.Add

 

(“en”,  “Description  of  My  Business”)

 

Then we create the BusinessService:

 

sb.BusinessEntities(0).BusinessServices.Add() sb.BusinessEntities(0).BusinessServices(0).Name = “My Business Service” sb.BusinessEntities(0).BusinessServices(0).Descriptions.Add

 

(“en”,  “Description  of  My  Business  Service”)

 

Next, we create the 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  =  “My  Access  Point”

 

sb.BusinessEntities(0).BusinessServices(0).BindingTemplates(0). AccessPoint.URLType = Microsoft.Uddi.Api.URLTypeEnum.Http

 

Finally, we create the tModelInstanceInfo:

 

sb.BusinessEntities(0).BusinessServices(0).BindingTemplates(0).

 

TModelInstanceDetail.TModelInstanceInfos.Add() sb.BusinessEntities(0).BusinessServices(0).BindingTemplates(0).

 

TModelInstanceDetail.TModelInstanceInfos(0).Descriptions.Add (“en”, “Insert Description Here”)

 

sb.BusinessEntities(0).BusinessServices(0).BindingTemplates(0). TModelInstanceDetail.TModelInstanceInfos(0).TModelKey = sTModelKey

 

Now we are ready to register our business with the UDDI registry:

 

Dim bd As New BusinessDetail() bd = sb.Send()


Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail
XML and Web Services : Building XML-Based Applications : Web Services Building Blocks: WSDL and UDDI : UDDI - Vendor Implementations |


Privacy Policy, Terms and Conditions, DMCA Policy and Compliant

Copyright © 2018-2023 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.