Hi,

I would like to describe step by step how to create a DFS service and DFS client via Composer. In this post, I am not exposing neither the deployment of this DFS service on an application server, neither the configuration of DFC file on server allowing the access to Documentum Content Server.
 
First, what is DFS?
EMC Documentum Foundation Services (DFS) are a set of technologies that enable service-oriented programmatic access to the EMC Documentum Content Server platform and related products. […] The design and technical implementation of DFS is grounded in the principles of Service-Oriented Architecture (SOA).

The DFS Software Development Kit (SDK) includes Java class libraries, .NET assemblies, tools, documentation, and samples that you can use to build DFS services that extend the delivered DFS services, or to build DFS consumers using the optional C# or Java client library.

 


 

DFS Service Creation

  • Create a Documentum Project:



     
     
  • DFS Libraries
    When an Documentum Project is created it also adds all the necessary DFS resources to allow you to develop Documentum services. It will deploy a copy of the DFS SDK to your core project (incidentally this is why creating the first project in a workspace takes a little longer than you might expect) and add the DFS Services Library to your project’s java build path. And add a DFS Builder for building your services.
     
    Click on the Documentum Project and bring up its DFS Module properties:

     
    …then select Builders, you should see DFS builder:

     
    …then select the Java Build Path, then the Libraries tab you will see DFS Service Library:

     
    Some words concerning the DFS Library, If you select DFS Services Library and click on Edit… button:


     
    …OR if you click on Add Library…:



     
    As you can see there are 4 types of DFS Services Library:
    o DFS Services Library: it is the default library used in order to developing services.
    o DFS Remote Client Library with UCF/MTOM: Theses libraries are used in order to developing services consumers.
    o DFS Local Client Library: This library is also used in order to developing services consumers, however, this type of library is added 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. A useful feature.

     
     
  • Building a Service
    See : EMC Documentum Documentum Foundation Services Development Guide Version 6.5. : https://www.emc.com/collateral/TechnicalDocument/docu7122.pdf
     
    There are a couple of types of DFS service; based on a POJO OR based on a BOF SBO (service-based object). They are, in fact, very similar and are just annotated java classes.
     
    o Create the com.java.lu.business.ecm.business package in the folder Web Services/src:


     
    o Create the text properties file JavaLuECMService.properties:


     
    o Create the com.java.lu.business.service.ecm.business.exception package in the folder Web Services/src:

     
    o Create the exception class JavaLuECMServiceException.java:

    package com.java.lu.business.service.ecm.business.exception;
    
    import javax.xml.bind.annotation.XmlAccessType;
    import javax.xml.bind.annotation.XmlAccessorType;
    import javax.xml.bind.annotation.XmlType;
    
    import com.emc.documentum.fs.rt.ServiceException;
    import com.java.lu.business.service.ecm.business.JavaLuECMService;
    
    @XmlType(name = "JavaLuECMServiceException", namespace = "http://exception.business.ecm.service.business.lu.java.com/")
    @XmlAccessorType(XmlAccessType.FIELD)
    public class JavaLuECMServiceException extends ServiceException {
    
    	private static final long serialVersionUID = -8678484668814217250L + JavaLuECMService.buildNumber;
    
    	public JavaLuECMServiceException() {
    		super();
    	}
    
    	public JavaLuECMServiceException(String errorCode, Throwable cause) {
    		super(errorCode, cause);
    	}
    
    	public JavaLuECMServiceException(Throwable cause) {
    		super(cause);
    	}
    }
    

     
    o Create the com.java.lu.business.service.ecm.business.result package in the folder Web Services/src:

     
    o Create the result class BinaryContent.java:

    package com.java.lu.business.service.ecm.business.result;
    
    import java.io.Serializable;
    
    import javax.xml.bind.annotation.XmlAccessType;
    import javax.xml.bind.annotation.XmlAccessorType;
    import javax.xml.bind.annotation.XmlAttribute;
    import javax.xml.bind.annotation.XmlElement;
    import javax.xml.bind.annotation.XmlRootElement;
    import javax.xml.bind.annotation.XmlType;
    
    @XmlType(name = "BinaryContent", namespace = "http://result.business.ecm.service.business.lu.java.com")
    @XmlRootElement(name = "BinaryContent")
    @XmlAccessorType(XmlAccessType.FIELD)
    public class BinaryContent implements Serializable {
    	private static final long serialVersionUID = 8693573608799806206L;
    	@XmlElement(name = "data")
    	private byte[] data;
    	@XmlAttribute(name = "format")
    	private String format;
    
    	public BinaryContent() {
    		this(null, null);
    	}
    
    	public BinaryContent(byte[] data, String format) {
    		this.data = data;
    		this.format = format;
    	}
    
    	public void setData(byte[] data) {
    		this.data = data;
    	}
    
    	public byte[] getData() {
    		return data;
    	}
    
    	public void setFormat(String format) {
    		this.format = format;
    	}
    
    	public String getFormat() {
    		return format;
    	}
    
    	@Override
    	public String toString() {
    		return new StringBuilder().append("<").append(getClass().getSimpleName()).append(" format='").append(getFormat()).append("'>").append("<data>").append(getData()).append("</data></").append(getClass().getSimpleName()).append(">").toString();
    	}
    
    	public final static String XLS_FORMAT = "excel8book";
    	public final static String XLSX_FORMAT = "excel12book";
    	public final static String PDF_FORMAT = "pdf";
    }
    

     
    o Create the result class DocumentInfo.java:

    package com.java.lu.business.service.ecm.business.result;
    
    import java.io.Serializable;
    import java.util.ArrayList;
    import java.util.List;
    
    import javax.xml.bind.annotation.XmlAccessType;
    import javax.xml.bind.annotation.XmlAccessorType;
    import javax.xml.bind.annotation.XmlAttribute;
    import javax.xml.bind.annotation.XmlElement;
    import javax.xml.bind.annotation.XmlRootElement;
    import javax.xml.bind.annotation.XmlType;
    
    
    @XmlType(name = "DocumentInfo", namespace = "http://result.business.ecm.service.business.lu.java.com")
    @XmlRootElement(name = "DocumentInfo")
    @XmlAccessorType(XmlAccessType.FIELD)
    public class DocumentInfo implements Serializable {
    	private static final long serialVersionUID = -8343058576424166034L;
    	@XmlAttribute(name = "objectId")
    	private String objectId;
    	@XmlAttribute(name = "objectName")
    	private String objectName;
    	@XmlElement(name = "content")
    	private BinaryContent content;
    	@XmlElement(name = "errors")
    	private List<ServiceError> errors;
    
    	
    	public DocumentInfo() {
    	}
    
    	public String getObjectName() {
    		return objectName;
    	}
    
    	public void setObjectName(String objectName) {
    		this.objectName = objectName;
    	}
    
    	public String getObjectId() {
    		return objectId;
    	}
    
    	public void setObjectId(String objectId) {
    		this.objectId = objectId;
    	}
    
    	public BinaryContent getContent() {
    		return content;
    	}
    
    	public void setContent(BinaryContent content) {
    		this.content = content;
    	}
    
    	public final List<ServiceError> getErrors() {
    		if (errors == null)
    			errors = new ArrayList<ServiceError>();
    		return errors;
    	}
    
    	public final void setErrors(List<ServiceError> errors) {
    		this.errors = errors;
    	}
    
    	public final void addError(ServiceError error) {
    		this.errors.add(error);
    	}
    
    	public final void addErrors(List<ServiceError> errors) {
    		this.errors.addAll(errors);
    	}
    	
    	@Override
    	public String toString() {
    		StringBuilder sb = new StringBuilder();
    		sb.append("<").append(getClass().getSimpleName());
    		sb.append(" objectId='").append(objectId).append("'");
    		sb.append(" objectName='").append(objectName).append("'");
    		sb.append(">");
    		if (content != null) {
    			sb.append("<content>").append(content).append("</content>");
    		}
    		sb.append(super.toString());
    		sb.append("</").append(getClass().getSimpleName()).append(">");
    		return sb.toString();
    	}
    }
    

     
    o Create the result error class ServiceError.java:

    package com.java.lu.business.service.ecm.business.result;
    
    import java.io.PrintWriter;
    import java.io.Serializable;
    import java.io.StringWriter;
    
    import javax.xml.bind.annotation.XmlAccessType;
    import javax.xml.bind.annotation.XmlAccessorType;
    import javax.xml.bind.annotation.XmlAttribute;
    import javax.xml.bind.annotation.XmlElement;
    import javax.xml.bind.annotation.XmlRootElement;
    import javax.xml.bind.annotation.XmlType;
    
    @XmlType(name = "ServiceError", namespace = "http://result.business.ecm.service.business.lu.java.com")
    @XmlRootElement(name = "ServiceError")
    @XmlAccessorType(XmlAccessType.FIELD)
    public class ServiceError implements Serializable {
    
    	private static final long serialVersionUID = -2515772948068877071L;
    
    	@XmlAttribute(name = "code")
    	private int code;
    	@XmlAttribute(name = "message")
    	private String message;
    	@XmlElement(name = "trace")
    	private String trace;
    
    	public final static int UNDEFINED = 0;
    
    	private static String getStackTraceAsString(Throwable t) {
    		String result = "";
    
    		if (t != null) {
    			StringWriter sw = new StringWriter();
    			PrintWriter pw = new PrintWriter(sw);
    			t.printStackTrace(pw);
    			pw.flush();
    			result = sw.toString();
    		}
    
    		return result;
    	}
    
    	public ServiceError() {
    		this(UNDEFINED, null, null);
    	}
    
    	public ServiceError(int code, String message, String trace) {
    		super();
    		this.code = code;
    		this.message = message;
    		this.trace = trace;
    	}
    
    	public ServiceError(String message) {
    		this(UNDEFINED, message, null);
    	}
    
    	public ServiceError(String message, Throwable trace) {
    		this(UNDEFINED, message, getStackTraceAsString(trace));
    	}
    
    	public int getCode() {
    		return code;
    	}
    
    	public String getMessage() {
    		return message;
    	}
    
    	public String getTrace() {
    		return trace;
    	}
    
    	public void setCode(int code) {
    		this.code = code;
    	}
    
    	public void setMessage(String message) {
    		this.message = message;
    	}
    
    	public void setTrace(String trace) {
    		this.trace = trace;
    	}
    
    	public void setTrace(Throwable trace) {
    		setTrace(getStackTraceAsString(trace));
    	}
    
    	@Override
    	public String toString() {
    		return new StringBuilder().append("<").append(getClass().getSimpleName()).append(" code='").append(getCode()).append("'").append(" message='").append(getMessage()).append("'>").append("<trace>").append(getTrace()).append("</trace>").append("</").append(getClass().getSimpleName()).append(">").toString();
    	}
    }
    

     
    o Create the service class JavaLuECMService.java with a method getDocumentInfo returning a DocumentInfo POJO from a r_object_id of document:

     

    package com.java.lu.business.service.ecm.business;
    
    import java.io.ByteArrayInputStream;
    import java.io.ByteArrayOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.Serializable;
    import java.text.MessageFormat;
    import java.util.Properties;
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
    
    import org.apache.commons.io.IOUtils;
    import org.apache.log4j.Logger;
    
    import com.documentum.fc.client.DfClient;
    import com.documentum.fc.client.IDfClient;
    import com.documentum.fc.client.IDfDocument;
    import com.documentum.fc.client.IDfSession;
    import com.documentum.fc.client.IDfSessionManager;
    import com.documentum.fc.common.DfException;
    import com.documentum.fc.common.DfLoginInfo;
    import com.documentum.fc.common.IDfLoginInfo;
    import com.documentum.fc.common.impl.MessageHelper;
    import com.emc.documentum.fs.datamodel.core.properties.NumberProperty;
    import com.emc.documentum.fs.datamodel.core.properties.PropertySet;
    import com.emc.documentum.fs.datamodel.core.properties.StringProperty;
    import com.emc.documentum.fs.rt.AuthenticationException;
    import com.emc.documentum.fs.rt.annotations.DfsPojoService;
    import com.java.lu.business.service.ecm.business.exception.JavaLuECMServiceException;
    import com.java.lu.business.service.ecm.business.result.BinaryContent;
    import com.java.lu.business.service.ecm.business.result.DocumentInfo;
    import com.java.lu.business.service.ecm.business.result.ServiceError;
    
    
    @DfsPojoService(requiresAuthentication = false, targetNamespace = "http://business.ecm.service.business.lu.java.com", useDeprecatedExceptionModel = false)
    public class JavaLuECMService implements Serializable {
    	
    	private final static Logger logger = Logger.getLogger(JavaLuECMService.class);
    	private final static PropertySet versionProperties;
    	private static final long serialVersionUID;
    	public static final long buildNumber;
    	
    	static {
    		try {
    			versionProperties = new PropertySet();
    			Properties properties = new Properties();
    			InputStream inputStream = JavaLuECMService.class.getResourceAsStream(JavaLuECMService.class.getSimpleName() + ".properties");
    			try {
    				if(inputStream!=null){
    					properties.load(inputStream);
    					buildNumber = Long.parseLong(properties.getProperty("Build-Number"));
    					serialVersionUID = 1768427593645267965L + buildNumber;
    					for (java.util.Map.Entry<Object, Object> entry : properties.entrySet()) {
    						versionProperties.set(new StringProperty(String.valueOf(entry.getKey()), String.valueOf(entry.getValue())));
    					}
    					versionProperties.set(new NumberProperty("serialVersionUID", serialVersionUID));
    				}else{
    					buildNumber = 1;
    					serialVersionUID = 1768427593645267965L;
    				}
    			} finally {
    				if(inputStream!=null){
    					inputStream.close();
    				}
    			}
    		} catch (IOException e) {
    			throw new RuntimeException(e);
    		}
    	}
    	
    	/**
    	 * Returns various properties set at packaging time.
    	 * 
    	 * @return 
    	 */
    	public PropertySet getVersionProperties() {
    		return versionProperties;
    	}
    	
    	
    	public DocumentInfo getDocumentInfo(String documentId) throws JavaLuECMServiceException, AuthenticationException {
    		if (logger.isDebugEnabled()) {
    			logger.debug(MessageFormat.format("getDocumentInfo(documentId={0}) - START", documentId));
    		}
    		DocumentInfo result;
    		try {
    			//String docbase = com.documentum.services.config.util.DocbaseUtils.getDocbaseNameFromId(documentId);
    			//if (StringUtils.isBlank(docbase)) {
    			//	throw new Exception(MessageFormat.format("Cannot determine repository from objectId {0}", documentId));
    			//}
    			String docbase = "MY_HUO_DOCBASE";			
    			String user = "huoadm";
    			String passwd = "password_4huoadm";
    			
    			IDfSession dfSession = getDfSession(user, passwd, docbase);
    			try {
    				result = new DocumentInfo();
    				// IDfDocument dfDocument = (IDfDocument) dfSession.getObject(new DfId(documentId));
    				IDfDocument dfDocument;
    				{
    					String qualification = getDocumentQualification(documentId);
    					dfDocument = (IDfDocument) dfSession.getObjectByQualification(qualification);
    					if (dfDocument == null) {
    						throw new DfException("Unable to find document for user " + dfSession.getLoginUserName() + " with qualification " + qualification);
    					}
    				}
    
    				// result.setObjectId(dfDocument.getObjectId().getId());
    				result.setObjectId(dfDocument.getChronicleId().getId());
    				result.setObjectName(dfDocument.getObjectName());
    				ByteArrayInputStream input = dfDocument.getContent();
    				try {
    					ByteArrayOutputStream output = new ByteArrayOutputStream();
    					try {
    						IOUtils.copy(input, output);
    						BinaryContent binaryContent = new BinaryContent();
    						binaryContent.setData(output.toByteArray());
    						binaryContent.setFormat(dfDocument.getContentType());
    						result.setContent(binaryContent);
    					} finally {
    						IOUtils.closeQuietly(output);
    					}
    				} finally {
    					IOUtils.closeQuietly(input);
    				}
    			} finally {
    				releaseSession(dfSession);
    			}
    		} catch (Throwable e) {
    			logger.fatal(e.getMessage(), e);
    			result = new DocumentInfo();
    			result.getErrors().add(new ServiceError(ServiceError.UNDEFINED, e.getMessage(), MessageHelper.getStackTraceAsString(e)));
    		}
    		return result;
    	}	
    
    	private IDfSession getDfSession(String user, String passwd, String docbase) throws Exception {
    		IDfLoginInfo login = new DfLoginInfo();
    		login.setUser(user);
    		login.setPassword(passwd);
    		IDfClient client = DfClient.getLocalClient(); // new DfClient();
    		IDfSessionManager sessMgr = client.newSessionManager();
    		sessMgr.setIdentity(docbase, login);
    		IDfSession idfSession = sessMgr.getSession(docbase);
    		if (idfSession != null)
    			System.out.println("Session created successfully");
    
    		return idfSession;
    	}
    	
    	private void releaseSession(IDfSession dfSession) throws Exception {
    		dfSession.getSessionManager().release(dfSession);
    	}
    	
    	private String getDocumentQualification(String documentId) {
    		Pattern pattern = Pattern.compile("^(([a-f0-9]{2})([a-f0-9]{6})([a-f0-9]{8}))$");
    		Matcher matcher = pattern.matcher(documentId);
    		if (!matcher.matches()) {
    			throw new RuntimeException(documentId + " is not a valid objectId");
    		}
    		StringBuilder dql = new StringBuilder();
    		dql.append(" dm_document WHERE r_object_id IN (");
    		dql.append("  SELECT r_object_id");
    		dql.append("  FROM my_huo_document");
    		dql.append("  WHERE ").append("i_chronicle_id").append(" = ID('").append(matcher.group(1)).append("')");
    		dql.append(")");
    		;
    		return dql.toString();
    	}
    	
    
    }
    

     
    o Assuming that you have automatic build turned on from project menu in composer, you should see the DFS Builder leap into life and attempt to build the service. In your Console view you’ll get a build report:

    Buildfile: C:\Workspaces\DocumentumCoreProject\dfs6.7\dfs-build.xml
    …
    
    generate:
    [generateModel] Creating 'myservices-mybusiness-service-model.xml'
    [generateArtifacts] Log4j not found. In order to avoid error messages during build process, please include log4j.jar into your classpath or copy it into $ANT_HOME/lib folder
    [generateArtifacts] Generating DFS artifacts
    [generateArtifacts] Generating JAXWS artifacts (wsgen & wsimport)
    [generateArtifacts] Note: C:\Users\HUSEYI~1\AppData\Local\Temp\dfs-sdk-3247901826753623178-server-artifacts-generator\wsimport\wsgen\generated\src\com\java\lu\business\service\ecm\business\ws\JavaLuECMServiceWebService.java uses unchecked or unsafe operations.
    [generateArtifacts] Note: Recompile with -Xlint:unchecked for details.
    [generateArtifacts] fdir.getAbsolutePath() = C:\Users\HUSEYI~1\AppData\Local\Temp\dfs-sdk-3247901826753623178-server-artifacts-generator\wsimport\wsgen\wsdl\com.java.lu.business.service.ecm.business.ws
    [generateArtifacts] ------------------------------------------------------------
    [generateArtifacts] SerializableExceptionPostProcessor.addSerializableException
    [generateArtifacts] file = C:\Users\HUSEYI~1\AppData\Local\Temp\dfs-sdk-3247901826753623178-server-artifacts-generator\wsimport\src\com\java\lu\business\service\ecm\business\ws\JavaLuECMServicePort.java
    [generateArtifacts] ------------------------------------------------------------
    BUILD SUCCESSFUL
    Total time: 22 seconds
    

     
    o After building, the Web Services/bin/gen-src folder contains a set of generated sources from the POJO service : jax-ws web service sources, a set of classes and wsdl.

     
     

  • Export/Test the service
     
    There are two approaches to test our service:
     
    o The first approach is to create a parallel test project with Junit tests that exercise your service. To facilitate this your test project would be configured with the local client library, as described above, so that it can make local invocations to your service. This project should of course be placed under the same version control as your services project.
     
    o The second approach is to export your services as an ear, deploy it to an application server and exercise your service again via another project capable of making remote service invocations. The service’s context root and module name affect the URL of service, these informations must be set via right-click on the project and select Properties->Documentum Project->DFS Module:


     
    Here, we use the second approach:
     
    o Right-click on the project and select Export…, then Documentum >> Export Service Archive to generate ear of service and client reference library:

     

    o Select the output folder and uncheck the Generate Publish Manifest checkbox:

    Tips: To avoid re-entering the destination directory each time, change the Export Directory setting in Preferences in COMPOSER:

     

    o Click on Finish button to launch the generation:


     

    Override ignored for property "TODAY"
        [mkdir] Created dir: C:\temp\dfs6.7sp2\20171109141738
         [copy] Copying 1 file to C:\temp\dfs6.7sp2\20171109141738
         [copy] Copying C:\temp\dfs6.7sp2\mybusiness.ear to C:\temp\dfs6.7sp2\20171109141738\DOCmybusiness-1.3.141.ear
         [copy] Copying 1 file to C:\temp\dfs6.7sp2\20171109141738
         [copy] Copying C:\temp\dfs6.7sp2\mybusiness-remote.jar to C:\temp\dfs6.7sp2\20171109141738\mybusiness-remote.jar
         [move] Moving 1 file to C:\temp\dfs6.7sp2
         [move] Attempting to rename: C:\temp\dfs6.7sp2\mybusiness.ear to C:\temp\dfs6.7sp2\DOCmybusiness-1.3.141.ear
         [move] Moving 1 file to C:\temp\dfs6.7sp2
         [move] Skipping self-move of C:\temp\dfs6.7sp2\mybusiness-remote.jar
    BUILD SUCCESSFUL
    
    BUILD SUCCESSFUL
    Total time: 1 minute 4 seconds
    

     
     

  • This will produce:
    o an ear file which can be deploy onto an application server (websphere, tomcat…) : mybusiness.ear
    o a jar file containing the client classes : mybusiness-remote.jar
     
    The output folder contains the ear file (service) and the jar (remote) and a subfolder “YYYYMMDDHHMISS” with the previous ear.


     
    Note : The naming of ear file is configurable in dfs6.7 folder of DocumentumCoreProject project:
    dfs-build.xml:

    <property name="ear.filename.new" value="DOC${module.name}-${build.version}.ear" />
    <property name="build.version" value="${application.version}.${release.version}.${build.number}" />
    

    dfs-build.properties:

    module.name=module-name
    application.version=1
    release.version=3
    build.number=141
    

     
     

  • Deployment of EAR on Application Server
    Once EAR file deployed, you can perform a quick sanity check by requesting the service’s WSDL document: http://localhost:9080/myservices/mybusiness/JavaLuECMService

     
    The WSDL is available http://localhost:9080/myservices/mybusiness/JavaLuECMService?wsdl

    This XML file does not appear to have any style information associated with it. The document tree is shown below.
    <!--
     Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.7-b01-. 
    -->
    <definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://ws.business.ecm.service.business.lu.java.com/"xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="JavaLuECMService" targetNamespace="http://ws.business.ecm.service.business.lu.java.com/">
    <types>
    <xsd:schema>
    <xsd:import namespace="http://ws.business.ecm.service.business.lu.java.com/" schemaLocation="http://localhost:9080/myservices/mybusiness/JavaLuECMService?xsd=1"/>
    </xsd:schema>
    <xsd:schema>
    <xsd:import namespace="http://rt.fs.documentum.emc.com/" schemaLocation="http://localhost:9080/myservices/mybusiness/JavaLuECMService?xsd=2"/>
    </xsd:schema>
    <xsd:schema>
    <xsd:import namespace="http://result.business.ecm.service.business.lu.java.com" schemaLocation="http://localhost:9080/myservices/mybusiness/JavaLuECMService?xsd=3"/>
    </xsd:schema>
    <xsd:schema>
    <xsd:import namespace="http://properties.core.datamodel.fs.documentum.emc.com/" schemaLocation="http://localhost:9080/myservices/mybusiness/JavaLuECMService?xsd=4"/>
    </xsd:schema>
    <xsd:schema>
    <xsd:import namespace="http://core.datamodel.fs.documentum.emc.com/" schemaLocation="http://localhost:9080/myservices/mybusiness/JavaLuECMService?xsd=5"/>
    </xsd:schema>
    <xsd:schema>
    <xsd:import namespace="http://content.core.datamodel.fs.documentum.emc.com/" schemaLocation="http://localhost:9080/myservices/mybusiness/JavaLuECMService?xsd=6"/>
    </xsd:schema>
    </types>
    <message name="getVersionProperties">
    <part element="tns:getVersionProperties" name="parameters"/>
    </message>
    <message name="getVersionPropertiesResponse">
    <part element="tns:getVersionPropertiesResponse" name="parameters"/>
    </message>
    <message name="ServiceException">
    <part xmlns:ns1="http://rt.fs.documentum.emc.com/" element="ns1:ServiceException" name="fault"/>
    </message>
    <message name="getDocumentInfo">
    <part element="tns:getDocumentInfo" name="parameters"/>
    </message>
    <message name="getDocumentInfoResponse">
    <part element="tns:getDocumentInfoResponse" name="parameters"/>
    </message>
    <message name="AuthenticationException">
    <part element="tns:AuthenticationException" name="fault"/>
    </message>
    <message name="JavaLuECMServiceException">
    <part element="tns:JavaLuECMServiceException" name="fault"/>
    </message>
    <portType name="JavaLuECMServicePort">
    <operation name="getVersionProperties">
    <documentation>
    Returns various properties set at packaging time. @return
    </documentation>
    <input message="tns:getVersionProperties"/>
    <output message="tns:getVersionPropertiesResponse"/>
    <fault message="tns:ServiceException" name="ServiceException"/>
    </operation>
    <operation name="getDocumentInfo">
    <input message="tns:getDocumentInfo"/>
    <output message="tns:getDocumentInfoResponse"/>
    <fault message="tns:AuthenticationException" name="AuthenticationException"/>
    <fault message="tns:JavaLuECMServiceException" name="JavaLuECMServiceException"/>
    <fault message="tns:ServiceException" name="ServiceException"/>
    </operation>
    </portType>
    <binding name="JavaLuECMServicePortBinding" type="tns:JavaLuECMServicePort">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="getVersionProperties">
    <soap:operation soapAction=""/>
    <input>
    <soap:body use="literal"/>
    </input>
    <output>
    <soap:body use="literal"/>
    </output>
    <fault name="ServiceException">
    <soap:fault name="ServiceException" use="literal"/>
    </fault>
    </operation>
    <operation name="getDocumentInfo">
    <soap:operation soapAction=""/>
    <input>
    <soap:body use="literal"/>
    </input>
    <output>
    <soap:body use="literal"/>
    </output>
    <fault name="AuthenticationException">
    <soap:fault name="AuthenticationException" use="literal"/>
    </fault>
    <fault name="JavaLuECMServiceException">
    <soap:fault name="JavaLuECMServiceException" use="literal"/>
    </fault>
    <fault name="ServiceException">
    <soap:fault name="ServiceException" use="literal"/>
    </fault>
    </operation>
    </binding>
    <service name="JavaLuECMService">
    <port binding="tns:JavaLuECMServicePortBinding" name="JavaLuECMServicePort">
    <soap:address location="http://localhost:9080/myservices/mybusiness/JavaLuECMService"/>
    </port>
    </service>
    </definitions>
    

     
     

 


 

DFS Service Client Creation

  • Create a Documentum Project:

     
  • Change the default DFS Services Library to DFS Local Client Library:

     
  • Add the jar xxxx-remote.jar previously generated in the Java Build Path of Client project:


     

  • Create a new package com.java.lu.test in the folder src / com.java.lu.test:

     
  • Create a class JavaLuECMServiceClient:

     

    package com.java.lu.test;
    
    import java.net.URL;
    import java.util.ArrayList;
    import java.util.List;
    import java.util.Set;
    import java.util.TreeSet;
    
    import javax.xml.bind.JAXBContext;
    import javax.xml.namespace.QName;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.soap.SOAPEnvelope;
    import javax.xml.soap.SOAPFactory;
    import javax.xml.soap.SOAPHeader;
    import javax.xml.ws.handler.Handler;
    import javax.xml.ws.handler.HandlerResolver;
    import javax.xml.ws.handler.MessageContext;
    import javax.xml.ws.handler.PortInfo;
    import javax.xml.ws.handler.soap.SOAPHandler;
    import javax.xml.ws.handler.soap.SOAPMessageContext;
    
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    
    import com.emc.documentum.fs.datamodel.core.context.BasicIdentity;
    import com.emc.documentum.fs.datamodel.core.context.ServiceContext;
    import com.java.lu.business.service.ecm.business.result.DocumentInfo;
    import com.java.lu.business.service.ecm.business.ws.JavaLuECMService;
    import com.java.lu.business.service.ecm.business.ws.JavaLuECMServicePort;
    import com.sun.xml.internal.bind.api.JAXBRIContext;
    
    public class JavaLuECMServiceClient {
    
    	public static void main(String[] args) {
    		try {
    			final JavaLuECMServicePort service = registerToDocumentum("http://localhost:9080/myservices/mybusiness/JavaLuECMService?wsdl", "huoadm", " password_4huoadm");
    			DocumentInfo documentInfo = service.getDocumentInfo("0902xxxxxxe14");
    			System.out.println(documentInfo.getObjectId());
    			System.out.println(documentInfo.getObjectName());
    			System.out.println(documentInfo.getContent().getFormat());
    			System.out.println(documentInfo.getContent().getData().length);
    
    		} catch (Throwable e) {
    			e.printStackTrace();
    		}
    	}
    
    	private static JavaLuECMServicePort registerToDocumentum(String urlWS, String user, String pwd) {
    		try {
    			ServiceContext serviceContext = new ServiceContext();
    			BasicIdentity basicIdentity = new BasicIdentity();
    			basicIdentity.setUserName(user);
    			basicIdentity.setPassword(pwd);
    			serviceContext.getIdentities().add(basicIdentity);
    			JAXBContext j = JAXBRIContext.newInstance(ServiceContext.class);
    			Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
    			j.createMarshaller().marshal(serviceContext, document);
    			final Element wsseSecurity = document.getDocumentElement();
    			
    			JavaLuECMService yourWebService = new JavaLuECMService(new URL(urlWS), new QName("http://ws.business.ecm.service.business.lu.java.com/", "JavaLuECMService"));
    			yourWebService.setHandlerResolver(new HandlerResolver() {
    				public List<Handler> getHandlerChain(PortInfo portInfo) {
    					List<Handler> handlerList = new ArrayList<Handler>();
    					handlerList.add(new SOAPHandler<SOAPMessageContext>() {
    						public void close(MessageContext context) {
    						}
    
    						public Set<QName> getHeaders() {
    							return new TreeSet<QName>();
    						}
    
    						public boolean handleFault(SOAPMessageContext context) {
    							throw new UnsupportedOperationException("Not supported yet.");
    						}
    
    						public boolean handleMessage(SOAPMessageContext context) {
    							Boolean outboundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
    							if (outboundProperty.booleanValue()) {
    								try {
    									SOAPEnvelope envelope = context.getMessage().getSOAPPart().getEnvelope();
    									SOAPHeader header = envelope.addHeader();
    									header.addChildElement(SOAPFactory.newInstance().createElement(wsseSecurity));
    								} catch (Exception e) {
    									System.out.println("Exception in handler: " + e);
    								}
    							} else {
    								// inbound
    							}
    							return true;
    						}
    					});
    					return handlerList;
    				}
    			});
    			return yourWebService.getJavaLuECMServicePort();
    
    		} catch (Exception e) {
    			throw new RuntimeException(e);
    		}
    	}	
    }
    

     
     

  • Execute this client class:
    0902xxxxxxe14
    My doc name
    excel12book
    8739
    

That’s all!!!

Huseyin OZVEREN