-
Notifications
You must be signed in to change notification settings - Fork 0
Developing using the jUDDI Client
There are a number of ways to interaction with a UDDI server. The jUDDI project provides both a user/administrative web interface as well as Java library for use with your own applications. This article is primarily for making your own software that uses jUDDI client Java library.
The jUDDI project includes a jUDDI-Client (juddi-client-3.0.0.jar) which can be use to connect to the Registry. The client uses the UDDI v3 API so it should be able to connect to any UDDI v3 compliant registry, however we have only tested it with jUDDIv3. It maybe useful to take a look at the unit-tests in the jUDDIv3-uddi-client module to see how the client can be used.
The UDDI client has a configuration file called uddi.xml. In this file you can set the type “Transport” used by the client to talk to the registry. The client tries to locate this file on the classpath and uses Apache Commons Configuration [COM-CONFIG] to read it. By default the uddi.xml file looks like
<?xml version="1.0" encoding="ISO-8859-1" ?> <uddi> <reloadDelay>5000</reloaddelay> <manager name="example-manager"> <nodes> <node> <name>default</name> <description>Main jUDDI node</description> <properties> <property name="serverName" value="localhost"/> <property name="serverPort" value="8080"/> <property name="keyDomain" value="juddi.apache.org"/> <property name="department" value="businesses" /> </properties> <proxyTransport> org.apache.juddi.v3.client.transport.InVMTransport </proxytransport> <custodyTransferUrl> org.apache.juddi.api.impl.UDDICustodyTransferImpl </custodytransferurl> <inquiryUrl>org.apache.juddi.api.impl.UDDIInquiryImpl</inquiryurl> <publishUrl>org.apache.juddi.api.impl.UDDIPublicationImpl</publishurl> <securityUrl>org.apache.juddi.api.impl.UDDISecurityImpl</securityurl> <subscriptionUrl>org.apache.juddi.api.impl.UDDISubscriptionImpl </subscriptionurl> <subscriptionListenerUrl> org.apache.juddi.api.impl.UDDISubscriptionListenerImpl </subscriptionlistenerurl> <juddiApiUrl>org.apache.juddi.api.impl.JUDDIApiImpl</juddiapiurl> </node> </nodes> </manager> </uddi>
Using the settings in the uddi.xml file from above, the client will use JAX-WS to communicate with the (remote) registry server. This means that the client needs to have access to a JAX-WS compliant WS stack (such as CXF, Axis2 or JBossWS). Make sure to point the JAXWS URLs to where the UDDI client can find the WSDL documents.
<proxyTransport>org.apache.juddi.v3.client.transport.JAXWSTransport</proxytransport> <custodyTransferUrl> http://${serverName}:${serverPort}/juddiv3/services/custody-transfer?wsdl </custodytransferurl> <inquiryUrl> http://${serverName}:${serverPort}/juddiv3/services/inquiry?wsdl </inquiryurl> <publishUrl> http://${serverName}:${serverPort}/juddiv3/services/publish?wsdl </publishurl> <securityUrl> http://${serverName}:${serverPort}/juddiv3/services/security?wsdl </securityurl> <subscriptionUrl> http://${serverName}:${serverPort}/juddiv3/services/subscription?wsdl </subscriptionurl> <subscriptionListenerUrl> http://${serverName}:${serverPort}/juddiv3/services/subscription-listener?wsdl </subscriptionlistenerurl> <juddiApiUrl> http://${serverName}:${serverPort}/juddiv3/services/juddi-api?wsdl </juddiapiurl>
If jUDDIv3 is deployed to an Application Server it is possible to register the UDDI Services as RMI services. If this is desired you need to edit the juddiv3.war/WEB-INF/classes/juddiv3.properties file, on the server. Add the following setting
juddi.jndi.registration=trueNow at deployment time, the RMI based UDDI services are bound into the Global JNDI namespace.
juddi (class: org.jnp.interfaces.NamingContext)
- UDDIPublicationService (class: org.apache.juddi.rmi.UDDIPublicationService)
- UDDICustodyTransferService (class: org.apache.juddi.rmi.UDDICustodyTransferService)
- UDDISubscriptionListenerService (class: org.apache.juddi.rmi.UDDISubscriptionListenerService)
- UDDISecurityService (class: org.apache.juddi.rmi.UDDISecurityService)
- UDDISubscriptionService (class: org.apache.juddi.rmi.UDDISubscriptionService)
- UDDIInquiryService (class: org.apache.juddi.rmi.UDDIInquiryService)
If you choose to use InVM Transport this means that the jUDDIv3 server is running in the same VM as you client. If you are deploying to juddi.war the server will be started by the org.apache.juddi.RegistryServlet, but if you are running outside any container, you are responsible for starting and stopping the org.apache.juddi.Registry Service yourself. Make sure to call
Registry.start()
before making any calls to the Registry, and when you are done using the Registry (on shutdown) call
Registry.stop()so the Registry can release any resources it may be holding. To use InVM Transport uncomment this section in the uddi.properties while commenting out the JAXWS and RMI Transport sections.
The UDDI client depends on
- juddi-client.VERSION.jar
- uddi-ws-VERSION.jar
- commons-configuration-1.5.jar
- commons-collection-3.2.1.jar
- log4j-1.2.13.jar
- libraries for JAXB if you are not using JDK5.
- JAXWS client libraries when using JAXWS transport (like CXF).
- RMI and JNDI client libraries when using RMI Transport.
Sample code on how to use the UDDI client can be found in the uddi-client module on the jUDDIv3 project. Usually the first thing you want to is to make a call to the Registry to obtain an Authentication Token. The following code is taken from the unit tests in this module.
public void testAuthToken() { try { String clazz = ClientConfig.getConfiguration().getString( Property.UDDI_PROXY_TRANSPORT,Property.DEFAULT_UDDI_PROXY_TRANSPORT); Class<?> transportClass = Loader.loadClass(clazz); if (transportClass!=null) { Transport transport = (Transport) transportClass.newInstance(); UDDISecurityPortType securityService = transport.getSecurityService(); GetAuthToken getAuthToken = new GetAuthToken(); getAuthToken.setUserID("root"); getAuthToken.setCred(""); AuthToken authToken = securityService.getAuthToken(getAuthToken); System.out.println(authToken.getAuthInfo()); Assert.assertNotNull(authToken); } else { Assert.fail(); } } catch (Exception e) { e.printStackTrace(); Assert.fail(); } }Make sure that the publisher, in this case “root” is an existing publisher in the Registry and that you are supplying the correct credential to get a successful response. If needed check Chapter 3, Authentication to learn more about this subject.
Another place to look for sample code is the docs/examples/helloword directory. Alternatively you can use annotations.
There are many How to samples within the SVN repository for jUDDI.
The jUDDI API is a web service interface for performing a number of administrative tasks, such as
- Delete tModels
- Delete Client Subscription Info
- Delete Publisher
- Get All Publisher Details
- Get Publisher Detail
- Invoke Synchronous Client Subscription
- Save Clerk
- Save Client Subscription Info
- Save Node
- Save Publisher