Chapter 4. Simple Publishing via the API
4.1. UDDI Data Model
- Business entities
- Business entities are at the top of the pyramid. They contain business services.
- Business services
- Business services contain end-point references.
4.2. Business Entity
4.3. Business Service
4.4. End-Point Reference
4.5. UDDI and the jUDDI API
sets. Each set represents a specific area of functionality:
Inquiryhandles queries to the Registry for details about entities.Publicationhandles the registration of entities.Securityis an open-ended specification that handles authentication.Custody and Ownership Transferhandles the transference of ownership of entities.Subscriptionallows clients to retrieve information about entities using a subscription format.Subscription Listeneris a client API for accepting subscription results.Value Set (Validation and Caching)validates keyed reference values. (This set is not yet available for the jUDDI.)Replicationallows you to federate data between registry nodes. (This set is not yet available for the jUDDI.)
sets you will use most frequently are Inquiry, Publication and Security. They provide the standard functions you need for interacting with the Registry.
sets as a JAX-WS-compliant web service. (Each method defined in a set is simply a method in the corresponding web service.)
4.6. jUDDI Additions to the UDDI Model
The jUDDI Registry's implementation provides the data model with some additional structure beyond that described in the specification. Prime amongst this is the concept of the publisher.
publish calls to assign ownership to the published entities.
4.7. Tutorial: Use the Service Registry for the First Time
Procedure 4.1. Task
- Instantiate the
SimplePublishclass. Here is the constructor:public SimplePublish() { try { String clazz = UDDIClientContainer.getUDDIClerkManager(null). getClientConfig().getUDDINode("default").getProxyTransport(); Class<?> transportClass = ClassUtil.forName(clazz, Transport.class); if (transportClass!=null) { Transport transport = (Transport) transportClass. getConstructor(String.class).newInstance("default"); security = transport.getUDDISecurityService(); juddiApi = transport.getJUDDIApiService(); publish = transport.getUDDIPublishService(); } } catch (Exception e) { e.printStackTrace(); } }This constructor uses the jUDDI client API to retrieve the transport from the default node. In this example, it is simply retrieving the default client transport class which is designed to make UDDI calls out using JAX-WS web services. - Obtain the three API sets needed for the example:
- the
SecurityAPI set, so you can obtain authorisation tokens, - the proprietary
jUDDIAPI set so you can save a publisher, - the
PublicationAPI set so that you can register entities in the jUDDI.
Here are the first few lines of thepublishmethod:// Setting up the values to get an authentication token for the 'root' user // ('root' user has admin privileges and can save other publishers). GetAuthToken getAuthTokenRoot = new GetAuthToken(); getAuthTokenRoot.setUserID("root"); getAuthTokenRoot.setCred(""); // Making API call that retrieves the authentication token for the 'root' user. AuthToken rootAuthToken = security.getAuthToken(getAuthTokenRoot); System.out.println ("root AUTHTOKEN = " + rootAuthToken.getAuthInfo());This code simply retrieves the authorisation token for the root user. - Add a publisher:
// Creating a new publisher that we will use to publish our entities to. Publisher p = new Publisher(); p.setAuthorizedName("my-publisher"); p.setPublisherName("My Publisher"); // Adding the publisher to the "save" structure, using the 'root' user authentication // info and saving away. SavePublisher sp = new SavePublisher(); sp.getPublisher().add(p); sp.setAuthInfo(rootAuthToken.getAuthInfo()); juddiApi.savePublisher(sp);The code above uses the jUDDI API to save a publisher with authorised name, my-publisher. Note that the authorisation token for the root user is utilised. - Obtain the authorisation token for this new publisher:
// Our publisher is now saved, so now we want to retrieve its authentication token GetAuthToken getAuthTokenMyPub = new GetAuthToken(); getAuthTokenMyPub.setUserID("my-publisher"); getAuthTokenMyPub.setCred(""); AuthToken myPubAuthToken = security.getAuthToken(getAuthTokenMyPub); System.out.println ("myPub AUTHTOKEN = " + myPubAuthToken.getAuthInfo());Note that no credentials have been set on either of the authorisation calls. This is because, by using the default authenticator, you do not have to provide any. - Publish:
// Creating the parent business entity that will contain our service. BusinessEntity myBusEntity = new BusinessEntity(); Name myBusName = new Name(); myBusName.setValue("My Business"); myBusEntity.getName().add(myBusName); // Adding the business entity to the "save" structure, using our publisher's // authentication info and saving away. SaveBusiness sb = new SaveBusiness(); sb.getBusinessEntity().add(myBusEntity); sb.setAuthInfo(myPubAuthToken.getAuthInfo()); BusinessDetail bd = publish.saveBusiness(sb); String myBusKey = bd.getBusinessEntity().get(0).getBusinessKey(); System.out.println("myBusiness key: " + myBusKey); // Creating a service to save. Only adding the minimum data: the parent // business key retrieved from saving the business above and a single name. BusinessService myService = new BusinessService(); myService.setBusinessKey(myBusKey); Name myServName = new Name(); myServName.setValue("My Service"); myService.getName().add(myServName); // Add binding templates, etc... // Adding the service to the "save" structure, using our publisher's // authentication info and saving away. SaveService ss = new SaveService(); ss.getBusinessService().add(myService); ss.setAuthInfo(myPubAuthToken.getAuthInfo()); ServiceDetail sd = publish.saveService(ss); String myServKey = sd.getBusinessService().get(0).getServiceKey(); System.out.println("myService key: " + myServKey);Note
There are some important things to note with regard to the use of entity keys. Version three of the specification allows for publishers to create their own keys but also instructs implementers to have default methods.Red Hat has chosen the default implementation approach by leaving each entity’s key field blank in thesavecall. The jUDDI’s default key generator simply takes the node’s partition and appends a GUID to it.In a default installation, it will look something like this:uddi:juddi.apache.org:<GUID>(You can, of course, customise all of this if you wish.)The second important point is that when the BusinessService is saved, its parent business key (retrieved from previous call saving the business) is set explicitly. This is a necessary step when the service is saved in an independent call like this because, otherwise, you would encounter an error as the jUDDI will not know where to find the parent entity.
In this example you have created and saved a BusinessEntity and then created and saved a BusinessService. You have added the bare minimum of data to each entity (and, in fact, have not added any BindingTemplates to the service).

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.