Web Service 1-2-3

Have you ever done a software inventory in your organization?  You will be surprised to find out how many calculation engines or financial models that your organization has.  And if you do a sample audit, you will realize that a lot of business logic are very similar within these engines / models.  It would be great if we can have a central calculation engine that is shared by all our systems / model.  We will have consistent results, reduced risks and effectively increase our model efficiency.

So what are the problems? One of the most common challenges is that our systems, i.e. pricing, valuation, asset liability management are in an heterogeneous environment; i.e. they can be in mainframe, UNIX, Windows, web or even tablet.  They just don’t talk to each others!  Fortunately, a lot of IT leaders recognized the problem and developed an interoperable machine to machine interaction protocol that allows systems to interact in a standard prescribed by W3C (World Wide Web Consortium).  This standard, Web Services was originally proposed by Microsoft in 1999 and quickly gained supports from IBM and other major software vendors, e.g. Oracle, HP and Sun.  During the last twelve years, web service has evolved significantly and become the backbone of service-oriented architecture.  Can we use Web Service to develop a central calculation library that can be used in Excel, desktop, server, web and even smartphone / tablet?  Let me demonstrate how easy Web Service can be implemented, as simple as 1-2-3.

  1. Install Visual Studio 2010
  2. Download and install WCF REST Service Template 40 (http://visualstudiogallery.msdn.microsoft.com/fbc7e5c1-a0d2-41bd-9d7b-e54c845394cd)
  3. Create a new WCF REST Service project in Visual Studio 2010

In the New Project Dialogue, we select Online Templates, then select WCF.

image

You will see the WCF REST Service Template 40 that we just installed; select it and give a name to the project, then click OK button.  WCF REST Service Template 40 generated all necessary program files to run Web Service for us.  If you build the project and run it, you will get the following web page.

image

Service1 is the name of Web Service.  Let’s create an Add function for Service1.

Add the following lines to Services1,cs:

[WebGet(UriTemplate = "Add?a={a}&b={b}")]
public Int32 Add(Int32 a, Int32 b)
{
    return a + b;
}

After we rebuild / rerun the project, then we can enter http://localhost:40501/Service1/Add?a=1&b=2.  A web page will be displayed with the following content:

<int xmlns="http://schemas.microsoft.com/2003/10/Serialization/">3</int>

This example is very simple but you can see it is also very simple to get Web Service up and running.  If you want to find out more about Web Service, please stay tuned.  I would show you how to call more sophisticated calculation within Web Service and call Web Service from other applications, e.g. Excel, desktop application and even smartphone.

 

About Andrew Chan
Andrew Chan is an Business Consultant who gives you accurate, consistent and timely information so that you can make better and faster decisions. He is an Associate of Society of Actuaries with over 20 years of IT experience. Apart from strong analytical skills and proven technical background, he was also a former system director at Manulife who had extensive project management experience. If you are looking for someone to gather, consolidate, validate, visualize and analyze data, look no further! Andrew can provide the most cost effective business analytics solution so that you can explore, optimize, predict and visualize your business. Don’t guess on any decision, no matter it is finance, operation, marketing or sales! Always ask for evidence!

One Response to Web Service 1-2-3

  1. Oliver Gray says:

    I would be interested to see how you use this from within Excel. I have been considering a similar approach myself to isolate approved business calculations from the users and just provide them with a function. However I’m not convinced how easy it would be for them to use, especially if you need more than a couple of inputs to the calculation method?

Leave a Reply

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

WordPress.com Logo

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

Facebook photo

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

Connecting to %s

%d bloggers like this: