top-image

LATEST ARTICLES

Hi,

Here, an simple example of use of logging platform NLog in C# projects. Or course, you need add reference to Nlog package in your project via NuGet Package Manager.

NLog is a free logging platform for .NET, NETSTANDARD, Xamarin, Silverlight and Windows Phone with rich log routing and management capabilities. NLog makes it easy to produce and manage high-quality logs for your application regardless of its size or complexity.

using System;
using NLog;
using NLog.Config;
using NLog.Targets;
using System.IO;
using System.Collections.ObjectModel;
using NLog.Layouts;

namespace HuoBlog.Logging
{

    public static class LoggerService
    {
        private static Logger logger;
        private static readonly string LOGGER_TARGET_FILE_NAME = "file";

        public static string ForceNewLoggerFile(string logFilePath = null)
        {
            logger = null;
            GetLogger(logFilePath);
            return GetLogFilePath();
        }

        public static string GetLogFilePath()
        {
            string logFilePath = null;
            if(logger != null)
            {
                foreach (Target target in LogManager.Configuration.AllTargets)
                {
                    if (target.GetType() == typeof(FileTarget) 
                        && ((FileTarget)target).FileName.GetType() == typeof(SimpleLayout))
                    {
                        SimpleLayout layout = (SimpleLayout) ((FileTarget)target).FileName;
                        return layout.Text;
                    }
                }
            }

            return logFilePath;
        }

        private static Logger GetLogger(string logFilePath = null)
        {
            if (logger == null)
            {
                // Log file
                {
                    if(logFilePath == null) // Generate a logfile
                    {
                        // OLD : 
                        //string outputPath = Path.Combine(Environment.CurrentDirectory, "output");
                        //if (!Directory.Exists(outputPath))
                        //    Directory.CreateDirectory(Path.Combine(Environment.CurrentDirectory, "output"));
                        // NEW: 
                        string outputPath = Environment.CurrentDirectory;
                        logFilePath = Path.Combine(outputPath, "HuoBlog_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".log");
                    }
                }

                // Config logger
                {
                    var config = new LoggingConfiguration();
                    var fileTarget = new FileTarget();
                    fileTarget.FileName = logFilePath;
                    fileTarget.Layout = "${message}";
                    config.AddTarget(LOGGER_TARGET_FILE_NAME, fileTarget);
                    config.LoggingRules.Add(new LoggingRule("*", LogLevel.Info, fileTarget));
                    LogManager.Configuration = config;
                }

                logger = LogManager.GetLogger("Extract");
            }

            return logger;
        }

        public static void Info(string message)
        {
            GetLogger().Info("INFO: " + message);
        }

        public static void Warn(string message)
        {
            GetLogger().Warn("WARNING: " + message);
        }

        public static void Error(string message)
        {
            GetLogger().Error("ERROR: " + message);
        }

        public static void Print(string message)
        {
            GetLogger().Info(message);
        }
        
    }
}

….

try{
	string logFilePath = LoggerService.ForceNewLoggerFile();
	// ...	

	LoggerService.Info("############ HuoBlog - Started at " + DateTime.Now);
	LoggerService.Print("\n\n");
	// ...	
}
catch (Exception ex)
{
	LoggerService.Error(ex.ToString());
}
finally
{
	LoggerService.Info("############ HuoBlog - ended at " + DateTime.Now);
	// ...	
	string logFileContent = File.ReadAllText(LoggerService.GetLogFilePath());
	// ...	
}

C:\Workspaces\MS_Visual_Studio_Projects\…\bin\Debug\output\HuoBlog_20171120165730.log.

That’s all!!

Huseyin

Hi,

Here, an example to get the source folder path of CSharp class via a static method and the package System.Runtime.CompilerServices. In fact, we solicit the compiler in order to get some informations about caller (caller line number, caller method, caller file path): https://msdn.microsoft.com/fr-fr/library/system.runtime.compilerservices.callermembernameattribute(v=vs.110).aspx.

using System.IO;
using System.Runtime.CompilerServices;

namespace HuoBlog
{
    public class ModelUtility
    {
        public static string getProjectPath([CallerMemberName] string memberName = "",
                [CallerFilePath] string sourceFilePath = "",
                [CallerLineNumber] int sourceLineNumber = 0)
        {
            // new System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName();
            string currentClassPath = getInternalPath();
            string currentProjectPath = Path.GetDirectoryName(currentClassPath);
            return currentProjectPath;
        }


        private static string getInternalPath([CallerMemberName] string memberName = "",
                [CallerFilePath] string sourceFilePath = "",
                [CallerLineNumber] int sourceLineNumber = 0)
        {
            return sourceFilePath;
        }
    }
}

 
…in the caller method, for example a simple Program.cs, some parameters Callerxxxx are set by compiler:

//...
string currentModelProjectPath = ModelUtility.getProjectPath();
//...
//...
// [CallerMemberName] string memberName = "Main"
// [CallerFilePath] string sourceFilePath = "C:\\Workspaces\\MS_Visual_Studio_Projects\\...\\Program.cs"
// [CallerLineNumber] int sourceLineNumber = 38

        public static string getProjectPath([CallerMemberName] string memberName = "",
                [CallerFilePath] string sourceFilePath = "",
                [CallerLineNumber] int sourceLineNumber = 0)
        {
                //...
        }
//...
//...
// [CallerMemberName] string memberName = "getProjectPath"
// [CallerFilePath] string sourceFilePath = "C:\\Workspaces\\MS_Visual_Studio_Projects\\...\\ModelUtility.cs"
// [CallerLineNumber] int sourceLineNumber = 13

        private static string getInternalPath([CallerMemberName] string memberName = "",
                [CallerFilePath] string sourceFilePath = "",
                [CallerLineNumber] int sourceLineNumber = 0)
        {
                //...
        }
//...

That’s all!!!!

Huseyin OZVEREN

Hi,

A post with concrete examples concerning the generation of Types/POJO from a XSD file, the serialization of these objects/POJO to XML and finally the validation of XML with XSD.

Generate Custom Types from XSD file

  • XSD file myXsdFile.xsd:
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                targetNamespace="urn:books"
                xmlns:bks="urn:books">
    
      <xsd:element name="books" type="bks:BooksForm"/>
    
      <xsd:complexType name="BooksForm">
        <xsd:sequence>
          <xsd:element name="book"
                      type="bks:BookForm"
                      minOccurs="0"
                      maxOccurs="unbounded"/>
        </xsd:sequence>
      </xsd:complexType>
    
      <xsd:complexType name="BookForm">
        <xsd:sequence>
          <xsd:element name="author"   type="xsd:string"/>
          <xsd:element name="title"    type="xsd:string"/>
          <xsd:element name="genre"    type="xsd:string"/>
          <xsd:element name="price"    type="xsd:float" />
          <xsd:element name="pub_date" type="xsd:date" />
          <xsd:element name="review"   type="xsd:string"/>
        </xsd:sequence>
        <xsd:attribute name="id"   type="xsd:string"/>
      </xsd:complexType>
    </xsd:schema>
    

     

  • CSharp sources and types generator:
            /// <summary>
            /// Custom Types Generator from XSD file
            /// </summary>
            /// <param name="xsdFile"></param>
            /// <param name="outputFile"></param>
            private static bool generateCSharpFile(string xsdFile, string outputFile)
            {
                bool result = true;
                try
                {
                    var stream = new MemoryStream(File.ReadAllBytes(xsdFile));
    
                    var schema = XmlSchema.Read(XmlReader.Create(stream), null);
                    var schemas = new XmlSchemas();
                    schemas.Add(schema);
    
                    var ns = new CodeNamespace { Name = "books" };
                    ns.Imports.Add(new CodeNamespaceImport("System"));
                    ns.Imports.Add(new CodeNamespaceImport("System.Collections.Generic"));
    
                    var exporter = new XmlCodeExporter(ns);
                    var importer = new XmlSchemaImporter(schemas);
    
                    foreach (XmlSchemaElement element in schema.Elements.Values)
                    {
                        var mapping = importer.ImportTypeMapping(element.QualifiedName);
                        exporter.ExportTypeMapping(mapping);
                    }
    
                    // Transform CodeDOM as required, adding new attributes, methods, modifying
                    // inheritance hierarchy, whatever.
                    var provider = new CSharpCodeProvider();
    
                    using (var writer = new StreamWriter(outputFile, false))
                    {
                        // Creates a new CodeGeneratorOptions.
                        CodeGeneratorOptions genOptions = new CodeGeneratorOptions();
    
                        // Sets a value indicating that the code generator should insert blank lines between type members.
                        genOptions.BlankLinesBetweenMembers = true;
    
                        // Sets the style of bracing format to use: either "Block" to start a
                        // bracing block on the same line as the declaration of its container, or 
                        // "C" to start the bracing for the block on the following line.
                        genOptions.BracingStyle = "C";
    
                        // Sets a value indicating that the code generator should not append an else, 
                        // catch or finally block, including brackets, at the closing line of a preceeding if or try block.
                        genOptions.ElseOnClosing = false;
    
                        // Sets the string to indent each line with.
                        genOptions.IndentString = "    ";
    
                        // Uses the CodeGeneratorOptions indexer property to set an
                        // example object to the type's string-keyed ListDictionary.
                        // Custom ICodeGenerator implementations can use objects 
                        // in this dictionary to customize process behavior.
                        genOptions["CustomGeneratorOptionStringExampleID"] = "BuildFlags: /A /B /C /D /E";
    
                        provider.GenerateCodeFromNamespace(ns, writer, genOptions);
                    }
                }
                catch (Exception ex)
                {
                    Console.Write(ex.ToString());
                    result = false;
                }
    
                return result;
            }
    
    

    //….

                string xsdFile = "C:\\Workspaces\\MS_Visual_Studio_Projects\\TestApps\\TestXmlXsd1\\myXsdFile.xsd";
                string outputFile = "C:\\Workspaces\\MS_Visual_Studio_Projects\\TestApps\\TestXmlXsd1\\generated\\MyCustomTypes.cs";
    
                generateCSharpFile(xsdFile, outputFile);
    

     
     

  • After execution, a CSharp file MyCustomTypes.cs containing all types of XSD file is generated:
    namespace books
    {
        using System;
        using System.Collections.Generic;
        
        
        /// <remarks/>
        [System.CodeDom.Compiler.GeneratedCodeAttribute("TestXmlXsd1", "1.0.0.0")]
        [System.SerializableAttribute()]
        [System.Diagnostics.DebuggerStepThroughAttribute()]
        [System.ComponentModel.DesignerCategoryAttribute("code")]
        [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:books")]
        [System.Xml.Serialization.XmlRootAttribute("books", Namespace="urn:books", IsNullable=false)]
        public partial class BooksForm
        {
            
            private BookForm[] bookField;
            
            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute("book", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
            public BookForm[] book
            {
                get
                {
                    return this.bookField;
                }
                set
                {
                    this.bookField = value;
                }
            }
        }
        
        /// <remarks/>
        [System.CodeDom.Compiler.GeneratedCodeAttribute("TestXmlXsd1", "1.0.0.0")]
        [System.SerializableAttribute()]
        [System.Diagnostics.DebuggerStepThroughAttribute()]
        [System.ComponentModel.DesignerCategoryAttribute("code")]
        [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:books")]
        public partial class BookForm
        {
            
            private string authorField;
            
            private string titleField;
            
            private string genreField;
            
            private float priceField;
            
            private System.DateTime pub_dateField;
            
            private string reviewField;
            
            private string idField;
            
            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
            public string author
            {
                get
                {
                    return this.authorField;
                }
                set
                {
                    this.authorField = value;
                }
            }
            
            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
            public string title
            {
                get
                {
                    return this.titleField;
                }
                set
                {
                    this.titleField = value;
                }
            }
            
            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
            public string genre
            {
                get
                {
                    return this.genreField;
                }
                set
                {
                    this.genreField = value;
                }
            }
            
            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
            public float price
            {
                get
                {
                    return this.priceField;
                }
                set
                {
                    this.priceField = value;
                }
            }
            
            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, DataType="date")]
            public System.DateTime pub_date
            {
                get
                {
                    return this.pub_dateField;
                }
                set
                {
                    this.pub_dateField = value;
                }
            }
            
            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
            public string review
            {
                get
                {
                    return this.reviewField;
                }
                set
                {
                    this.reviewField = value;
                }
            }
            
            /// <remarks/>
            [System.Xml.Serialization.XmlAttributeAttribute()]
            public string id
            {
                get
                {
                    return this.idField;
                }
                set
                {
                    this.idField = value;
                }
            }
        }
    }
    
    

 
 
 

Serialization of objects to XML

  • Instantiation of POJO objects and use of them in order to generate XML file myXmlFile.xml:
            /// <summary>
            /// Generate XML file for POJO annotated (System.Xml)
            /// </summary>
            /// <param name="model"></param>
            /// <param name="xmlFile"></param>
            private static bool generateXML(object model, string xmlFile)
            {
                bool result = true;
                try
                {
                    // Build POJO
                    var serializer = new XmlSerializer(model.GetType());
    
                    using (StreamWriter writer = new StreamWriter(xmlFile, true, new UTF8Encoding(false)))
                    {
                        serializer.Serialize(writer, model);
                    }
                }
                catch (XmlSchemaValidationException ex)
                {
                    Console.Write(ex.ToString());
                    result = false;
                }
    
                return result;
            }
    

    //….

                string xmlGeneratedFile = "C:\\Workspaces\\MS_Visual_Studio_Projects\\TestApps\\TestXmlXsd1\\myXmlFile.xml";
                BooksForm booksForm = new BooksForm();
                {
                    List<BookForm> booksList = new List<BookForm>();
                    {
                        BookForm book = new BookForm();
                        book.id = "bk001";
                        book.author = "Writer";
                        book.title = "The First Book";
                        book.genre = "Fiction";
                        book.price = 44.95F;
                        book.pub_date = DateTime.ParseExact("2000-10-01", "yyyy-MM-dd", CultureInfo.InvariantCulture);
                        book.review = "An amazing story of nothing.";
                        booksList.Add(book);
                    }
                    {
                        BookForm book = new BookForm();
                        book.id = "bk002";
                        book.author = "Poet";
                        book.title = "The Poet's First Poem";
                        book.genre = "Poem";
                        book.price = 24.95F;
                        book.review = "Least poetic poems.";
                        booksList.Add(book);
                    }
                    booksForm.book = booksList.ToArray();
                }
    
    
                generateXML(booksForm, xmlGeneratedFile);
    

     
     

  • The generated XML file myXmlFile.xml would be:
    <?xml version="1.0" encoding="utf-8"?>
    <books xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:books">
      <book id="bk001" xmlns="">
        <author>Writer</author>
        <title>The First Book</title>
        <genre>Fiction</genre>
        <price>44.95</price>
        <pub_date>2000-10-01</pub_date>
        <review>An amazing story of nothing.</review>
      </book>
      <book id="bk002" xmlns="">
        <author>Poet</author>
        <title>The Poet's First Poem</title>
        <genre>Poem</genre>
        <price>24.95</price>
        <pub_date>0001-01-01</pub_date>
        <review>Least poetic poems.</review>
      </book>
    </books>
    

 
 
 

Validation of XML with XSD file

  • Validation of generated XML myXmlFile.xml with original XSD file myXsdFile.xml:
            /// <summary>
            /// Validate XML file with XSD file
            /// </summary>
            /// <param name="xmlFilePath"></param>
            /// <param name="xsdFilePath"></param>
            /// <param name="namespaceName"></param>
            /// <returns></returns>
            private static bool IsValidXml(string xmlFilePath, string xsdFilePath, string namespaceName)
            {
                var xdoc = XDocument.Load(xmlFilePath);
                var schemas = new XmlSchemaSet();
                schemas.Add(namespaceName, xsdFilePath);
    
                bool result = true;
                try
                {
                    xdoc.Validate(schemas, (sender, e) =>
                    {
                        Console.Write("Error:" + e.Message);
                        result = false;
                    });
                }
                catch (XmlSchemaValidationException ex)
                {
                    Console.Write(ex.ToString());
                    result = false;
                }
                return result;
            }
    

    //….

                string xsdFile = "C:\\Workspaces\\MS_Visual_Studio_Projects\\TestApps\\TestXmlXsd1\\myXsdFile.xsd";
                string xmlGeneratedFile = "C:\\Workspaces\\MS_Visual_Studio_Projects\\TestApps\\TestXmlXsd1\\myXmlFile.xml";
    
                IsValidXml(xmlGeneratedFile, xsdFile, "urn:books");
    

 

Note: Below the import / using needed to these methods:

using Microsoft.CSharp;
using System;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.IO;
using System.Xml;
using System.Xml.Linq;
using System.Xml.Schema;
using System.Xml.Serialization;
using System.Text;
using books;
using System.Collections.Generic;
using System.Globalization;

 

Best regards,

Huseyin OZVEREN

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

Page 1 of 51:1 2 3 4 »Last »
bottom-img
Copyright ® 2012 Huseyin Ozveren. No reproduction, even partial, can be used from this site and all its contents including text, documents, images, etc.. without the express permission of the author.