Working with UDDI
An AccessPoint Locator Service
One common problem you encounter when you deal with a web service based architecture
is to build a library that eases the process of retrieving web services accesspoints URLs
from the registry. What you will see hereafter is an example of a JBoss service based
on MBeans called "Accesspoint Locator Service" that aims to centralise and optimize these
registry accesses for all web service clients deployed into a JBossAS server.
This example is using:
previous UDDIExample to deploy & publish an example web service
JAXR to talk to the registry.
The UDDI v2 jUDDI service you will find in all/juddi-service.sar and you can copy into the default configuration
JBossAS-4.0.3RC2+
MBeans
Description
The AccesspointLocator MBean publishes a simple Proxy in the JBossAS JNDI tree. Thus, using a
initialContext.lookup()
,
client applications will use a simple
AccesspointLocator
interface to interact with the service and retrieve a web
service accesspoint.
The simple AccesspointLocator interface:
public interface AccesspointLocator { public URL getAccesspoint(String in_serviceName) throws Exception; }
Thus, your web service client code will be:
AccesspointLocator al = (AccesspointLocator)(new InitialContext()).lookup("java:/AccesspointLocator"); ExampleService_PortType stub = (ExampleService_PortType) new ExampleService_Service_Impl().getExampleServicePort(); URL accesspoint = al.getAccesspoint("ExampleService"); ((Stub)stub)._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, accesspoint.toString() );
The AccesspointService modules
registry: a simple MBean dedicated to the registry conversation. The provided one uses JAXR.
cache: a simple MBean handling a HashMap. Ask your cache specialists to develop a real one with several initialisation/flush policies and maybe UDDI changes notification system.
distribute: in case of you deploy your web services several time, you will have several accesspoints per web service. You need to define how these accesspoints will be distributed per client requests. In this example, it's a simple MBean implementing a non strict Round-Robin distribution. Here too, ask your genious developers to provide you with wonderful policies with numerous options.
To run the example
install the juddi-service.sar (copy the
juddi-service.sar
from the all configuration)
publish in the registry the web service from the example in this wiki page (don't forget to add the ddl in the
juddi-service.sar/META-INF/ddl
used to publish the WSDL)
deploy the accesspoint service (ant task in Accesspoint.zip)
deploy the test.war (ant task in Accesspoint.zip)
in your browser, enter http://localhost:8080/test/testService.jsp
You should see the following result :
Test WS with Accesspoint Locator # http://localhost:8080/example/ExampleService (483) * multiply 100 by 2 = 200 # http://localhost:8080/example2/ExampleService (0) * multiply 100 by 2 = 200 # http://localhost:8080/example/ExampleService (0) * multiply 100 by 2 = 200
To go further
This example is just a starting point. What you will have to do is to apply your
taxonomy and give key categories as an argument to the AccesspointLocator.getAccespoint() method.
Also you can largely extend the service to, for example, collect statistics (useful if you want to know which
services are currently used in your system) or locate WSDL too (not only access points) for your DII code.
Comments