Windows Server AppFabric Hello World

So I’ve been taking a look at BizTalk “lite”, a.k.a Windows Server AppFabric. 😉  Why?  Well lets face it, BizTalk Server is geared for throughput rather than low latency messaging.  So really any synchronous messaging scenarios requiring streamlined performance are going to be problematic if implemented on BizTalk Server.  Consider a typical service aggregation scenario that may aggregate data from a number of service calls.  Consider the overhead BizTalk Servers underlying publish/subscribe architecture imposes on this scenario.  Don’t get me wrong, BizTalk is a powerful integration server.  It’s my tool of choice for integration but there are scenarios where its use is not appropriate.  Use the right tooling for the job.  BizTalk Server and Windows Server AppFabric are complimentary technologies, we are even seeing some integration of the toolsets.  For example the BizTalk mapper can now be used from a WCF Workflow Service hosted on AppFabric.  The below quote provides some insight on where/why AppFabric came to be.

“As Microsoft looked at BizTalk, as well as the .NET Framework, it was determined that there are many great features in BizTalk that if a scaled down version was available (and was offered free with the operating system instead of a separate purchase) it would address gaps in the framework. Not all service developers had the money to spend or the need for all the infrastructure support of BizTalk Server.  Thus, Windows Server AppFabric evolved out of this thought process.”  See the rest of the article here.

So enough talk, more action.  This post revolves around a simple first up “Hello World” scenario.  I will develop a WCF Workflow Service and host it under IIS inside AppFabric.  The Workflow Service will call a web service, then send a response back to the workflow service consumer.  So pretty much the most basic scenario imaginable.

1.  Ensure you have AppFabric.  An easy easy way to do this is to start up the IIS administration console and look for the AppFabric Dashboard as below.  If its not installed then download here.

image

2. Create a new Visual Studio WCF Workflow Service project called HelloWorld_wf_svc

image

3. Go to the design service for “Service1.xamlx and delete the “Sequential Sequence” shape.  Add a new “Sequence” shape from the Visual Studio toolbox as below.

image

4. At this point we’ll create the sample WCF Service that our HelloWorld_wf_svc workflow service is going to call.  Add a new WCF Service Application project “HelloWorld_svc” to the solution as below.  For simplicity sake rename the “GetData” sample method to HelloWorld.  Then Publish the service to IIS.  This is just a traditional WCF service.

image

5. Add a service reference to the deployed HelloWorld_svc from our workflow service as below.  Then rebuild the “HelloWorld_wf_svc” workflow service.  When Visual Studio builds the project it uses the service reference and adds new activities to the Visual Studio toolbox that we will use to call the web service.

image

6.     Now lets build out the workflow service.  Go back to Service1.xamlx and drag a “Receive and Send Reply” activity into the Sequence shape on the design surface.  Whilst you’re there drag the “HelloWorld” activity and drop it in-between the newly created receive and reply shapes on the design surface.  The HelloWorld activity is what the workflow service uses to call our WCF web service.  Your workflow should start to look as below.

image

10. Create a variable as below.  This variable will take the response from our HelloWorld_svc web service.  This will all be feeling very familiar to the old BizTalk guns amongst us.  To create a variable right mouse on the Sequence shape and select “Create Variable”.  Add the variables as below.

image

11. Select the “HelloWorld” activity on the design surface and add the HelloWorldResponse variable as the web service result, add a static value to the value paramter.  In this case 1000.  1000 is the value that will be passed in the “value” paramter of the HelloWorld method.

image

12. Select the Receive shape and change the operation name field to “HelloWorldWorkflowSample” as below.  Also ensure the “CanCreateInstance” checkbox in the properties of the Receive shape is checked.

image

13. Select the Send shape and click the content field on the shape.  We are going to specify the workflow service response.  This is what will be sent back to the workflow service consumer.  Configure as below.

image

14.  We’re done!  Time to build and deploy to AppFabric.  Build and publish the HelloWorld_wf_svc project just as you would any other web service to IIS.  The properties should look something like below.

image

15. Now to test.  We’ll just use a simple console application.  Add a new console application to our Visual Studio project as below.

image

16. In the console application add a service reference to the AppFabric WCF Workflow Service.  e.g. http://localhost/HelloWorld_wf_svc/Service1.xamlx.  Then paste the below code into your console application.

using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using HelloWorld_console_test.ServiceReference1;

namespace HelloWorld_console_test
{
  class Program
  {
    static void Main(string[] args)
    {
      ServiceClient client = new ServiceClient();

      Console.Write(client.HelloWorldWorkflowSample());
      Console.ReadLine();
    }
  }
}

Run the console app and give it a test.  Attached visual studio to the w3wp.exe process and debug the WCF Workflow Service with breakpoints.  Open up the AppFabric dashboard under the IIS Administration console and see the number of WCF calls, view errors, etc.

image

This was a basic hello world sample aimed at getting familiar with the toolset.  I’ll post again shortly extending this scenario using the WCF LOB adapters to call SQL, Oracle, and SAP.

Advertisements
This entry was posted in .NET, Windows. Bookmark the permalink.

One Response to Windows Server AppFabric Hello World

  1. Lee says:

    Very well written post !!! I’ve a suggestion for you, quite recently I was watching a video on youtube talked about he feature comparison of AppFabric with NCache, which is is an enterprise level distributed cache for .NET and Java and also provides a fast and reliable storage for ASP.NET and JSP Sessions. Why don’t you also write a similar sort of comparison? I am sure your followers will defiantly like this post. Here is the link of the video I am talking about

    http://www.alachisoft.com/ncache/demos/ncache-vs-appfabric.html

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s