top-image

OLDER ARTICLES

Hi,

Just a post concerning the generation of JAVA webservice client for CXF and AXIS web services via an ANT script.

More information on sites on proxies creation:
http://cxf.apache.org/docs/wsdl-to-java.html
http://axis.apache.org/axis/java/ant/axis-wsdl2java.html

  • First, download the CXF and AXIS SDK librairies:
    C:\SDK\axis2-1.7.7
    C:\SDK\cfx-3.0.3
    C:\SDK\jdk1.7.0_17
     
  • Create a specific folder for the generated proxies sources (for example, WSProxyGenerator\src_generated)
     
  • References all needed libairies (JAR) in your project (for example lib/*.jar)
     
  • Create a properties file for the ANT script build.properties:
    cxf.home=C\:/SDK/cfx-3.0.3
    axis.home=C\:/SDK/axis2-1.7.7
    

     

  • Create a ANT script file build.xml containing the ANT targets create_proxy depending of init_proxy, create_proxy_cxf and create_proxy_axis targets:
    <?xml version="1.0" encoding="UTF-8"?>
    <project name="ProxiesGenerator" default="create_proxy" basedir=".">
    	<property file="build.properties" />
    
    	<target name="create_proxy" depends="init_proxy,create_proxy_cxf,create_proxy_axis" >
    	</target>
    	
    	<target name="init_proxy">
    		<fail unless="cxf.home" message="Apache CXF home (cxf.home) not set" />
    		<path id="cxf.classpath">
    			<fileset dir="${cxf.home}/lib">
    				<include name="*.jar" />
    			</fileset>
    		</path>
    
    		<fail unless="axis.home" message="Apache AXIS home (axis.home) not set" />
    
    		<path id="axis.classpath">
    			<fileset dir="${axis.home}/lib">
    				<include name="*.jar" />
    			</fileset>
    			<fileset dir="${basedir}/lib">
    				<include name="*.jar" />
    			</fileset>
    		</path>
    
    		<delete includeemptydirs="true">
    			<fileset dir="${basedir}/src_generated">
    				<include name="**/*.java" />
    			</fileset>
    		</delete>
    		<mkdir dir="${basedir}/src_generated" />
    	</target>
    
    	<target name="create_proxy_cxf">
    	</target>
    
    	<target name="create_proxy_axis">
    	</target>
    </project>
    

     

 

CXF proxy generation

  • Create a file containing the URLs of CXF web services wsdllist_cxf.txt:
    https://myserver1.java.lu/services/core/MyObjectService?wsdl
    https://myserver1.java.lu/services/core/MyObjectService2?wsdl
    

     

  • Create a file for the binding-name simple-binding.xjb
    <?xml version="1.0" encoding="UTF-8"?>
    <jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
    	jaxb:version="2.0" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
    	jaxb:extensionBindingPrefixes="xjc">
    	<jaxb:globalBindings>
    		<xjc:simple />
    		<xjc:serializable uid="1397139757393" />
    	</jaxb:globalBindings>
    </jaxb:bindings>
    

     

  • Create in the build.xml file the CXF target:
    	<target name="create_proxy_cxf">
    		<java classname="org.apache.cxf.tools.wsdlto.WSDLToJava" fork="true">
    			<arg value="-autoNameResolution" />
    			<arg value="-verbose" />
    			<arg value="-fe" />
    			<arg value="jaxws21" />
    			<arg value="-encoding" />
    			<arg value="Cp1252" />
    			<arg value="-d" />
    			<arg value="${basedir}/src_generated" />
    			<arg value="-b" />
    			<arg value="simple-binding.xjb" />
    			<arg value="-wsdlList" />
    			<arg value="wsdllist_cxf.txt" />
    			<classpath>
    				<path refid="cxf.classpath" />
    			</classpath>
    		</java>
    	</target>
    

     

 

AXIS proxy generation

  • Create in the build.xml file the CXF target:
    	<target name="create_proxy_axis">
    		<java classname="org.apache.axis.wsdl.WSDL2Java" fork="true">
    			<arg value="--verbose" />
    			<arg value="--Debug" />
    			<arg value="--output" />
    			<arg value="${basedir}/src_generated" />
    			<arg value="-u" />
    			<arg value="https://myserver2.java.lu/MyWebServices/services/MyWebService?wsdl" />
    			<classpath>
    				<path refid="axis.classpath" />
    			</classpath>
    		</java>
    	</target>
    

     

 

build.xml

<?xml version="1.0" encoding="UTF-8"?>
<project name="ProxiesGenerator" default="create_proxy" basedir=".">
	<property file="build.properties" />

	<target name="create_proxy" depends="init_proxy,create_proxy_cxf,create_proxy_axis" >
	</target>
	
	<target name="init_proxy">
		<fail unless="cxf.home" message="Apache CXF home (cxf.home) not set" />
		<path id="cxf.classpath">
			<fileset dir="${cxf.home}/lib">
				<include name="*.jar" />
			</fileset>
		</path>

		<fail unless="axis.home" message="Apache AXIS home (axis.home) not set" />

		<path id="axis.classpath">
			<fileset dir="${axis.home}/lib">
				<include name="*.jar" />
			</fileset>
			<fileset dir="${basedir}/lib">
				<include name="*.jar" />
			</fileset>
		</path>

		<delete includeemptydirs="true">
			<fileset dir="${basedir}/src_generated">
				<include name="**/*.java" />
			</fileset>
		</delete>
		<mkdir dir="${basedir}/src_generated" />
	</target>

	<target name="create_proxy_cxf">
		<java classname="org.apache.cxf.tools.wsdlto.WSDLToJava" fork="true">
			<arg value="-autoNameResolution" />
			<arg value="-verbose" />
			<arg value="-fe" />
			<arg value="jaxws21" />
			<arg value="-encoding" />
			<arg value="Cp1252" />
			<arg value="-d" />
			<arg value="${basedir}/src_generated" />
			<arg value="-b" />
			<arg value="simple-binding.xjb" />
			<arg value="-wsdlList" />
			<arg value="wsdllist_cxf.txt" />
			<classpath>
				<path refid="cxf.classpath" />
			</classpath>
		</java>
	</target>

	<target name="create_proxy_axis">
		<java classname="org.apache.axis.wsdl.WSDL2Java" fork="true">
			<arg value="--verbose" />
			<arg value="--Debug" />
			<arg value="--output" />
			<arg value="${basedir}/src_generated" />
			<arg value="-u" />
			<arg value="https://myserver2.java.lu/MyWebServices/services/MyWebService?wsdl" />
			<classpath>
				<path refid="axis.classpath" />
			</classpath>
		</java>
	</target>
</project>

 
Execute the ANT script build.xml, the proxies are generated in the src_generated folder:

Buildfile: C:\Workspaces\WSProxyGenerator\build.xml
init_proxy:
create_proxy_cxf:
      Loading FrontEnd jaxws21 ...
      Loading DataBinding jaxb ...
      wsdl2java -autoNameResolution -verbose -fe jaxws21 -encoding Cp1252 -d C:\Workspaces\WSProxyGenerator/src_generated -b simple-binding.xjb -wsdlList wsdllist_cxf.txt
      wsdl2java - Apache CXF 3.0.3
create_proxy_axis:
      Parsing XML file:  https://myserver2.java.lu/MyWebServices/services/MyWebService?wsdl
      Symbol Table
      -----------------------
      org.apache.axis.wsdl.symbolTable.DefinedType
...
      -----------------------
      Generating C:\Workspaces\WSProxyGenerator/src_generated\com\myjava\lu\myservice\webservice\services\myserviceWebService.java
      Generating C:\Workspaces\WSProxyGenerator/src_generated\com\myjava\lu\myservice\webservice\services\myserviceWebServiceSoapBindingStub.java
      Generating C:\Workspaces\WSProxyGenerator/src_generated\com\myjava\lu\myservice\webservice\services\myserviceWebServiceService.java
      Generating C:\Workspaces\WSProxyGenerator/src_generated\com\myjava\lu\myservice\webservice\services\myserviceWebServiceServiceLocator.java
create_proxy:
BUILD SUCCESSFUL
Total time: 11 seconds

 

Best regards,

Huseyin

Hello,

Just a mini post concerning the persistence/saving of MAIL document with external/internal attachments. Here, 2 solutions for the relation between MAIL document and its attachments in Documentum.

For external attachment of MAIL document, a simple solution is the creation of dm_document/dmr_content for each external attachment and the creation of dm_relation with specific type (relation_name = ‘mail_attachment’) for the link between attachments and MAIL document:
o parent_id = r_object_id of MAIL document (dm_document -> dmr_content)
o child_id = r_object_id of attachment document (dm_document -> dmr_content)
 
DQL:

select relation_name, parent_id, child_id from dm_relation where relation_name = 'mail_attachment' and parent_id = '090xxxxxxxxcd' ;

 
 

For the internal attachment inside MAIL document (the system generates automaticaly a SHA-1 for each attachment which is stored directly in the MAIL content)
 
Exemple of MAIL document/content:

	"<item name="$FILE" seal="true" sign="true" summary="true"><object><file compression="none" encoding="unknown" flags="storedindoc" hosttype="msdos" name="1540453.htm" size="7759">
	<created><datetime>20141104T065226,37-05</datetime></created>
	<modified><datetime>20141104T065226,37-05</datetime></modified>
	<filedata>1c195c............6e83db</filedata></file></object></item>"

 
So, a solution is the creation of dm_document/dmr_content for each external attachment and the use of the storing of this SHA-1 value in the dmr_content repeating attributes content_attr_name and content_attr_value instead of the dm_relation objects.
 
The DFC javadoc contains several methods for these dmr_content repeating attributes:

o String getStringContentAttr(String name, String formatName, int page, String pageModifier) throws DfException = Return a string content attribute.
Parameters:
– name : the name of the attribute.
– formatName :the name for the content objects format.
– page : the content page.
– pageModifier : the content object’s page modifier.

o void setStringContentAttribute(String name, String value, String formatName, int page, String pageModifier) throws DfException = Set a String content attribute.
Parameters:
– name : the name of the attribute.
– value : the value of the attribute.
– formatName : the name for the content objects format.
– page : the content page.
– pageModifier : the content object’s page modifier.

 

Example:



dm_document
  r_object_id                : 090xxxxxxxxxxeef
  i_contents_id              : 060xxxxxxxxxxa84
  object_name                : binary.gif


dmr_content
  r_object_id                : 060xxxxxxxxxxa84
  parent_id               	[0]: 090xxxxxxxxxxeef
  content_attr_name       	[0]: SHA-1
				[1]: Width
				[2]: Height
				[3]: Format
				[4]: Color Mode
				[5]: Compression
				[6]: Jpeg Quality
				[7]: Gif Interleave
				[8]: Color Components
				[9]: Sample Bands
				[10]: Sample Depth
				[11]: Colorspace
  content_attr_value     	[0]: e97c9xxxxxxxxxxxxxxxxxxf36bc
				[1]: 
				[2]: 
				[3]: GIF
				[4]: Indexed
				[5]: LZW
				[6]: 
				[7]: false
				[8]: 
				[9]: 
				[10]: 
				[11]: RGB

  full_content_size          : 905

 

DQL:

select r_object_id, parent_id, content_attr_name, content_attr_value  from dmr_content where ANY (content_attr_name = 'SHA-1' and content_attr_value='1c195cxxxxxxxxxxxxxxxxxx83db' );
060xxxxxxxxx0ca	090xxxxxxxxbbe	SHA-1	1c195cxxxxxxxxxxxxxxxxxx83db

select r_object_id, r_page_cnt, r_content_size, a_content_type, i_contents_id from pwc_client_document where r_object_id ='090xxxxxxxxbbe';
090xxxxxxxxbbe	1	7759	html	060xxxxxxxxx0ca

 

Best regards,

Huseyin OZVEREN

Hi,

Juste a mini-post concerning the configuation of DATASOURCE on Documentum server.
The DATASOURCE (DS) are configurable:

 
Here, the example for the DS “java:/MY_ARCHIVE_DS” :

<?xml version='1.0' encoding='UTF-8'?>
<server xmlns="urn:jboss:domain:1.2">
    <profile>
       <subsystem xmlns="urn:jboss:domain:datasources:1.0">

            <datasources>

                <datasource jndi-name="java:/MY_ARCHIVE_DS" pool-name="MY_ARCHIVE_DS" enabled="true" use-java-context="true">
                    <connection-url>jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MYDBSERVER123)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=MYARCHIVE)))</connection-url>
                    <driver>oracle.jdbc</driver>
                    <pool>
                        <min-pool-size>5</min-pool-size>
                        <max-pool-size>100</max-pool-size>
                    </pool>
                    <security>
                        <user-name>MY_APP_USER</user-name>
                        <password>WD{HUO/dfdfdsfdsfh]-DUHi</password>
                    </security>
                    <validation>
                        <exception-sorter class-name="org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter"/>
                    </validation>
                </datasource>
	        <drivers>
                    <driver name="h2" module="com.h2database.h2">
                        <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
                    </driver>
                    <driver name="oracle.jdbc" module="oracle.jdbc">
                        <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
                    </driver>
                    <driver name="sqljdbc" module="com.microsoft.sqlserver">
                        <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
                    </driver>
                </drivers>
            </datasources>
        </subsystem>
    </profile>

    <interfaces>

    </interfaces>

    <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">

    </socket-binding-group>
</server>

 
 
The use of this DS in the JOB/JAVA code could be:

	private static final String DS = "MY_ARCHIVE_DS";
	private static final String JNDI_PREFIX[] = { "java:/", "java:", "jdbc/" };

	//...
		InitialContext ic = new InitialContext();
		for (int i = 0; i < JNDI_PREFIX.length && dataSource == null; i++) {
			try {
				dataSource = (DataSource) ic.lookup(JNDI_PREFIX[i] + DS);
			} catch (NamingException e) {
			}
		}
		if (dataSource == null) {
			throw new Exception("Unable to find datasource " + DS);
		}
	//...

	Connection connection = dataSource.getConnection();
	try {
		connection.setAutoCommit(false);

		PreparedStatement statement = connection.prepareStatement(MessageFormat.format(sql.toString(), StringUtils.upperCase(StringUtils.trimToEmpty(table)), year.format(coll.getTime("time_stamp").getDate())));

		//... Save the original data in a BLOB field in ARCHIVE database
		Blob blob = connection.createBlob();

		//...
		statement.executeUpdate();

		//...
		blob.free();

		//...
		statement.close();

		//...

	} finally {

		if(connection!=null){
	
			if (commit) {
				connection.commit();
				println("SqlConnection transaction commited !");
			} else {
				connection.rollback();
				println("SqlConnection transaction rollbacked !");
			}
			connection.close();
		}
	}

That’s all!!!

Huseyin OZVEREN

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

Page 3 of 54:« 1 2 3 4 5 6 »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.