As described in the post of Richard Seroter, (http://seroter.wordpress.com/2010/05/24/using-the-new-biztalk-mapper-shape-in-a-windows-workflow-service/) there is a nice new feature that gets installed through the released beta of BizTalk 2010. Two capabilities of BizTalk Server are made available to WF 4.0! This is about the BizTalk mapper and the Line of Business adapters (like SQL, Oracle, SAP…).
These features are described in the following wiki white paper on the social technet site : http://social.technet.microsoft.com/wiki/contents/articles/biztalk-appfabric-better-together.aspx.
This is a first article in a series of three that is about these features. Three articles will be posted in the coming days:
1. Using the BizTalk mapper in Workflow
2. Using the LOB Adapter functionality in Workflows
3. Performance impact of the mapper shape, compared to code mapping.
The BizTalk mapper used in workflow services.
It happens a lot that data structures that are exposed through web services are different from the contracts and object types that need to be consumed by that service.
During one of the demos I gave lately, I showed how an AppFabric workflow service was used to compose and consume three different other web services. Allthough the customer really liked the pattern and the performance, he felt it was a bit too technical and too much code was involved to instantiate the web service requests and objects for the different services. They were right (I needed to use too much assign shapes and different variables).
Luckily, we have a good answer to this at this moment, through the BizTalk mapper workflow activity. It makes these workflows more model-driven and less code-oriented.
Installing the activities
It is important to know that the activities are only available in the Workflow designer toolbox, when installing the BizTalk LOB Adapter pack! They are not part of the BizTalk 2010 installable and it looks like the installer of the adapter pack is checking if BizTalk 2010 is available to see if he should make the activities available.
Sample workflow service
The scenario I’ll be working out in this post is the exposing of a service that will call another web service. This service will implement some specific logic and will also hide and abstract the actual names and contracts of the ‘backend-service’. The functionality we provide through this service is a loanrequest, where a consumer can request a loan and gets response with a result.
The exposed contracts
<to do : copy contracts />
Designing and beginning the workflow service
1. After adding a new workflow service, I changed the action and namespace on the ReceiveRequest activity.
2. I also defined two variables: loanRequest and loanResponse that apply to their corresponding DataContract message types. These are linked to the ReceiveRequest and SendResponse activities.
Adding a service reference to the ‘backend service’.
1. Right-clicking the project and selecting Add Service Reference, pops up the dialog where I am linking to the WSDL of my web service.
2. After a rebuild of this project, a new custom activity is added to my toolbox that can be used to call the web service operation. If my web service would have had multiple operations, multiple activities would have been added, one for each operation. They totally hide the implementation of doing this web service call.
3. Now, two new variables get defined that represent the request and response to the backend service. (notice the uppercased host-like names J)
4. Dragging the LOANSIM activity to the designer canvas allows us to link the variables to the Activity Parameters of this web service operation call.
Use the BizTalk mapper activity to map request and response variables
1. The Mapper activity is available in the BizTalk category in the Workflow Toolbox. I just dragged two instances of this activity to the canvas, just before and after the LOANSIM activity.
2. Once the mapper is dragged to the canvas, the input and output data types need to be configured, using the type picker dropdown. This will be used to define the BizTalk map inputs and outputs.
3. After this, the correct variables need to be linked and configured to their corresponding parameter.
4. Clicking the Edit button on the activity, allows us to automatically generate a new BizTalk map that will use these types or we can reuse an existing map.
5. Creating a new map, results in a new Biztalk mapper being opened. Various schemas are being generated and added to the project in a specific sub folder. The nice new BizTalk mapper can be used to make the mapping between both objects. If required, custom XSLT functionality can also be used for this.
6. The above logic has been done for both the request and the response messages.