Hi,
I have to do a Web service that also consumes the DFS services so I can create new documents in Documentum 6.5.
I downloaded the DFS SDK sample codes and executed them. All worked correctly.
After that I tried to create a Java Web service that executed the same code as, for example, TQueryServiceTest java class.
I created a class like this:
It has the same code as the class TQueryServiceTest but erasing main method and changing it by a "SUMAR" method.
I'm using Tomcat 5.5 with Axis2-1.5.1 and JDK 1.6. and Eclipse Helios.
I'm creating the web service using the wizard. First a Dynamic project and after that creating the class and from the class creating a web service. After that, I add the jar files coming in the DFS SDK package.
When I run the web service and execute the "sumar" method. It only has to add two values, but also execute the TQueryService logic.
The error it gives me is
[ERROR] javax.xml.bind.MarshalException
- with linked exception:
[javax.xml.bind.JAXBException: com.emc.documentum.fs.services.core.Execute is not known to this context]
java.lang.reflect.InvocationTargetException
public void setContext(){
/*
* Get the service context and set the user
* credentials and repository information
*/
ContextFactory contextFactory = ContextFactory.getInstance();
serviceContext = contextFactory.newContext();
RepositoryIdentity repoId = new RepositoryIdentity();
repoId.setRepositoryName(repository);
repoId.setUserName(userName);
repoId.setPassword(password);
serviceContext.addIdentity(repoId);
}
/*
* Demonstrates a typical scenario for calling the query service.
* Gets an instance of the Query service and calls the execute operation
* with a hard-coded query and operation options.
*/
public void callQueryService(){
/*
* Get an instance of the QueryService by passing
* in the service context to the service factory.
*/
try{
ServiceFactory serviceFactory = ServiceFactory.getInstance();
IQueryService querySvc =
serviceFactory.getRemoteService(IQueryService.class, serviceContext,
moduleName, host);
/*
* Construct the query and the QueryExecution options
*/
PassthroughQuery query = new PassthroughQuery();
query.setQueryString("select r_object_id, "
+ "object_name from dm_cabinet");
query.addRepository(repository);
QueryExecution queryEx = new QueryExecution();
queryEx.setCacheStrategyType(CacheStrategyType.DEFAULT_CACHE_STRATEGY);
/*
* Execute the query passing in the operation options and print the result
*/
OperationOptions operationOptions = null;
QueryResult queryResult = querySvc.execute(query, queryEx, operationOptions);
System.out.println("QueryId == " + query.getQueryString());
System.out.println("CacheStrategyType == " + queryEx.getCacheStrategyType());
DataPackage resultDp = queryResult.getDataPackage();
List<DataObject> dataObjects = resultDp.getDataObjects();
int numberOfObjects = dataObjects.size();
System.out.println("Total objects returned is: " + numberOfObjects);
for (DataObject dObj : dataObjects)
{
PropertySet docProperties = dObj.getProperties();
String objectId = dObj.getIdentity().getValueAsString();
String docName = docProperties.get("object_name").getValueAsString();
System.out.println("Document " + objectId + " name is " + docName);
}
}
catch (ServiceException e){
e.printStackTrace();
}
}
public int sumar(int a, int b){
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
try {
ClassLoader cl = getClass().getClassLoader();
Thread.currentThread().setContextClassLoader(cl);
// .. do DFS stuff
this.setContext();
this.callQueryService();
} finally {
Thread.currentThread().setContextClassLoader(tccl);
}
return(a+b);
}