Friday, May 25, 2012

Accessing Webcenter Content repository using RIDC

My preferable way to access Webcenter Content (former UCM) repository from Java code is RIDC API. To establish RIDC connection you can use below code:

/*The Remote Intradoc Client (RIDC) provides a thin communication API 
for communication with Oracle Content Server. This API removes data 
abstractions to the content server while still providing a wrapper to 
handle connection pooling, security, and protocol specific
Intradoc communication is handled via the content server Intradoc port (typically
4444). This communication method requires a trusted connection between the
client and content*/
IdcClientManager manager = new IdcClientManager (); 

/*idc://localhost:4444 Intradoc communication. Uses the Intradoc port, 
only requires hostname and port number.
idcs://localhost:4433 SSL communication. Uses SSL over the 
Intradoc port; requires extra configuration*/
IdcClient client = manager.createClient("idc://hostname:4444");

/*Configuration of the clients can be done after they are created. Configuration
parameters include setting the socket timeouts, connection pool size, etc. The
configuration is specific to the protocol; if you cast the IdcClient object to the specific
type, you can then retrieve the protocol configuration object for that type.*/
client.getConfig().setSocketTimeout(30000); // 30 seconds
client.getConfig().setConnectionSize(20); // 20 connections

/*RIDC allows Secure Socket Layer (SSL) communication with Oracle Content Server
using the Intradoc communication protocol. To establish SSL connection you must install and enable 
the Security Providers component on the instance of the content server you wish 
to access and configure the content server for SSL communication.*/
client.getConfig().setKeystoreFile ("ketstore/client_keystore"); // keystore file
client.getConfig().setKeystorePassword ("password"); // keystore password
client.getConfig().setKeystoreAlias ("SecureClient"); // keystore aliaa
client.getConfig().setKeystoreAliasPassword ("password"); // keystore alias password

/*All calls to RIDC require some user identity. Optionally, this identity can be
accompanied by credentials as required by the protocol used. The user identity is
represented by the IdcContext object; once created, it can be reused for all subsequent
IdcContext context = new IdcContext("sysadmin");

/*You can also pass identity with passowrd: 
IdcContext userPasswordContext = new IdcContext ("sysadmin", "idc");*/

/*To invoke a service, use the ServiceRequest object, which can be obtained from the
client. Creating a new request will also create a new binder and set the service name in
the binder along with any other default parameters. You can then populate the binder
as needed for the request.*/
DataBinder dataBinder = client.createBinder ();

dataBinder.putLocal ("IdcService", "DOC_INFO_BY_NAME");

dataBinder.putLocal ("dDocName", "123simple");

ServiceResponse response = client.sendRequest (context, dataBinder);

DataBinder responseData = response.getResponseAsBinder ();

String docUrl = responseData.getLocal("DocUrl");

Friday, May 11, 2012

How to resolve: java.lang.NoClassDefFoundError: oracle/j2ee/ws/common/jaxws/ServiceDelegateImpl

Cited below error can occur when exist problem related to runtime access to wsclient.jar library.
Exception in thread "main" java.lang.NoClassDefFoundError: oracle/j2ee/ws/common/jaxws/ServiceDelegateImpl
    at jnditest.WorklistClient.connect(
    at jnditest.JNDITest.main(
Caused by: java.lang.ClassNotFoundException:
    at Method)
    at java.lang.ClassLoader.loadClass(
    at sun.misc.Launcher$AppClassLoader.loadClass(
    at java.lang.ClassLoader.loadClass(
    ... 3 more

The error message says "java.lang.NoClassDefFoundError: oracle/j2ee/ws/common/jaxws/ServiceDelegateImpl" which means that your application can't access this class. Also you must add appropriate jar including not found class to application classpath.

In case of ServiceDelegateImpl you should add %JDEV_HOME%\oracle_common\modules\oracle.webservices_11.1.1\wsclient.jar. If you are using JDeveloper, you can do this as shown below:

1. Click Project Properties menu item on your Project  in Project Inspector
2. Select Libraries and Classpath

3. Click Add JAR/Directory

4. Find appriopriate library and confirm selection