Mumbai, India
ecmnotes.com parag@ecmnotes.com

Creating a DFS Consumer

Just as a quick aside if you do need to create a consumer, select the “DFS Services Library” entry and then select Edit, you should see something like this:-

DFS Services Library

DFS Services Library

As you can see there are in fact 4 flavours of DFS services library. The first, and the default, is concerned with developing services. The remaining three are actually concerned with developing service consumers.

They are pretty self-explanatory. The only one that perhaps requires a little explanation is the last; “DFS Local Client”. You add this type of library to projects that are acting as “functional tests” for your services projects.Typically, you create one or more of these “functional test” projects in the same workspace as your services projects and configure them with this type of library. This then allows you to debug from the client into the service and back again without having to deploy to a server.

Creating a Java Client Consumer 

As JMS is up and DFS available to consumer, we can go ahead with development of java consumer for the service.Create New Java project in composer/eclipsr using Click on File>> New>>Java Project.

Java Project

Java Project

Give the project name and click on finish

Creating A Java Project

Creating A Java Project

Inside the Project folder create a folder structure as shown below. Import the dfc.properties and dfs-client.xml from  emc-dfs-sdk-6.5\samples\DfsJavaSamples\etc

Consumer Project Navigator

Consumer Project Navigator

Add etc/config folder to source folders on build path.

Java Build Project

Java Build Project

In the library tab add the following external jars for a remote consumer

External Jars

External Jars

Also,add helloworld-remote.jar which is available at the location where the ear file was exported during web service export.

Add Hello World Jar

Add Hello World Jar

Steps to keep in mind while creating DFS client

Interaction between the DFS client and the services persist on the DFS data model.The data created or modified from both sides move with the compliance to the data model.

Create consumer class-

New Java Consumer

New Java Consumer

package com.service.example;

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 DFSConsumer {

/**
* @param args
* @throws ServiceException
*/
public static void main(String[] args) {
try {
ContextFactory contextFactory = ContextFactory.getInstance();
IServiceContext context = contextFactory.getContext();
// IServiceContext registeredContext = contextFactory.register(context, Constants.SERVICE_MODULE, Constants.SERVICE_URL);
ServiceFactory serviceFactory = ServiceFactory.getInstance();
IHelloWorldService service = serviceFactory.getRemoteService(IHelloWorldService.class, context, Constants.SERVICE_MODULE, Constants.SERVICE_URL);
// IHelloWorldService service = serviceFactory.getRemoteService(IHelloWorldService.class, registeredContext);
String filePath = “C:\\workspace\\DFSProjClient\\src\\prg\\client\\example”;
String fileName = “Utility.java”;
String importPath = “\\Temp”;
// boolean imported = service.importFile(filePath, fileName, importPath);
// System.out.println(imported);
System.out.println(service.sayHello(“Parag”));
}
catch(ServiceException ex) {
ex.printStackTrace();
}
}

}

package com.service.example;

public class Constants {

public static final String SERVICE_MODULE = “helloworld”;
public static final String SERVICE_URL = “http://localhost:9080/services”;
}

It will give compilation error for IHelloWorldService object class. To resolve this, import the jar file helloworld-remote.jar generated while exporting the service.Run the client code to use methods defined in service.

 

 

 

Leave a Reply