UDDI Tutorial : JUDDI / UDDI4J ( publish & inquiry using juddi console and uddi4j client API )

Last two weeks i was busy with my office work trying to figure out some tasks related to an EU project called sensoria. I had to integrate the Events plugin of Joomla (CMS) with Google calender (which i am hoping to write about in future) and I had to compose a case study documentation for service discovery using UDDI (Universal Description, Discovery and Integration). It took me few days to setup a test environment to get things actually working.pict_uddi_1.gif

As I saw, that in this area there aren’t many help or online tutorials.. you have to collect tits and bits from every where and put some effort to make things work..

SO yeah thats why i thought to publish a small tutorial on setting up a UDDI server and handling the UDDI4J java client API..

 


What is UDDI

Universal description discovery and integration (UDDI) is a special directory service which is implemented to use for indexing all the available services, a company offer. UDDI registries keep records of the details of the company, the details of the offering services and the technical specifications to use them.

UDDI creates a standard interoperable platform that enables companies and applications to quickly, easily, and dynamically find and use Web services over the Internet. UDDI also allows operational registries to be maintained for different purposes in different contexts.

More details

You can read more details about UDDI data structure and the technical architecture from tutorialspoint where i got a good idea how things did work in the ground level.

apache.gifApache jUDDI

jUUDI is an Open source UDDI server which have to be integrated with the apache tomcat application server. jUDDI provides a console where the uses can publish and inquire businesses / Services and tmodels along with the binding templates. Apache provides the HOW-TO setup guide it its wiki, yet its bit confusing and out of date.

Step by Step setup guide ( jUDDI on tomcat )

  • Unzip the jUDDI archive to a directory.
  • Copy the MySQL JDBC driver to {TOMCAT}/common/lib. This makes the MySQL database runtime available to Tomcat.
  • As a test for confirmation of successful database restoration execute a SELECT query in the MySQL prompt SELECT COUNT(*) FROM PUBLISHER

If the result is “1”. The database is successfully restored.

  • Copy the {JUDDI}/webapps/juddi directory to {TOMCAT}/webapps. This installs the jUDDI web application into Tomcat.
  • In the {TOMCAT}/webapps/juddi/META-INF directory, create a file named context.xml. Enter the following into the file:

<Context path=”/juddi” docBase=”juddi” debug=”5″ reloadable=”true”
crossContext=”true”>

<Logger className=”org.apache.catalina.logger.FileLogger”
prefix=”localhost_juddiDB_log” suffix=”.txt”
timestamp=”true”/>

<Resource name=”jdbc/juddiDB”
auth=”Container”
type=”javax.sql.DataSource”
username=”MySQL_username” password=”MySQL_password”
driverClassName=”com.mysql.jdbc.Driver”
url=”jdbc:mysql://host.domain.com:3306/juddi?autoReconnect=true”
validationQuery=”select publisher_ID from PUBLISHER”/>

<Resource name=”jdbc/juddi”
auth=”Container”
type=”javax.sql.DataSource”
username=”MySQL_username” password=”MySQL_password”
driverClassName=”com.mysql.jdbc.Driver”
url=”jdbc:mysql://host.domain.com:3306/juddi?autoReconnect=true”
validationQuery=”select publisher_ID from PUBLISHER”/>

</Context>

configures two DataSources so that the jUDDI application can use the MySQL database tables which are created in an earlier step.

  • Edit the {TOMCAT}/webapps/juddi/WEB-INF/web.xml file and near the bottom, copy the existing resource-ref element so there are two. Edit the copy to define a res-ref-name of jdbc/juddi. The two resource-ref elements should look like:

<resource-ref>

<description>jUDDI DataSource</description>
<res-ref-name>jdbc/juddiDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>

</resource-ref>
<resource-ref>

<description>jUDDI DataSource</description>
<res-ref-name>jdbc/juddi</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>

</resource-ref>

  • Restart tom cat server.
  • Test jUDDI by opening a Web browser and entering the following URL:

http://localhost:8080/juddi/happyjuddi.jsp
there should not be any errors on the page (no red text).

In the top multi-line entry area, change the userID from *** to jdoe and the cred from *** to an empty string. Then press the Submit button.
In the bottom multi-line area, if there is a returned SOAP message with an authInfo element containing text of the form authToken:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. That means JUDDI is successfully installed and configured.

JUDDI console ( http://localhost:8080/juddi/console/ )

using JUDDI console, a new business / Tmodel / Service can be created.

  • using the link get_authToken using the publisher username and the password, take a authentication token.
  • use the link save_business create a new business by putting the received authentication code.
  • Publish a tmodel for a relevant category (save_tmodel).
  • Save a service giving the associating tmodel key (save _service).

but this is not the case always.. you need to build a client to lookup the UDDI registry remotely or need to publish your business data. for this task there are several client APIs available.. and the flowing is the java implementation.

uddi4j.jpegUDDI client API (UDDI4J)

UDDI4J is a Java class library that provides an API that is can be used to interact with a UDDI registry. This class library generates and parses messages sent to and received from a UDDI server.
The central class in this set of APIs is org.uddi4j.client.UDDIProxy. It is a proxy for the UDDI server that is accessed from client code. Its methods map to the UDDI Version 2.0 API Specification.
The classes within org.uddi4j.datatype represent data objects used to send or receive UDDI information. and in the, business, service, tmodel subpackages represent data objects that are sent on calls or received from the server.
The subpackage org.uddi4j.request contains messages sent to the server. These classes are typically not used directly, rather the UDDIProxy class uses these classes.
Similarly, the subpackage org.uddi4j.response represents response messages from a UDDI server.

Pluggable transports are supported by the package org.uddi4j.transport.

Getting the Service url

When you download the UDDI4J archive and unzip it you get a folder with some examples. in these examples you can find the methodologies to publish and lookup for businesses. but what was bit dificult was to get the service URL which is the most important. so I thought of adding that piece of code where you can get the service url easily.

I assume there are some Services are published to the registry.

try {

UDDIProxy proxy = new UDDIProxy();
proxy.setInquiryURL(INQ_URL);Vector names = new Vector();
names.add(new Name(SERVICE_NAME));

FindQualifiers findQualifiers = new FindQualifiers();
Vector qualifier = new Vector();
qualifier.add(new FindQualifier(FindQualifier.exactNameMatch));
findQualifiers.setFindQualifierVector(qualifier);

ServiceList serviceList = proxy.find_service(null, names, null,
null, findQualifiers, MAX_ROWS);
Vector serviceInfoVector = serviceList.getServiceInfos()
.getServiceInfoVector();

/* service end point URL list */
Vector urlList = new Vector();

for (int i = 0; i < serviceInfoVector.size(); i++) {

ServiceInfo sInfo = (ServiceInfo) serviceInfoVector
.elementAt(i);
BindingDetail btd = proxy.find_binding(null, sInfo
.getServiceKey(), null, MAX_ROWS);
BindingTemplate bt = (BindingTemplate)btd.getBindingTemplateVector().elementAt(0);
urlList.add(bt.getAccessPoint().getText());

}

/* select a suitable service as to the given criteria, here we just
* select the service randomly */
int i = (int)(Math.random() * urlList.size());
return new AmbulanceServiceStub((String)urlList.elementAt(i));
} catch (Exception e) {

System.out.println(e);
return null;

}

Bibliography

I hope this article will make sense to you. but if you get any problem during the server setup or while using uddi4j please feel free to leave a comment or email.

cheers !!

Advertisements

8 thoughts on “UDDI Tutorial : JUDDI / UDDI4J ( publish & inquiry using juddi console and uddi4j client API )”

  1. Hi,

    Can you kindly post another blog about jUDDI v1.3, on Solaris/Sun Java App, and UDDI4J? I built, and installed jUDDI v1.3, on Solaris machine, and it appears to work, e.g.: happyjuddi page appears to work – green everywhere. But because console is now taken away, I could not test whether my juddi is working properly or not. Can you kindly help me? Thank you very much.

    Like

  2. Hello,

    In your case.. you can publish businesses and services using UDDI4J client API.. There are some examples in UDDI4J Directory when you download and unzip it.. Those might help you..

    Good Luck

    Like

  3. Hi,
    I want to use the juddi console from my program using the uddi4j api. I have installed.
    1)jdk 1.5.0.15
    2)tomcat 5.5.25
    3)juddi 0.9rc4
    4)mysql

    I dunno wat to do with AXIS(install it or not), all i need is to get atleast the get_authtoken to work from my pgm.

    Pls help me out. Thanks in advance

    -sandeep

    Like

    1. Yes you need AXIS (axis2) to publish your web service. get the WSDL (service URL) and publish it in the UDDI, and get the token. that will do.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s