Thursday, July 29, 2010

SOA Tenets and Principles

Below are the rules to creating services, follow the rules and you will have a painless journey, and as you will see all the good things that the development community have discovered over the last eighty years all all baked in, any developer worth their salt will recognize this a merely the next evolution in development, the one that is allowing us to create applications that live in a distributed environment.

SOA Tenets and Principles

Friday, July 23, 2010

Building Service Orientated Architecture

Here is an article I wrote to follow up the soa for executives article. This article moves a little deeper into defining what a SOA is and the differeences between Service Orientated Architecture and Service Orientated Application Design

Monday, July 19, 2010

SOA explained for for business people

Here is a article i wrote that covers what SOA is without technical jargon, it is aimed at helping business executive understand what the propeller heads are taking about

Saturday, July 17, 2010

Well done South Africa!

Well done South Africa in making such a success of the 2010 World Cup in South Africa, the eyes of the world have been opened to the potential of our country as a vacation destination.

Here is a great article with some cool pictures about why now is the best time to plan a visit.

Tuesday, June 1, 2010

Create WCF Proxies on the Fly

Here is one of the more useful classes i have used, it allows you to spin up a WCF proxy, and invoke any method from just the interface and a line of code.

Usage:
ChannelFactoryHelper.InvokeServiceMethod<IRoutingTopics>(
m => m.Method1(instruction, data), "Portal");


Class:

    public static class ChannelFactoryHelper
{
/// <summary>
/// Creates the channel.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
private static T CreateChannel<T>(string endpoint) where T : class
{
string endpointConfigName = endpoint;
try
{
ChannelFactory<T> factory = new ChannelFactory<T>(endpointConfigName);
return factory.CreateChannel();
}
catch (Exception ex)
{
throw new Exception(string.Format("Could not create proxy for endpoint configuration with name '{0}'", endpointConfigName), ex);
}
}

/// <summary>
/// Invokes the service method.
/// </summary>
/// <typeparam name="I"></typeparam>
/// <typeparam name="R"></typeparam>
/// <param name="source">The source.</param>
/// <returns></returns>
public static R InvokeServiceMethod<I, R>(Func<I, R> source, string endpointConfigName)
where I : class
{
R returnValue;
returnValue = InvokeServiceMethod<I, R>(source, CreateChannel<I>(endpointConfigName));
return returnValue;
}

/// <summary>
/// Invokes the service method.
/// </summary>
/// <typeparam name="I"></typeparam>
/// <param name="source">The source.</param>
public static void InvokeServiceMethod<I>(Action<I> source, string endpointConfigName)
where I : class
{
InvokeServiceMethod<I>(source, CreateChannel<I>(endpointConfigName));
}

/// <summary>
/// Invokes the service method.
/// </summary>
/// <typeparam name="I">Service Contract Interface.</typeparam>
/// <param name="source">The source.</param>
/// <param name="proxy">The proxy.</param>
private static void InvokeServiceMethod<I>(Action<I> source, I proxy) where I : class
{
try
{
// Call the service method
source.Invoke(proxy);
// Make sure to close the proxy
(proxy as IClientChannel).Close();
}
catch
{
if (proxy != null)
{
// If the proxy cannot close normally or an exception occurred, abort the proxy call
(proxy as IClientChannel).Abort();
}
throw;
}
}

/// <summary>
/// Invokes the service method.
/// </summary>
/// <typeparam name="I">Service Contract Interface.</typeparam>
/// <typeparam name="R">Return Type.</typeparam>
/// <param name="source">The source.</param>
/// <param name="proxy">The proxy.</param>
/// <returns></returns>
private static R InvokeServiceMethod<I, R>(Func<I, R> source, I proxy)
where I : class
{
R returnValue;
try
{
// Call the service method
returnValue = source.Invoke(proxy);
// Make sure to close the proxy
(proxy as IClientChannel).Close();
}
catch
{
if (proxy != null)
{
// If the proxy cannot close normally or an exception occurred, abort the proxy call
(proxy as IClientChannel).Abort();
}
throw;
}
return returnValue;
}
}