| |

Example 1: Creating a business entity and publishing it in the UDDI registry

This example shows how to create an organization and publish it in an UDDI 2.0 Business Registry. Note that you need to obtain a username and password for the targeted registry for this example to work.

import inspireit.uddi.*;

import inspireit.uddi.io.*;

import inspireit.uddi.request.*;

import inspireit.uddi.request.publishing.*;

import inspireit.uddi.response.*;

import inspireit.uddi.response.base.*;

import inspireit.uddi.collections.*;

import inspireit.uddi.base.*;

 

public class PublishORG {

public PublishORG(String queryURL, String publishURL, String username,

String password) throws Exception {

// setup HTTPS-related stuff

System.setProperty("java.protocol.handler.pkgs",

"com.sun.net.ssl.internal.www.protocol");

java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());

 

// define the UDDI profile

UDDIProfile profile = new UDDIProfile();

profile.setProperty("inspireit.uddi.inquiry.url", queryURL);

profile.setProperty("inspireit.uddi.publishing.url", publishURL);

profile.setProperty("inspireit.uddi.publishing.username", username);

profile.setProperty("inspireit.uddi.publishing.password", password);

profile.setProperty("inspireit.uddi.version", "2.0");

 

try {

// get an appropriate publisher

UDDIPublisher publisher = UDDIPublisher.getPublisher(profile);

 

// build up the BusinessEntity to save in the registry

Name name = new Name("INSPIRE IT");

BusinessKey businessKey = null; // it's a new business...

BusinessEntity businessEntity = new BusinessEntity(businessKey, name);

 

// add contact information

Contact contact = new Contact("Bertrand Fontaine");

Phone phone = new Phone("02 648 71 34");

EMail email = new EMail("bertrand.fontaine@inspireit.biz");

contact.addPhone(phone);

contact.addEMail(email);

businessEntity.addContact(contact);

 

// add categorization: INSPIRE IT is a software publisher located in Belgium

KeyedReference softwarePublisher = new KeyedReference("5112");

softwarePublisher.setKeyName("NAICS: Software Publishers");

softwarePublisher.setTModelKey(TModel.NTIS_GOV_NAICS_1997.getTModelKey());

 

KeyedReference belgianCompany = new KeyedReference("BE");

belgianCompany.setKeyName("Belgium");

belgianCompany.setTModelKey(TModel.UDDI_ORG_ISO_CH_3166_1999.getTModelKey());

 

KeyedReferences keyedReferences = new KeyedReferences();

keyedReferences.add(softwarePublisher);

keyedReferences.add(belgianCompany);

CategoryBag categoryBag = new CategoryBag(keyedReferences);

businessEntity.setCategoryBag(categoryBag);

 

// define the www.javashelf.com bookstore service

AccessPoint accessPoint = new AccessPoint("http://www.javashelf.com");

TModelInstanceDetails instanceDetails = new TModelInstanceDetails();

TModelInstanceInfo instanceInfo = new TModelInstanceInfo(

new TModelKey("uuid:4cec1cef-1f68-4b23-8cb7-8baa763aeb89"));

instanceInfo.addDescription(new Description("JavaShelf.com homepage"));

instanceDetails.addTModelInstanceInfo(instanceInfo);

 

ServiceKey serviceKey = null; // it's a new service

BindingKey bindingKey = null; // it's a new binding

BindingTemplate bindingTemplate = new BindingTemplate(bindingKey, serviceKey,

accessPoint, instanceDetails);

Names names = new Names();

names.add(new Name("Javashelf.com"));

BindingTemplates bindingTemplates = new BindingTemplates();

bindingTemplates.add(bindingTemplate);

 

BusinessService bookstoreService = new BusinessService(serviceKey, businessKey,

names, bindingTemplates);

businessEntity.addBusinessService(bookstoreService);

 

// execute the saveBusiness() operation and get the returned BusinessDetail

BusinessDetail businessDetail = publisher.saveBusiness(businessEntity);

 

// get the saved BusinessEntity

BusinessEntitys businessEntitys = businessDetail.getBusinessEntitys();

BusinessEntity savedBusinessEntity = (businessEntitys.toArray())[0];

businessKey = savedBusinessEntity.getBusinessKey();

System.out.println("BusinessEntity saved with business key : " + businessKey);

} catch(UDDIException e) {

System.out.println("An error has occured. More information follows.");

DispositionReport dispositionReport = e.getDispositionReport();

Results results = dispositionReport.getResults();

Result result[] = results.toArray();

 

for(int i=0; i< result.length; i++) {

System.out.println("Errno : " + result[i].getErrNo() +

"\n KeyType : " + result[i].getKeyType() +

"\n ErrInfo : " + result[i].getErrInfo());

}

}

}

 

public static void main(String args[]) throws Exception {

if (args.length != 4) {

System.out.println("PublishORG usage:

java PublishORG <queryURL> <publishURL>

<username> <password>");

System.exit(0);

}

 

new PublishORG(args[0], args[1], args[2], args[3]);

return;

}

}

In this example, we have published business information about INSPIRE IT, the author of Ruddi. Note that in addition to the basic contact information, we have also published a service and its service bindings. Also, we have classified the business of INSPIRE IT according to the North American Industry Classification System (NAICS). In this scheme, businesses are classified based on the products and services they offer. We have published here INSPIRE IT as a "Software publisher" by using NAICS code 5112. A list of all NAICS codes can be found at http://www.census.gov/epcd/naics/naicscod.txt.

When we run this example, the following messages are exchanged behind the scene between Ruddi and the UDDI registry.

First, Ruddi is requesting an authentication token by sending a get_authToken request with the appropriate user identification and credential information. Confidential information has been here replaced by stars ("*"). In practice, the actual authentication information would be embedded in the XML code. Typically, the HTTPS protocol is used in order to secure any publication transmission, including the authentication token request.

<?xml version="1.0" encoding="UTF-8" ?>

<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">

<Body>

<get_authToken generic="2.0" xmlns="urn:uddi-org:api_v2" userID="***" cred="***"/>

</Body>

</Envelope>

 

If the user identification and credential information are valid, the UDDI registry replies with the following XML message that contains authentication information to be provided with any subsequent UDDI publication request:

<?xml version="1.0" encoding="utf-8"?>

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<soap:Body>

<authToken operator="Microsoft Corporation" generic="2.0" xmlns="urn:uddi-org:api_v2">

<authInfo>***</authInfo>

</authToken>

</soap:Body>

</soap:Envelope>

 

Now that the authentication token has been obtained from the UDDI registry, Ruddi formats the provided business information in an UDDI-compliant XML stream and sends it as part of a save_business request. Note how the authentication information is used to tag the request.

<?xml version="1.0" encoding="UTF-8" ?>

<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">

<Body>

<save_business generic="2.0" xmlns="urn:uddi-org:api_v2">

<authInfo>***</authInfo>

<businessEntity businessKey="">

<name>INSPIRE IT</name>

<contacts>

<contact>

<personName>Bertrand Fontaine</personName>

<phone>02 648 71 34</phone>

<email>bertrand.fontaine@inspireit.biz</email>

</contact>

</contacts>

<businessServices>

<businessService serviceKey="">

<name>Javashelf.com</name>

<bindingTemplates>

<bindingTemplate bindingKey="">

<accessPoint URLType="other">

http://www.javashelf.com

</accessPoint>

<tModelInstanceDetails>

<tModelInstanceInfo

tModelKey="uuid:4cec1cef-1f68-4b23-8cb7-8baa763aeb89">

<description>JavaShelf.com homepage</description>

</tModelInstanceInfo>

</tModelInstanceDetails>

</bindingTemplate>

</bindingTemplates>

</businessService>

</businessServices>

<categoryBag>

<keyedReference keyName="NAICS: Software Publishers" keyValue="5112"

tModelKey="uuid:C0B9FE13-179F-413D-8A5B-5004DB8E5BB2"/>

<keyedReference keyName="Belgium" keyValue="BE"

tModelKey="uuid:4E49A8D6-D5A2-4FC2-93A0-0411D8D19E88"/>

</categoryBag>

</businessEntity>

</save_business>

</Body>

</Envelope>

 

The following businessDetail message is sent back with the exact information saved in the UDDI registry. All keys that had to be assigned, such as the business entity or business service key have been generated by the registry. The businessDetail message has the following structure:

<?xml version="1.0" encoding="utf-8"?>

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<soap:Body>

<businessDetail generic="2.0" operator="Microsoft Corporation"

truncated="false" xmlns="urn:uddi-org:api_v2">

Exact information on the saved business entity would be here...

</businessDetail>

</soap:Body>

</soap:Envelope>

 

Once we run the example successfully, it is easy to confirm that the organization information has been added to the UDDI registry. Simply log on to the UDDI registry and check the information.

The following figure shows that the "INSPIRE IT" business entity has been published to the UDDI registry with the key "6696301d-eb42-4440-bb9d-a033184f336a":

By clicking on the "Services" tab, we can verify that the "JavaShelf.com" Web service has indeed registered:

 

Bertrand Fontaine has been registered as the contact for INSPIRE IT:

 

INSPIRE IT has been categorized using the NAICS and ISO 3166 taxonomies:

 

 

 

| |

(c) INSPIRE IT, 2003 | Send us your feedback: developers@ruddi.biz