Skip Headers
Oracle® Content Services Application Developer's Guide
10g Release 1 (10.1.1)

Part Number B14494-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

1 Connecting to Content Services

Getting Started

This guide should be used in conjunction with the Content Services Web Services Toolkit. The toolkit can be downloaded from http://otn.oracle.com. In the Toolkit you will find the necessary JAR files with which to run the Web Services client. The examples in this guide are available in full within the Toolkit. The Toolkit also provides additional documentation, the bulk tools, more samples, and Java API Reference (Javadoc).

The following jars from the /lib directory of the Toolkit must be in your CLASSPATH to run the examples:

The examples in this guide are available in the Toolkit in the sample_code/sample_webservices/src/oracle/ifs/examples/ws directory.

Connecting to a Content Services Instance

The first step for a Content Services client is to authenticate with the Content Services instance. The instance is accessed at a fixed URL such as http://servername.com/content/ws. To connect to an instance, you will need a URL and port, as well as a valid username and password. Content Services authentication uses the RemoteLoginManager class to pass the username and password to the running instance.

Note:

For the example below, we will assume that your Content Services instance can accept authentication requests over an insecure connection. By default, Content Services only allows cleartext authentication over HTTPS. To change this setting, the CleartextAuthenticationRequiresHttps property of the OCS domain must be set to false. See Chapter 6 of the Content Services Administrator's Guide for more information.

The RemoteLoginManager object must be retrieved from the server using its ServiceLocator.

RemoteLoginManagerServiceLocator rlmsl =
        new RemoteLoginManagerServiceLocator();
    rlmsl.setMaintainSession(true);
    
    // initialize the RemoteLoginManager
    s_RLM = rlmsl.getRemoteLoginManager(new URL(serverUrl +
                                        "/RemoteLoginManager"));
    

The RemoteLoginManager.login method returns a set of properties about the login session (namely, the login user, session timeout, and transaction timeout). These properties are stored in an array of NamedValue pairs, and can be used as needed.

// establish a session
    NamedValue[] properties = s_RLM.login(username, password, null, null);

After logging in, get the value of the HEADER_COOKIE property from the RemoteLoginManager. This cookie will be used to register the session with other Manager instances.

// get the cookies
    s_Cookie =
        (String) ((Stub) s_RLM)._getCall().getMessageContext().getProperty(
            HTTPConstants.HEADER_COOKIE);

Note that the examples in this book use the WsConnection utility class to connect to a Content Services instance and retrieve Manager objects.

Initializing Manager Classes

Manager classes must be retrieved and initialized individually before a user can perform actions with them. Each Manager is located at a the base URL of the Web Services instance with /ManagerName appended. To retrieve an object for a Manager, you will use the corresponding Locator class.

DomainManagerServiceLocator dmsl = new DomainManagerServiceLocator();
dmsl.setMaintainSession(true);

The setMaintainSession method sets a flag to allow the Manager instance to be used across a persistent user session. This session must be registered with each Manager individually by passing the session cookie. Registering the session prevents having to authenticate and register with each Manager every time you want to perform an operation.

The Manager instance is returned from the Locator class.

DomainManager s_DM = dmsl.getDomainManager(new URL(serverUrl + "/DomainManager"));

Register the session cookie with a Manager instance by setting its HEADER_COOKIE property (Stub is a JAX-RPC class used to set properties on the Manager instance.).

((Stub) s_DM)._setProperty(HTTPConstants.HEADER_COOKIE, s_Cookie);