Using the New BizTalk Mapper Shape in a Windows Workflow Service

So hidden within the plethora of announcements about the BizTalk Server 2010 beta launch was a mention of AppFabric integration.  The best that I can tell, this has to do with some hooks between BizTalk and Windows Workflow.  One of them is pretty darn cool, and I’m going to show it off here.

In my admittedly limited exposure thus far to Windows Workflow (WF), one thing that jumped out was the relatively clumsy way to copy data between objects.  Now, you get a new “BizTalk Mapper” shape in your Windows Workflow activity palette which lets you use the full power of the (new) BizTalk Mapper from within a WF.

First off, I created a new .NET 4.0 Workflow Service.  This service accepts bookings into a Pet Hotel and returns a confirmation code.  I created a pair of objects to represent the request and response messages.

namespace Seroter.Blog.WorkflowServiceXForm
{
    public class PetBookingRequest
    {
        public string PetName { get; set; }
        public PetList PetType { get; set; }
        public DateTime CheckIn { get; set; }
        public DateTime CheckOut { get; set; }
        public string OwnerFirstName { get; set; }
        public string OwnerLastName {get; set; }
    }

    public class PetBookingConfirmation
    {
        public string ConfirmationCode { get; set; }
        public string OwnerName { get; set; }
        public string PetName { get; set; }
    }

    public enum PetList
    {
        Dog,
        Cat,
        Fish,
        Barracuda
    }
}

Then I created WF variables for those objects and associated them with the request and response shapes of the Workflow Service.

2010.5.24wfmap01

To show the standard experience (or if you don’t have BizTalk 2010 installed), I’ve put an “Assignment” shape in my workflow to take the “PetName” value from the request message and stick it into the Response message.

2010.5.24wfmap02

After compiling and running the service, I invoked it from the WCF Test Client tool.  Sure enough, I can pass in a request object and get back the response with the “PetName” populated.

2010.5.24wfmap03

Let’s return to our workflow.  When I installed the BizTalk 2010 beta, I saw a new shape pop up on the Windows Workflow activity palette.  It’s under a “BizTalk” tab name and called “Mapper.”

2010.5.24wfmap04

Neato.  When I drag the shape onto my workflow, I’m prompted for the data types of my source and destination message.  I could choose primitive types, or custom types (like I have).

2010.5.24wfmap05

After that, I see an unconfigured “Mapper” shape in my workflow. 

2010.5.24wfmap06

After setting the explicit names of my source and destination variables in the activity’s Property window, I clicked the “Edit” button of the shape.  I’m asked whether I want to create a new map, or leverage an existing one.

 2010.5.24wfmap07

This results in a series of files being generated, and a new *.btm file (BizTalk Map) appears.

2010.5.24wfmap08

In poking around those XSD files, I saw that two of them were just for base data type definitions, and one of them contained my actual message definition.  What also impressed me was that my code enumeration was properly transferred to an XSD enumeration.

2010.5.24wfmap09

Now let’s look at the Mapper itself.  As you’d expect, we get the shiny new Mapper interface included in BizTalk Server 2010.  I’ve got my source data type on the left and destination data type on the right.

2010.5.24wfmap10

What’s pretty cool is that besides getting the graphical mapper, I also get access to all the standard BizTalk functoids.  So, I dragged a “Concatenate” functoid onto the map and joined the OwnerLastName and OwnerFirstName and threw it into the OwnerName field.

2010.5.24wfmap11

Next, I want to create a confirmation code out of a GUID.  I dragged a “Scripting” functoid onto the map and double clicked.  It’s great that double-clicking now brings up ALL functoid configuration options.  Here, I’ve chosen to embed some C# code (vs. pointing to external assembly or writing custom XSLT) that generates a new GUID and returns it.  Also, notice that I can set “Inline C#” as a default option, AND, import from an external class file.  That’s fantastic since I can write and maintain code elsewhere and simply import it into this limited editor.

2010.5.24wfmap13

Finally, I completed my map by connected the PetName nodes.

2010.5.24wfmap12

After once again building and running the Workflow Service, I can see that my values get mapped across, and a new GUID shows up as my confirmation value.

2010.5.24wfmap14

I gotta be honest, this was REALLY easy.  I’m super impressed with where Windows Workflow is and think that adding the power of the BizTalk Mapper is a killer feature.  What a great way to save time and even get reuse from BizTalk projects, or, aid in the migration of BizTalk solutions to WF ones.

UPDATE: Apparently this WF activity gets installed when you install the WCF LOB Adpater SDK update for BizTalk Server 2010.  JUST installing BizTalk Server 2010 won’t provide you the activity.

Share

About these ads


Categories: .NET, BizTalk, WCF/WF

26 replies

  1. Hi Richard, interesting stuff. Too bad everyone is jumping on the new features so I’m always too late with writing my blog ;-)
    Like you I’m interested in the new BizTalk shapes in WF4, but unfortunately they’re not in my toolbox when I start a new console workflow app.(?)
    I have installed a BizTalk Server 2010 beta Hyper-V image on Win2k8 R2/SQL 2k8 R2. Do I need to do anything else?
    Thanks,
    Jean-Paul

  2. Thanks Richard for providing even more motivation to try out BTS2010 beta. I have downloaded it so it should not be too difficult now. I’m super exceited after reading your article.

  3. Hi Richard,

    The BizTalk group doesn’t appear in my Toolbox – which assembly do I need to
    add a reference to?

    –larsw

  4. Richard, having the same issue as the others. Don’t see the Mapper shape in my WF toolbox after installation. Any ideas?

    James

  5. Jean-Paul, Lars and James,

    I’m assuming you all have BizTalk 2010, Visual Studio 2010 installed. Mine did show up in the toolbox automatically, but, it can also be found in the Microsoft.ServiceModel.Channels.MapperActivity which is found at:
    c:\Program Files\Microsoft BizTalk Server 2010\Developer Tools\Microsoft.ServiceModel.Channels.MapperActivity.dll

  6. Have MS released any information regarding the licensing of the mapper activity in lieu of a full blown BTS license?

  7. That DLL did not exist in my install. Is this because I only installed the Dev Tools and not the server components?

  8. Richard this is awesome! I just tried this out at the hotel this morning and was amazed. I wasn’t sure about the idea of opening parts of BizTalk up outside of the core product, but this is amazing. You and Microsoft (I guess they deserve some credit) really outdid yourselves. I think this will greatly expand the base for BizTalk.

  9. From my experience, the Mapper Activity comes in the WCF LOB Adapter SDK. I have not installed the Adapter Pack.

  10. pretty cool feature and greate post as usual Richard. thanks a lot!

  11. Richard, Thanks for sharing this, one question:

    If I add an XSD into my Workflow project, can I use that in my map directly? as is the case in Biztalk, or I’ve to generate a class first from that XSD and only then I can use it inside the WF Mapper?

    I am not able to do the above so far, the XSD type doesn’t show up in the type selector for map, and it says “Select .Net Type” so I am wondering if using an XSD directly in a map is an option here or not.

Trackbacks

  1. Scott Banwart's Blog » Blog Archive » Distributed 52
  2. Videos & Feedback on the new features of BizTalk Server 2010 | Service Oriented Architecture - SOA
  3. Interview Series: Four Questions With … Dan Rosanova « Richard Seroter’s Architecture Musings
  4. BizTalk Server 2010 Beta: BizTalk + AppFabric « Connected Thoughts – Thiago Almeida
  5. Trying to Rehost the BizTalk Mapper Activity « MS Innovations Blog
  6. Useful Links for BizTalk & AppFabric - Damir Dobric Posts - developers.de
  7. Useful Links for BizTalk & AppFabric - DamirDobric
  8. 2010 Year in Review « Richard Seroter's Architecture Musings
  9. How to use Duplex MEP to communicate with BizTalk from a .NET application or a WF workflow running inside AppFabric Part 2 - Paolo Salvatori's Blog - Site Home - MSDN Blogs
  10. How to use Duplex MEP to communicate with BizTalk from a .NET application or a WF workflow running inside AppFabric Part 2 - Paolo Salvatori's Blog - Site Home - MSDN Blogs
  11. AppFabric CAT | How to use Duplex MEP to communicate with BizTalk from a .NET application or a WF workflow running inside AppFabric Part 2

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

Follow

Get every new post delivered to your Inbox.

Join 253 other followers

%d bloggers like this: