(private) sorry...!! contact@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

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.

Select a Java Project

Give the project name and click on finish

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.5samplesDfsJavaSamplesetc

Consumer Project Navigator

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

Java Build Project consumer

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

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

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

 

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.

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:workspaceDFSProjClientsrcprgclientexample";
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";
}

Leave a Reply