java call filenet ejb api

来源:互联网 发布:java.long.ill 编辑:程序博客网 时间:2024/06/06 05:14

filenet api有ejb和webservice

项目里使用的是filenet ejb api,自己写了一个test类for test filenet login and take the session,花了很长时间才成功,当中遇到了很多错误,记录一下。

filenet service deploy in websphere server, so the program demo is for websphere 6。

连接filenet的代码很简单,复杂的是它的环境设置,先记录它的环境设置

copy AppClient 去到本地

 

jar file:

com.ibm.ws.admin.client_6.1.0.jar,

com.ibm.ws.runtime_6.1.0.jar,

commons-codec.jar,

commons-collections.jar,

commons-logging-1.0.4.jar,

commons-logging.jar,

Jace.jar,

javaapi.jar,

log4j-1.2.14.jar,

ws_runtime.jar

config file:

jaas.conf.Websphere,

sas.client.props,

ssl.client.props,

log4j.xml,

copy all the file from:%{was_home}%\AppServer\profiles\AppSrv01\etc

(里面是trust文件和key文件,把它们拷贝到本地,如:C:\testetc)

修改

ssl.client.props

user.root=C:\testetc

sas.client.props

com.ibm.CORBA.securityServerHost=XXX.XX.XXX.XXX

com.ibm.CORBA.securityServerPort=2809(我滴BOOTSTRAP_ADDRESS port)

确定 jaas.conf.Websphere

FileNetP8Engine {

com.ibm.ws.security.common.auth.module.proxy.WSLoginModuleProxy required

delegate=com.ibm.ws.security.common.auth.module.WSLoginModuleImpl;

};

设置was

一切都准备好了

开始代码

建立一个JAVA工程,把以上的jar导到工程里,建一个类包,拷贝

jaas.conf.Websphere,

sas.client.props,

ssl.client.props,

log4j.xml进类包里

 

建立一个类:FileNetSession.java

建立一个方法:

 

public Session getSession(String userId, String password)

 {

try {

System.setProperty("java.naming.factory.initial","com.ibm.websphere.naming.WsnInitialContextFactory");

System.setProperty("java.naming.provider.url","iiop://XXX.XXX.XXX.XXX:2809");

System.setProperty("com.ibm.CORBA.ConfigURL","file:ert/sas.client.props");

System.setProperty("java.security.auth.login.config","file:ert/jaas.conf.Websphere");

System.setProperty("com.ibm.SSL.ConfigURL","file:ert/ssl.client.props");

Session myCESession = ObjectFactory.getSession(appId,Session.DEFAULT, userId, password);

myCESession.verify();

return myCESession;

} catch (Exception e) {

e.printStackTrace();

returnnull;

}

}

建立一个search方法

 

public void testSearch(Session filnetSession)

{

//objectStoreName是我们在filenet里做的一个项目对象

//from XXXX 是在对象里做的不同的类,比如一个类叫XXXX,条件是这个类里我们生成的属性,比如有属性是submissionid,

//u can find all the column in filenet database docversion also.

String str = "ApplicationLicenceNumber = 'E201002844'";

String objectStoreName="XXXX";

StringBuffer sql = new StringBuffer("select ScannedDate from XXXX where " + str +

" and SubmissionID = 'XXXXX' and ContentSize is not null" +

" order by ScannedDate desc");

String xmlreq ="<request>" +

"<objectstores mergeoption=\"union\">" +

"<objectstore id=\"" + objectStoreName +"\"/>" +

"</objectstores>" +

"<querystatement>" + sql.toString() +"</querystatement>" +

"<options cursorlocation=\"client\"/>" +

"</request>";

Search search = ObjectFactory.getSearch(filnetSession);

Documents docs = (Documents)search.singleObjectTypeExecute(xmlreq,BaseObject.TYPE_DOCUMENT);

System.out.println(docs.size());

if(docs !=null && docs.size() > 0){

Document tmp = (Document)docs.get(0);

String id = tmp.getVersionSeries().getId();

System.out.println(id);

}

}

 

注意:

运行的环境必须是websphere自己的JAVA jre。可以在AppClient里找到。

ERROR api.BadReferenceException: [throw] com.filenet.api.exception.EngineRuntimeException;Requested item not found. Principal UNAUTHENTICATED not found. [Code=null]; OMFC/TheNetwork/NoOp//E_OBJECT_NOT_FOUND

com.filenet.wcm.api.BadReferenceException: com.filenet.api.exception.EngineRuntimeException;Requested item not found. Principal UNAUTHENTICATED not found. [Code=null]; OMFC/TheNetwork/NoOp//E_OBJECT_NOT_FOUND

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:67).....

一般这样的错误是环境配置没完成,缺少config file造成的,以上所提到的config file一定要在filenet server的server上拷贝下来,file要一致

 

 

原创粉丝点击