DFS is a service-oriented API and an abstraction layer over the Documentum Foundation Classes
(DFC). DFS is generally simpler to use from the perspective of consumer development than DFC
and is intended to allow development of client applications in less time and with less code according to the development guide.
In researching or searching Google regarding Documentum Foundation Services (which is not new to Documentum world), i have found that many links were obsolete and there was no right answer for the problems and issues i have faced, trying to test in our environment (Windows OS and Weblogic 10.3.6 app server). Please read DFS Development guide and deployment guide for a quick understanding of how to develop and deploy Documentum Foundation Services at http://support.emc.com. I have used DFS three years ago, in a project and I should admit that nothing has changed with respect to the implementation and it is just that I lost touch with the usage of DFS services.
I have used Documentum Composer 6.7 SP2 for developing DFS. Documentum Composer is built on Eclipse. Open the perspective 'Documentum Artifacts' and now, you are all set to develop your first DFS service. Documentum composer comes packaged with DFS api and all you need is to create a new Documentum Project.
1. You can use annotations in the code and please refer to the DFS development guide regarding the usage. In the example that i worked on, there is a annotation @DfsPojoService(targetNamespace = "http://example.service.com", requiresAuthentication = true). Although, for a simple HelloWorldService, you may not require authentication with the content server, you will use this feature most often in the true world scenarios. Please make sure that the targetNameSpace reflects the package structure, where your service java file resides (in our case it is HelloWorldService.java)
2. Although, i have created 'dfc.properties' in /etc/config folder and included in the classpath, after deploying the service and trying to call the service from my client, i was getting AuthenticationException. Then i realized that, when i exported the DFS Service project as Export Service Archive to create a .ear file, it didn't include the dfc.properties in the \APP-INF\classes. I had to unzip the .ear file by changing the .ear extension to .zip and copied the dfc.properties file to get past the authentication exception.
3. If you are using Weblogic, Please make sure that in the /META-INF/weblogic-application.xml, comment out <prefer-application-packages> tags like
<!--
<prefer-application-packages>
<package-name>javax.xml.ws.*</package-name>
<package-name>javax.xml.bind.*</package-name>
<package-name>javax.jws.*</package-name>
<package-name>javax.namespace.xml.*</package-name>
<package-name>javax.xml.soap.*</package-name>
<package-name>org.apache.xerces.*</package-name>
<package-name>org.apache.commons.*</package-name>
<package-name>com.sun.xml.*</package-name>
</prefer-application-packages>
-->
For me, i got 'com.emc.documentum.fs.rt.context.unrecoverableexception' until i corrected this.
1. Create a java class HelloWorldService in Web Services\src folder in the Project.
package com.service.example;
import com.emc.documentum.fs.rt.annotations.DfsPojoService;
@DfsPojoService(targetNamespace = "http://example.service.com", requiresAuthentication = true)
public class HelloWorldService
{
public String sayHello(String name)
{
return "Hello " + name;
}
}
2. Please make sure you have the following in the project properties.
3. Please include the /etc/config/dfc.properties in the classpath (As already noted, the dfc.properties was not copied to the created .ear file and i had to manually do that after creating the .ear file)
4. Since you are developing a DFS service, Please notice the below images and follow accordingly. Edit the 'DFS Serives Library' and update it by specifying that is is a service.
5. Compile the project and export it as Documentum/Export Service Archive, by specifying the directory to export and unchecking the Generate Publish Manifest as below.
6. Rename the .ear as zip and extract it. Once extracted, Please check if there is dfc.properties in the \APP-INF\classes, else copy the dfc.properties into this location. Now, you can use the folder to deploy in your weblogic application server or you can repackage into a zip and then rename it as .ear.
7. Once deployed, verify the WSDL by reaching to http:/YourAppServerHost:Port/services/example/HelloWorldService?wsdl
8. If your WSDL displays, your service is installed and ready to be consumed.
1. When you export the project as Documentum service archive, there is also another .jar get created and this should be in the build path of the DFS client that you develop.
2. Please make sure to go to the java build path, Libraries tab and edit the DFS Services Library as ' DFS Remote Client Library with UCF'
1. Create a HelloWorldClient.java and this is the DFS Service HelloWorldService consumer.
package com.client.example;
import com.emc.documentum.fs.datamodel.core.context.RepositoryIdentity;
import com.emc.documentum.fs.rt.ServiceException;
import com.emc.documentum.fs.rt.context.ContextFactory;
import com.emc.documentum.fs.rt.context.IServiceContext;
import com.emc.documentum.fs.rt.context.ServiceFactory;
import com.service.example.client.IHelloWorldService;
public class HelloWorldClient
{
public static void main(String[] args)
{
//in the real world, you will never hard code username and password.
String moduleName = "example";
String contextRoot = "http://YOURHOST:8080/services";
String repository = "YOUR-REPOSITORY-NAME-HERE";
String user = "USERNAME-HERE";
String password = "PASSWORD-HERE";
ContextFactory contextFactory = ContextFactory.getInstance();
IServiceContext context = contextFactory.newContext();
RepositoryIdentity repoId = new RepositoryIdentity();
repoId.setRepositoryName(repository);
repoId.setUserName(user);
repoId.setPassword(password);
context.addIdentity(repoId);
try
{
IServiceContext registeredContext = contextFactory.register(context, moduleName, contextRoot);
ServiceFactory serviceFactory = new ServiceFactory();
IHelloWorldService service = serviceFactory.getRemoteService(IHelloWorldService.class, registeredContext, moduleName, contextRoot);
service = ServiceFactory.getInstance().getRemoteService(IHelloWorldService.class,
context,
moduleName,
contextRoot);
System.out.println(service.getServiceContext().getIdentityCount());
System.out.println(service.sayHello("Anand"));
}
catch (ServiceException e)
{
e.printStackTrace();
}
}
}
2. Make sure all the libraries are included and copied from DFS SDK lib. Please only copy the listed libraries as shown below.
Running DFS Remote Client:
1. Now, Run the 'HelloWorldClient.java' and you should see the following
1
log4j:WARN No appenders could be found for logger (com.emc.documentum.fs.rt.handlers.UcfInitiatorHandler).
log4j:WARN Please initialize the log4j system properly.
Hello Anand
Good Blogs on DFS:
https://paulcwarren.wordpress.com/category/documentum-foundation-services/
http://blog.tsgrp.com/2011/06/13/documentum-foundation-services-%E2%80%93-what-happened/
http://ecmnotes.com/blog/2013/06/04/creating-dfs-service/
http://ajithp.com/tag/documentum-foundation-services-tutorial/
Lastly, you can try out the samples from the DFS SDK with some changes.
Good Luck!
Anand Alagappa
(DFC). DFS is generally simpler to use from the perspective of consumer development than DFC
and is intended to allow development of client applications in less time and with less code according to the development guide.
In researching or searching Google regarding Documentum Foundation Services (which is not new to Documentum world), i have found that many links were obsolete and there was no right answer for the problems and issues i have faced, trying to test in our environment (Windows OS and Weblogic 10.3.6 app server). Please read DFS Development guide and deployment guide for a quick understanding of how to develop and deploy Documentum Foundation Services at http://support.emc.com. I have used DFS three years ago, in a project and I should admit that nothing has changed with respect to the implementation and it is just that I lost touch with the usage of DFS services.
I have used Documentum Composer 6.7 SP2 for developing DFS. Documentum Composer is built on Eclipse. Open the perspective 'Documentum Artifacts' and now, you are all set to develop your first DFS service. Documentum composer comes packaged with DFS api and all you need is to create a new Documentum Project.
DFS Service Development:
Things to keep in mind:
1. You can use annotations in the code and please refer to the DFS development guide regarding the usage. In the example that i worked on, there is a annotation @DfsPojoService(targetNamespace = "http://example.service.com", requiresAuthentication = true). Although, for a simple HelloWorldService, you may not require authentication with the content server, you will use this feature most often in the true world scenarios. Please make sure that the targetNameSpace reflects the package structure, where your service java file resides (in our case it is HelloWorldService.java)
2. Although, i have created 'dfc.properties' in /etc/config folder and included in the classpath, after deploying the service and trying to call the service from my client, i was getting AuthenticationException. Then i realized that, when i exported the DFS Service project as Export Service Archive to create a .ear file, it didn't include the dfc.properties in the \APP-INF\classes. I had to unzip the .ear file by changing the .ear extension to .zip and copied the dfc.properties file to get past the authentication exception.
3. If you are using Weblogic, Please make sure that in the /META-INF/weblogic-application.xml, comment out <prefer-application-packages> tags like
<!--
<prefer-application-packages>
<package-name>javax.xml.ws.*</package-name>
<package-name>javax.xml.bind.*</package-name>
<package-name>javax.jws.*</package-name>
<package-name>javax.namespace.xml.*</package-name>
<package-name>javax.xml.soap.*</package-name>
<package-name>org.apache.xerces.*</package-name>
<package-name>org.apache.commons.*</package-name>
<package-name>com.sun.xml.*</package-name>
</prefer-application-packages>
-->
For me, i got 'com.emc.documentum.fs.rt.context.unrecoverableexception' until i corrected this.
Creating DFS Service (A simple HelloWorldService which uses repository authentication):
1. Create a java class HelloWorldService in Web Services\src folder in the Project.
package com.service.example;
import com.emc.documentum.fs.rt.annotations.DfsPojoService;
@DfsPojoService(targetNamespace = "http://example.service.com", requiresAuthentication = true)
public class HelloWorldService
{
public String sayHello(String name)
{
return "Hello " + name;
}
}
2. Please make sure you have the following in the project properties.
3. Please include the /etc/config/dfc.properties in the classpath (As already noted, the dfc.properties was not copied to the created .ear file and i had to manually do that after creating the .ear file)
4. Since you are developing a DFS service, Please notice the below images and follow accordingly. Edit the 'DFS Serives Library' and update it by specifying that is is a service.
5. Compile the project and export it as Documentum/Export Service Archive, by specifying the directory to export and unchecking the Generate Publish Manifest as below.
6. Rename the .ear as zip and extract it. Once extracted, Please check if there is dfc.properties in the \APP-INF\classes, else copy the dfc.properties into this location. Now, you can use the folder to deploy in your weblogic application server or you can repackage into a zip and then rename it as .ear.
7. Once deployed, verify the WSDL by reaching to http:/YourAppServerHost:Port/services/example/HelloWorldService?wsdl
8. If your WSDL displays, your service is installed and ready to be consumed.
DFS Remote Client Development:
Things to keep in mind:
1. When you export the project as Documentum service archive, there is also another .jar get created and this should be in the build path of the DFS client that you develop.
2. Please make sure to go to the java build path, Libraries tab and edit the DFS Services Library as ' DFS Remote Client Library with UCF'
Creating DFS Remote Client:
1. Create a HelloWorldClient.java and this is the DFS Service HelloWorldService consumer.
package com.client.example;
import com.emc.documentum.fs.datamodel.core.context.RepositoryIdentity;
import com.emc.documentum.fs.rt.ServiceException;
import com.emc.documentum.fs.rt.context.ContextFactory;
import com.emc.documentum.fs.rt.context.IServiceContext;
import com.emc.documentum.fs.rt.context.ServiceFactory;
import com.service.example.client.IHelloWorldService;
public class HelloWorldClient
{
public static void main(String[] args)
{
//in the real world, you will never hard code username and password.
String moduleName = "example";
String contextRoot = "http://YOURHOST:8080/services";
String repository = "YOUR-REPOSITORY-NAME-HERE";
String user = "USERNAME-HERE";
String password = "PASSWORD-HERE";
ContextFactory contextFactory = ContextFactory.getInstance();
IServiceContext context = contextFactory.newContext();
RepositoryIdentity repoId = new RepositoryIdentity();
repoId.setRepositoryName(repository);
repoId.setUserName(user);
repoId.setPassword(password);
context.addIdentity(repoId);
try
{
IServiceContext registeredContext = contextFactory.register(context, moduleName, contextRoot);
ServiceFactory serviceFactory = new ServiceFactory();
IHelloWorldService service = serviceFactory.getRemoteService(IHelloWorldService.class, registeredContext, moduleName, contextRoot);
service = ServiceFactory.getInstance().getRemoteService(IHelloWorldService.class,
context,
moduleName,
contextRoot);
System.out.println(service.getServiceContext().getIdentityCount());
System.out.println(service.sayHello("Anand"));
}
catch (ServiceException e)
{
e.printStackTrace();
}
}
}
2. Make sure all the libraries are included and copied from DFS SDK lib. Please only copy the listed libraries as shown below.
Running DFS Remote Client:
1. Now, Run the 'HelloWorldClient.java' and you should see the following
1
log4j:WARN No appenders could be found for logger (com.emc.documentum.fs.rt.handlers.UcfInitiatorHandler).
log4j:WARN Please initialize the log4j system properly.
Hello Anand
Good Blogs on DFS:
https://paulcwarren.wordpress.com/category/documentum-foundation-services/
http://blog.tsgrp.com/2011/06/13/documentum-foundation-services-%E2%80%93-what-happened/
http://ecmnotes.com/blog/2013/06/04/creating-dfs-service/
http://ajithp.com/tag/documentum-foundation-services-tutorial/
Lastly, you can try out the samples from the DFS SDK with some changes.
Good Luck!
Anand Alagappa