Click here to Skip to main content
11,928,403 members (50,632 online)
Click here to Skip to main content
Add your own
alternative version


24 bookmarked

Simple Integration With SimpleInt

, 6 Oct 2006
Rate this:
Please Sign up or sign in to vote.
How to use the SimpleInt Framework to integrate applications.


Applications in the business world do not live in isolation, they have to cooperate and share information between themselves. In the ideal world applications can talk to each other without any problems and platform independence is commonplace. In the real world there are often silos of massive amounts of data, which are often redundant, sometimes very complex, hardly ever is it easily shared, and true platform independence is a fairy tale. It is in this world, the real world, that the hard work of integrating applications together takes place.

Enter, the Simple Integration Framework (a.k.a SimpleInt). SimpleInt is a new open source project on the CodePlex web site.

This is a simple demonstration of how to use SimpleInt to allow data to be shared from one system to another. The basic components of an integration package in the SimpleInt Framework consist of a listener, a parser, a transformer, and a sender. In this article we will walk through setting up each of these components to integrate two applications together.


SimpleInt is an integration framework in the very early stages of development. Currently there is an implementation of a simple and very configurable message broker in the framework. A good place to go for an overview of the message broker pattern is

Let’s Get Started

For simplicity’s sake the example we are going to work on in this article uses the file system as the transport medium from one application to another. Our first hypothetical application places output files in one file folder and our second hypothetical application reads files from an input folder.

The integration package that we are going to create will poll the first applications output folder for new files.The integration package will read those files in and apply an XSL transform to them and place the output in our second applications input folder.

Now, we will go ahead and create an xml file that will be our input file. Let us name it input.xml and it should read as follows:

<?xml version="1.0" encoding="utf-8"?>

Now, create an XSL transform named changIt.xslt that will change this xml document into another xml format.

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="">
  <xsl:output method="xml" encoding="UTF-8"/>
  <xsl:template match="/visit">
        <xsl:value-of select='date'/>
        <xsl:value-of select='doctor'/>
        <xsl:value-of select="patient"/>
        <xsl:value-of select="insurance"/>

Now that we know our input and have defined our output format, create a project. Since a great company like Northwinds is always expanding and looking for new opportunities let’s go ahead and get them into the Healthcare market since our input and output data deals with going to see the doctor.

  1. Open Visual Studio 2005 and create a new Winforms project named NorthwindsMedical.
  2. Add a reference to the SimpleInt.Framework.dll.
  3. Include our input file, input.xml, and the XSL transform changeIt.xslt in the project. Flag the changeIt.xslt file to always be copied to the output directory.
  4. Add a button to Form1 and change its text to “Start”.
  5. Add another button, change its text to “Stop”, and set its enabled property to false.

Now your form should look like this:

Sample image

Now let us add some code to the form.

SimpleInt.Framework.ServiceManager _sm; 

public Form1() 
     _sm = new SimpleInt.Framework.ServiceManager(); 

We added a SimpleInt ServiceManager field to the form class and initialized it in the form constructor. All the code we will write to manipulate the SimpleInt framework will be against this class, and there’s not a lot of code that we will write.

Now let’s start the service manager in the Start button click event.

private void button1_Click(object sender, EventArgs e)
    button1.Enabled = false;
    button2.Enabled = true;

And stop the service manager in the Stop button click event.

private void button2_Click(object sender, EventArgs e)
    button1.Enabled = true;
    button2.Enabled = false;

Believe it or not, we are done coding. The rest of the article we will be setting up and configuring the service manager. We will use some of the simple implementations of parsers, listeners, translators, and senders that are already built into the SimpleInt framework. You could easily extend the framework by implementing your own parsers, senders, translators, or listeners and, in fact, that is exactly what the creators of the framework envision many developers doing. But this is a simple demonstration so we will stick to the basics.

Configuring the Service Manager

Add an App.config file to the NorthwindsMedical project. In that App.config add the following configSections:

   <sectionGroup name="IntegrationConfig">
      <section name="context" 
         type="Spring.Context.Support.ContextHandler, Spring.Core"/>
      <section name="objects" 
         type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />
   <section name="log4net" 
       type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
   <section name="nhibernate" 
       type="System.Configuration.NameValueSectionHandler, System, 
             PublicKeyToken=b77a5c561934e089" />

This declares the IntegrationConfig section in which we will configure the SimpleInt service manager, the nhibernate section in which we will configure our database connection, and the log4net section which we will not use but NHibernate and Spring.NET need.

Now we need to setup a database. (Note: In this example we will use a MSSQL Server as our data store but NHibernate allows for pretty good database independence. MySQL, Oracle, and others are supported by NHibernate out of the box and the SimpleInt framework does not care where its data is stored.) Run the CreateMessagesTable.sql script against the MSSQL Server database you want to use for this example. With the database now set we can add the following NHibernate configuration info to the App.config file:

    <add key="hibernate.connection.provider" 
            value="NHibernate.Connection.DriverConnectionProvider" />
    <add key="hibernate.dialect" 
            value="NHibernate.Dialect.MsSql2000Dialect" />
    <add key="hibernate.connection.driver_class" 
            value="NHibernate.Driver.SqlClientDriver" />
    <add key="hibernate.connection.connection_string" 
            value="Server=(local);initial catalog=YourDB;
                   user id=someuser;password=somepassword" />

Now change the hibernate.connection.connection_string value to the connection string for the database you ran the CreateMessagesTable.sql script against.

Now add the following to the App.config file:

        <!--<span class="code-comment"> using embedded assembly configuration file --></span>
        <!--<span class="code-comment"> <resource 
           uri="assembly://MyAssembly/My.Namespace.Xyzzy/AppContext.xml"/> --></span>

        <!--<span class="code-comment"> using section in App.config --></span>
        <resource uri="config://IntegrationConfig/objects"/>

      <objects xmlns="" 


This is the section where most of the magic is going to happen. We will come back to this soon.

Add the following to the App.config to keep log4net happy:

      <logger name="testApp.Logging">
        <level value="DEBUG"/>

Now back to the meat of the configuration. Inside the objects tags in the IntegrationConfig section we are going to wire up an instance of the SimpleInt.Framework.Processor class. Add the following xml inside the objects tags:

<!--<span class="code-comment">Processor--></span>
<object name="IntegrationProcessor"
        type="SimpleInt.Framework.Processor, SimpleInt.Framework"

        <property name="DataStore">
            <ref object="IntegrationDataStore"/>

        <property name="IntegrationPackages">
                <ref object="TestPackage"/>


It is very important that the name of this object be correct (IntegrationProcessor) because it is the name that the SimpleInt service manager will be looking for. Notice that we have configured this class as a singleton, so only one instance of this object will be created for the life of the service manager. Also, we have set the DataStore and IntegrationPackages properties. The DataStore property references an object named IntegrationDataStore, which we will configure later. The IntegrationPackages property is a collection, so any object that needs to be added to that collection goes in between the list tags.

Now let’s set up the TestPackage integration package and all of its supporting objects. Add the following xml inside the objects tags:

<!--<span class="code-comment">TestPackage--></span>
<object name="TestPackage"
      type="SimpleInt.Framework.IntegrationPackage, SimpleInt.Framework"

    <property name="Name">

    <property name="Listener">
        <ref object="TestListener"/>

    <property name="Parser">
        <ref object="TestParser"/>

    <property name="Translator">
        <ref object="TestTranslator"/>

    <property name="Sender">
        <ref object="TestSender"/>


<object name="TestListener"
          FilePollingListener, SimpleInt.Framework"
    <property name="FolderPath">

    <property name="ArchiveFolder">

<object name="TestParser"               
          PassThroughParser, SimpleInt.Framework"

<object name="TestTranslator" 
          XsltTranslator, SimpleInt.Framework"
    <property name="XsltFile">

<object name="TestSender"                
    <property name="Folder">
    <property name="FileType">

Notice we are using a PassThroughParser (TestParser) and we are using the XsltTranslator, which we have configured to use the changeIt.xslt file we created earlier. We are also using a FilePollingListener and a FileSender.

So based on the configuration above, the listener will grab any file placed in the Input folder, read it into the system as a new message, and move it to the Archive folder. The parser will just pass the message on to the translator as is. The translator will apply the changeIt.xslt transform to the message and the sender will write the translated message to the Output folder as a new file with a “.out” file extension.

Now we need to add the folders mentioned above in the right place. In your project output folder (ususally bin\Debug) create three folders: Input, Archive, and Output.

Sweet… Not too bad for 3 lines of SimpleInt specific code and some xml.

Now let’s finish up and configure the data store. Add the following xml inside the objects tags:

<!--<span class="code-comment">Database setup--></span>
<object name="cfg"
           Hibernate.NHibernateConfiguration, SimpleInt.Framework" 

    <property name="Assemblies">

<object name="sessionFactory" 
           factory-method="CreateSessionFactory" factory-object="cfg"/>

<!--<span class="code-comment">DataStore--></span>
<object name="IntegrationDataStore" 
            SimpleDBDataStore, SimpleInt.Framework"
    <property name="NHibernateSessionFactory">
        <ref object="sessionFactory"/>

Here we are just configuring and initializing the SimpleDBDataStore, which uses NHibernate to handle database calls to store and log the messages that are processed.

Now we are ready to run it.

Running the Demo

Now hit F5 to build the project and run it. When Form1 pops up, push start. After you click the “started” message box, put a copy of the input.xml file into the Input folder. That file should disappear from that folder in a second or so. After it has disappeared, verify that a copy of the input.xml file is now in the Archive folder and that a new file is in the Output folder. The contents of that file should be the contents of the input file translated into the format that our second application needs, and it should look like this:

<?xml version="1.0" encoding="utf-16"?>

Again, not too bad for 3 lines of SimpleInt specific code and some xml, is it?

Points of Interest

The ability to wire objects together in a config file and then have an application run based on that wiring is pretty cool. Spring.Net has some great dependency injection and inversion of control abilities. Also SimpleInt has plans to add a message bus set of features as the framework grows.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.151126.1 | Last Updated 6 Oct 2006
Article Copyright 2006 by pconverse
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid