All versions of BizTalk Server use a publish/subscribe messaging engine architecture. In a publish/subscribe architecture, all messages that flow through BizTalk Server are first published to the MessageBox database and subsequently picked up by Send Ports, Receive Ports, or Orchestrations that are decorated with matching subscription information. One of the primary advantages of a publish/subscribe architecture is that receiving of messages is loosely coupled from sending of messages and messages can be published even if there are no subscribers available to process messages when they are published. Other advantages include the ability to track message properties, messages bodies, and to resubmit messages that initially failed delivery to subscribers.
Figure 1 - BizTalk Server Publish Subscribe architecture
This document provides .NET/WorkFlow developers with techniques for utilizing AppFabric and BizTalk Server 2010 together to develop low latency connectivity solutions to LOB systems. Such solutions allow front end applications built on ASP.NET, SharePoint, or Web Services to exchange messages with multiple backend systems and respond to user initiated requests quickly.
This whitepaper provides information on using BizTalk Server and WF/WCF together by illustrating to BizTalk and Workflow developers how to combine functionality from both in a Visual Studio 2010 project. The project is a simple workflow that leverages the BizTalk Server Mapper and LOB Adapter functionality.
Because this project does not use the BizTalk Messaging Engine it will provide improved latency over a pure BizTalk Server solution while still utilizing BizTalk Server functionality.
Since Visual Studio 2010 can access the BizTalk Mapping and WCF LOB connectivity APIs, this whitepaper also illustrates how WorkFlow developers can now access BizTalk Mapper functionality to implement document transformations and complete WCF LOB connectivity without having to first configure a BizTalk Server environment.
The following users should read this guide:
All software was installed on a single machine using the steps provided at Installing the BizTalk Server 2010 AppFabric Connect feature on a developer computer (http://social.technet.microsoft.com/wiki/contents/articles/installing-the-biztalk-server-2010-appfabric-connect-feature.aspx#InstDev). For purposes of this walkthrough, both the Required and Optional components were installed.
This section provides a walkthrough of using Visual Studio 2010 with BizTalk Server 2010 and the BizTalk Adapter Pack to develop a simple WCF solution which uses the WCF SQL Adapter to retrieve some records from the "Customers" table in the "NorthWind" database, apply a simple map to the selected records, and then update a modified version of the "Customers" table ("Customers2") in a modified version of the "Northwind" database ("Northwind2"). To build and run the solution, follow these steps:
After installing all software, download the scripts to install the NorthWind database on your SQL Server instance from http://go.microsoft.com/fwlink/?LinkID=62009.
Note Ensure that your user account is member of the serveradmin role on this instance of SQL Server.
After following the instructions to install the NorthWind database on your SQL Server instance, paste the following script into the SQL Query Editor to add a "Customers2" table to the NorthWind database:
USE [Northwind]
GO
/****** Object:
Table
[dbo].[Customers2]******/
SET
ANSI_NULLS
ON
QUOTED_IDENTIFIER
CREATE
TABLE
[dbo].[Customers2](
[CompanyName] [nvarchar](100)
NOT
NULL
,
[Address] [nvarchar](100)
)
Figure 2 – Visual Studio 2010 New Project Dialog Box
Figure 3 – Visual Studio 2010 Service1.xamlx as viewed in Designer
Verify that the Add Adapter Service Reference dialog box is populated with the following values and click the OK button.
Figure 4 – Visual Studio 2010 Add Adapter Service Reference dialog box
Note If you installed the BizTalk Adapter Pack 2.0 on a 64-bit machine and you received the error message "No valid adapters installed on the machine", then ensure that the 32-bit version of the BizTalk Adapter Pack 2.0 is also installed. Both the 64-bit and 32-bit versions of the BizTalk Adapter Pack 2.0 are available for download at http://go.microsoft.com/fwlink/?LinkId=194572 (http://go.microsoft.com/fwlink/?LinkId=194572).
In the Solution Explorer, right-click the WCF_BTS_APP project and select Build from the context menu. After building this project with the new adapter service references the Visual Studio 2010 toolbox should expose two additional tabs; mssql:TableOp_dbo_Customers and mssql:TableOp_dbo_Customers2. The mssql:TableOp_dbo_Customers tab will expose a SelectActivity and the mssql:TableOp_dbo_Customers2 tab will expose an InsertActivity:
Figure 5 - Visual Studio 2010 Toolbox Tabs added after adding SQL Adapter service references
Figure 6 - Sequence shape with Receive shape, SelectActivity shape and InsertActivity shape as viewed in the Designer
These activities are visual representations of the logic that will be used to select records from the Customers table in the NorthWind database and after performing a BizTalk mapping operation on the selected records, insert the result set into the Customers2 table in the NorthWind database. Before we can apply any operations to the selected data or insert the result set we must first define a query for the select activity, and define variables to contain both the selected data as input into a BizTalk map as well as the data that is output from the BizTalk map.
After creating the variables data1 and data2 the Designer should look as follows:
Figure 7 – Variables defined in the Visual Studio 2010 Designer
After creating variables apply properties to the SelectActivity and InsertActivity items as follows:
Right-click to select the SelectActivity item in the Visual Studio Designer and select Properties from the context menu. Enter the following values for the SelectActivity item properties:
Follow these steps to add a BizTalk Map to the WCF_BTS_APP project:
Figure 8 – New map surface displayed in Visual Studio
Figure 9 – Map connecting input schema to output schema
Complete the following steps to publish the WCF_BTS_APP project to IIS:
Figure 9 – Publish Web dialog box displayed in Visual Studio
To create a console application to test the published WCF Service and verify that the WCF SQL Adapter is updating the NorthWind database as expected, follow these steps:
using
System;
System.Collections.Generic;
System.Linq;
System.Text;
ConsoleAppTest.ServiceReference1;
namespace
ConsoleAppTest
{
class
Program
static
void
Main(
string
[] args)
Console.WriteLine(
"Invoking WCF Service to transform selected rows from Customers table and insert result set into Customers2 table"
);
IinitializeSvcClient client =
new
IinitializeSvcClient();
client.ExtractTransformLoad();
"Done"
"Please press <Enter> to close program."
Console.ReadLine();
}
Another important place to find a huge amount of BizTalk related articles is the TechNet Wiki itself. The best entry point is BizTalk Server Resources on the TechNet Wiki Read suggested related topics:
Carsten Siemens edited Revision 70. Comment: fixed typo
Sandro Pereira edited Revision 73. Comment: Fixing picture format to center
Maheshkumar S Tiwari edited Revision 76. Comment: Added tags
Trace Young edited Revision 66. Comment: Ed here. Featuring this article on the front page of TechNet Wiki! Congrats!
_RussH edited Revision 67. Comment: unfeatured article
Excellent
Impressive
Any idea why I am missing : "Add Adapter Service Reference" when I right click on project level (under item 10 Create the WCF Solution and a WCF Workflow Service Application in Visual Studio 2010). Iam running Windows 7 Home Premium edition and VS2010 Pofessional. Thanks for your suggestions.
Hi Peter,
IIRC, the "Add Adapter Service Reference" functionality is provided when you install the The WCF LOB Adapter SDK SP2, which can be downloaded from go.microsoft.com/fwlink. Can you verify that the WCF LOB Adapter SDK SP