Oracle® Content Services Application Developer's Guide 10g Release 1 (10.1.1) Part Number B14494-01 |
|
|
View PDF |
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:
activation
axis
commons-discovery-0.2
commons-logging-1.0.3
content-ws-client
http_client
jaxrpc
mail
saaj
wsdl4j-1.5.1
xmlpaserv2
The examples in this guide are available in the Toolkit in the sample_code/sample_webservices/src/oracle/ifs/examples/ws
directory.
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, theCleartextAuthenticationRequiresHttps
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.
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);