O'Reilly logo

Java Web Services in a Nutshell by Kim Topley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

JAXR Programming

So far in this chapter, you have seen the JAXR registry information model, which is mapped to the javax.xml.registry.infomodel package. This section looks at the API that allows you to search or update a registry, which is defined in the package javax.xml.registry. The examples shown in this section assume that you have installed the sample registry data in either a UDDI or ebXML registry, as described in Section 7.3, earlier in this chapter.

Connecting to the Registry

In order to use a registry, you first have to create a connection to it. This process requires two steps:

  1. Obtain a ConnectionFactory object and optionally set properties that determine how it will behave.

  2. Use the ConnectionFactory object to obtain a Connection or FederatedConnection to the target registry.

There are two ways to get a ConnectionFactory object. In a J2EE environment, the preferred way is to use the JNDI API to look up a preconfigured ConnectionFactory:

InitialContext ctx = new InitialContext(  );
ConnectionFactory factory = (ConnectionFactory)ctx.lookup("pathToFactory");

J2SE-based registry clients that do not have a preconfigured JNDI environment can instead use the static newInstance( ) method:

ConnectionFactory factory = ConnectionFactory.newInstance(  );

ConnectionFactory is an abstract class. The actual class of the object returned by the newInstance( ) method is determined by the property javax.xml.registry.ConnectionFactoryClass, which can be set in either of the following locations (in ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required