Here's a zip file with the complete code. Just update the make.bat file with your paths, double click on "make.bat" and it should work.
Download full code
Key points (this is all included in the zip file link above) -
- setProperty - include path to sas.client.props, edited with: com.ibm.CORBA.securityServerHost=127.0.0.1 and com.ibm.CORBA.securityServerPort=2809
- setProperty - include path to "jaas.conf.WebSphere"
-
- Include in your classpath
jace.jar, log4j.jar, and com.ibm.ws.admin.client_7.0.0.jar
- Make sure everything is running: Websphere, CE, etc. You can check by browsing to: http://localhost:9080/wsi/FNCEWS40MTOM/ and http://localhost:2809/ (this will spit out something like "GIOP", at least telling you that this port is active).
- Troubleshooting: include a log4j.xml file configured to DEBUG output level
Test code:
Make.bat
rem update the paths to your jace.jar, log4j.jar,
rem and com.ibm.ws.admin.client_7.0.0.jar below:
rem ------ update these: --------------
set cp=C:/FNSW/CE_API/lib/jace.jar
set cp=%cp%;C:/FNSW/CE_API/lib/log4j.jar
set cp=%cp%;C:/Progra~1/IBM/WebSphere/AppServer/runtimes/com.ibm.ws.admin.client_7.0.0.jar
set WAS_JAVA=C:/Progra~1/IBM/WebSphere/AppServer/java/bin
rem Build the test
rem (update with the path to the Websphere java/javac
rem (specifically, the websphere executables, not just any jdk/jre ...)
"%WAS_JAVA%/javac.exe" -classpath "%cp%" FileNetConnectionTest.java
rem Run the test
"%WAS_JAVA%/java.exe" -classpath "%cp%;." FileNetConnectionTest
rem pause
FileNetConnectionTest.java
import java.util.Iterator;
import javax.security.auth.Subject;
import com.filenet.api.admin.ClassDefinition;
import com.filenet.api.admin.PropertyDefinition;
import com.filenet.api.collection.PropertyDefinitionList;
import com.filenet.api.core.Connection;
import com.filenet.api.core.Domain;
import com.filenet.api.core.Factory;
import com.filenet.api.core.ObjectStore;
import com.filenet.api.util.UserContext;
public class FileNetConnectionTest {
public String FILENET_USERNAME = "FileNetUserNameHere";
public String FILENET_PASSWORD = "FileNetPasswordHere";
public String FILENET_URI = "iiop://localhost:2809/FileNet/Engine";
public String CE_DOMAIN = "FileNetDomainHere";
public String CE_OBJECTSTORE = "FileNetObjectStoreHere";
public static void main(String args[]) {
FileNetConnectionTest test = new FileNetConnectionTest();
test.Go();
}
public void Go() {
System.setProperty ("java.naming.factory.initial",
"com.ibm.websphere.naming.WsnInitialContextFactory");
System.setProperty("java.naming.provider.url","iiop://localhost:2809");
//Use absolute file path as needed, e.g.:
//System.setProperty("com.ibm.CORBA.ConfigURL",
// "file:c:/path/to/file/sas.client.props");
System.setProperty("com.ibm.CORBA.ConfigURL", "file:sas.client.props");
System.setProperty("java.security.auth.login.config", "file:jaas.conf.WebSphere");
System.out.println("Connect to " + FILENET_URI);
Connection ceConnection = Factory.Connection.getConnection(FILENET_URI);
System.out.println("CreateSubject ...");
Subject ceSubject = UserContext.createSubject(ceConnection, FILENET_USERNAME,
FILENET_PASSWORD, null);
System.out.println("PushSubject ...");
UserContext.get().pushSubject(ceSubject);
System.out.println("ceConnection: " + ceConnection.toString());
System.out.println("FetchInstance for " + CE_DOMAIN);
Domain ceDomain = Factory.Domain.fetchInstance(ceConnection,
CE_DOMAIN, null);
System.out.println("Fetch object store instance for " + CE_OBJECTSTORE);
ObjectStore ceObjectStore = Factory.ObjectStore.fetchInstance(ceDomain,
CE_OBJECTSTORE, null);
System.out.println("Fetch Document instance");
ClassDefinition classDef = Factory.ClassDefinition.fetchInstance(ceObjectStore,
"Document", null);
PropertyDefinitionList properties = classDef.get_PropertyDefinitions();
for (Iterator propertyIter = properties.iterator(); propertyIter.hasNext();) {
PropertyDefinition property = (PropertyDefinition) propertyIter.next();
System.out.println("Property: " + property.get_DisplayName());
}
UserContext.get().popSubject();
}
}