Sun Java System Message Queue 3.7 UR1 Developer's Guide for Java Clients

Using SOAP Administered Objects

Administered objects are objects that encapsulate provider-specific configuration and naming information. For endpoint objects, you have the choice either to instantiate such an object or to create an administered object and associate it with an endpoint object instance.

The main benefit of creating an endpoint through a JNDI lookup is to isolate endpoint URLs from the code, allowing the application to switch the destination without recompiling the code. A secondary benefit is provider independence.

Creating an administered object for a SOAP element is the same as creating an administered object in Message Queue: you use the Object Manager (imqobjmgr) utility to specify the lookup name of the object, its attributes, and its type.

Table 5–2 lists and describes the attributes and other information that you need to specify when you create an endpoint administered object. Remember to specify all attributes as strings.

Table 5–2 SOAP Administered Object Information

Option 

Description 

-o “attribute=val

Use this option to specify three possible attributes for an endpoint administered object: 

  • A URL list

-o “imqSOAPEndpointList = “url1 url2 ....urln

The list may contain one or more space-separated URLs. If it contains more than one, the message is broadcast to all the URLs. Each URL should be associated with a servlet that can receive and process a SOAP message. 

  • A name

-o “imqEndpointName=SomeName

If you don’t specify a name, the name Untitled_Endpoint_Object is used by default.

  • A description

-o "imqEndpointDescription=my endpoints for broadcast"

If you don’t specify a description, the default value "A description for the endpoint object" is supplied by default.

-l “cn=lookupName

Use this option to specify the lookup name of the endpoint. 

-t type

Use this option to specify the object’s type. This is always e for an endpoint.

-i filename

Use this option to specify the name of an input file containing imqobjmgr commands. Such an input file is typically used to specify object store attributes.

-j “attribute=val

Use this option to specify object store attributes. You can also specify these in an input file. Use the -i option to specify the input file. 

Example 5–2 shows how you use the imqobjmgr command to create an administered object for an endpoint and add it to an object store. The -i option specifies the name of an input file that defines object store attributes (-j option).


Example 5–2 Adding an Endpoint Administered Object


imqobjmgr add
    -t e
    -l "cn=myEndpoint"
    -o "imqSOAPEndpointList=http://www.myServlet/
                            http://www.myServlet2/"
    -o "imqEndpointName=MyBroadcastEndpoint"
    -i MyObjStoreAttrs
         

Having created the administered object and added it to an object store, you can now use it when you want to use an endpoint in your SAAJ application. In Example 5–3, you first create an initial context for the JNDI lookup and then you look up the desired object.


Example 5–3 Looking up an Endpoint Administered Object


Hashtable env = new Hashtable();
env.put (Context.INITIAL_CONTEXT_FACTORY,
        "com.sun.jndi.fscontext.RefFSContextFactory");
env.put (Context.PROVIDER_URL,
        "file:///c:/imq_admin_objects");
Context ctx = new InitialContext(env);
Endpoint mySOAPEndpoint = (Endpoint)
         ctx.lookup("cn=myEndpoint");

You can also list, delete, and update administered objects. For additional information, please see Chapter 8, Managing Administered Objects, in Sun Java System Message Queue 3.7 UR1 Administration Guide.