SOA for the Masses

I just received an invitation to review a proposal for a book on SOA. The first question, as always is "do you think this book is necessary?" Well, not only yes, but hell yes. But, I digress.

SOA for the Masses

First, let’s understand what SOA is. In simple terms, SOA is two things:

  1. Boxing up a set of functions into a service (a complete piece of software that performs a narrowly focused set of functions). In general, you aim for something specific, like a security service, a zipcode lookup service, etc.
  2. Putting an interface to reach the service over the wire. In general, you will want this to be a standards based interface, like web services, but any interface you can agree on is still SOA.

Yes, I have just exposed the man behind the curtain. You are probably thinking it cannot be that simple, can it. Let me show you how simple it is.

Step 1: Create a web page

In this case, I am aiming for simplicity. Open Visual Studio 2005 and create a new web site. In the default.aspx page, add two textboxes, with a plus sign in between, a horizontal line and a label and button. The code will be something like this:

<asp:TextBox ID="TextBox1" runat="server" Width="67px"></asp:TextBox
<asp:TextBox ID="TextBox2" runat="server" Width="67px"></asp:TextBox><br
= <asp:Label ID="Label1" runat="server"></asp:Label><br
<asp:Button ID="Button1" runat="server" Text="Button"

Double click on the Button and add the followign coded method.


Protected Sub Button1_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Button1.Click
    Label1.Text = VBCalculator.Add(_
       Integer.Parse(TextBox1.Text), Integer.Parse(_
End Sub


protected void Button1_Click(object sender, EventArgs e)
    Label1.Text = CSharpCalculator.Add(

Now, you need to add the calculator class(es). In this case, we are simply adding two integers. Yeah, it is an overly simplistic solution, but it works.



Class VBCalculator
Public Shared Function Add(ByVal a As Integer, ByVal b As Integer) As Integer
Return a + b
End Function



class CSharpCalculator
public CSharpCalculator()
public static int Add(int a, int b)
return a + b;

Test the solution. Woo hoo, isn’t that fun.

Making the calc a service

Now, your XBox Live buddy pings you and says he needs an addition application. You say "d00d, don’t code it, I have 1", only in hackereze. To do this, add a web service page to your application and add the following method:


<WebMethod()> _

Public Function Add(ByVal a As Integer, ByVal b As Integer) As Integer
Return VBCalculator.Add(a, b)
End Function


public int Add(int a, int b)
return CSharpCalculator.Add(a, b);

You are now so SOA.


In this overly simplistic exercise, you moved from a simple web application to a SOA implementation. You can now have anyone in the world add using your service. NO, it is not real world, but imagine some real world possibilities.

What you need for SOA:

  1. Code that can work with a set message format for input and return a set message for output. In this example, the input was two integers and the output was a single integer. This is unusual for services, however, as you are generally dealing with a much larger set of data, at least in one direction. For example, you might want a zip code service that returns city, county, and state for a particular zip code.
  2. An interface to reach the code externally. In this case a web service. This could be remoting, however, or any other port listening code that can return a message. In the later two cases, you are getting more and more stuck. Remoting, currently at least, requires Microsoft clients and the port listening solution requires an agreed format between you and your partners.

The benefit of Remoting or proprietary code is speed, but the benefit is often very small. In general, I would aim for the web service implementation first and alter if you need the extra performance. In ASP.NET 2.0, web services run very fast and there is not much gain with Remoting in most instances. In addition, you can use UDDI as a name service and quickly add other machines that can service clients. Finally, switching to WCF is a simple matter of changing the UDDI pointers.

Until next time.




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: