Escolar Documentos
Profissional Documentos
Cultura Documentos
Server 2010
Biztalk Developer Courseware
Microsoft Certified Technology Specialist
Version 1.0
www.firebrandtraining.com
Module 0: Introduction
Time estimated: 30 minutes
Course timing
Approximate timings for this course are included in the following tables.
Day 1
Day 2
Day 4
Day 5
Start End Module
Description
This five-day instructor-led course provides students with the knowledge and skills to
integrate internal and external systems and trading partners and to develop business
process integration applications using BizTalk Server 2010.
Audience
This course is intended for developers who are responsible for developing BizTalk Server
2010 e-business solutions.
Individuals who attend this course are expected to have the following prerequisite
knowledge or experience:
At least two years of experience using Visual Basic, C#, or Java to develop distributed
applications
Familiarity with systems integration and Web services terminology and concepts
Familiarity with Visual Studio 2010.
Working knowledge of XML
Prior experience with of BizTalk Server is not required.
Course Outline
Course outline
This course contains a total of nineteen modules. The last four modules are optional, and
they may be covered as time permits. Each module contains multiple lessons.
Module 1, “Introduction to BizTalk Server 2010,” introduces the core features of BizTalk
Server 2010 and how messaging and orchestration services work. Also, this module provides
a look at what is new in BizTalk Server 2010.
Module 2, “Creating Schemas,” shows how to create and manage XML and flat-file schemas.
Module 3, “Creating Maps,” shows how to create maps and use functoids to perform
mapping operations.
Module 4, “Deploying and Managing BizTalk Application,” shows how to deploy applications
to the BizTalk Server computers that will host the application.
Module 5, “Routing BizTalk Messages,” shows how to filter and route messages to BizTalk
send ports and orchestrations.
Module 6, “Creating Pipelines,” shows how to use the Pipeline Designer to create and
configure send and receive pipelines.
Module 7, “Integrating with Adapters,” shows how to configure adapters to integrate BizTalk
servers with systems, databases, and applications.
Module 8, “Creating a BizTalk Orchestration,” shows how to use BizTalk Orchestration
Designer to create an orchestration.
Course Outline (continued)
Hyper-V configuration
In this course, you will use Microsoft Hyper-V R2 virtual machines to perform the hands-on
practices and labs.
The following table shows the role of each virtual machine used in this course.
Course files
There are files associated with the demonstrations, practices, and labs in this course. The
files are located on each student computer, in the folder C:\Microsoft BizTalk Server 2010
Training.
Classroom setup
Each classroom computer will have the same virtual machine configured in the same way.
Each of the labs in this course uses its own virtual machine. There are 14 virtual machines.
Hyper-V demonstration
In this demonstration, your instructor will help familiarize you with the Virtual PC
environment in which you will work to complete the practices and labs in this course. You
will learn:
How to start Hyper-V.
How to start a virtual machine.
How to log on to a virtual machine.
How to switch between full screen and window modes.
How to pause a virtual machine
How to resume a virtual machine
How to distinguish the virtual machines that are used in the practices for this course.
How to close Virtual PC.
Keyboard shortcuts
While working in the Hyper-V environment, you might find it helpful to use keyboard
shortcuts. Some useful shortcuts include:
CTRL-ALT+END to log on to the Virtual Machine.
CTRL-ALT+BREAK to switch between full-screen and window modes.
For more information about using Hyper-V, see Hyper-V Help.
Module 1: Introduction to BizTalk Server
2010
Time estimated: 120 Minutes
Module objective:
In this module, you will learn how to:
Describe the BizTalk message processing architecture and identify the new features and toolsets
provided in BizTalk Server 2010.
Overview
Microsoft® BizTalk® Server 2010 helps customers efficiently and effectively integrates
systems, employees, and trading partners faster than ever before. BizTalk Server 2010
introduces a host of new performance features and an improved toolset that enables
developers, IT professionals, and business analysts to build, deploy, and analyze complex
application integration and business process automation scenarios.
Lesson 1: What Is BizTalk Server 2010?
Lesson objective:
Describe common BizTalk Server 2010 scenarios, the overall messaging architecture, and the
common job roles and toolsets used with BizTalk.
Overview
BizTalk Server 2010 solves common problems that many businesses encounter with
automating business processes: integrating multiple heterogeneous systems and
communicating with business partners. This section provides an overview of BizTalk Server
2010 and identifies several common BizTalk integration scenarios. It will also provide a
detailed look at how BizTalk works to processes messages.
BizTalk Integration Services and Tools
Overview
BizTalk Server 2010 is an efficient business-process management server that provides
powerful messaging and orchestration services and development tools. BizTalk unifies these
services and development tools to provide a smooth design experience for developers
designing a business process as well as a robust environment for deploying and executing
business processes.
Multiple Applications
Businesses often acquire multiple systems and applications from different vendors to
support their business needs. This results in a variety of applications that run on dedicated
platforms and which were not designed to work together. This is because each application is
usually designed in isolation to fulfill a specific purpose such as inventory, human resources,
or customer relationship management (CRM).
Companies wanting to integrate information from these internal applications discover that
integrating systems can be an expensive and time-consuming task. BizTalk helps to solve
many of the problems associated with integrating systems and managing business
processes.
Common Complaints
Consider the following common integration complaints:
BizTalk Integration
BizTalk Server 2010 facilitates integrating internal applications and securely connects with
your business partners over the Internet. Companies need to integrate applications,
systems, and technologies from a variety of sources. To make this easier, BizTalk delivers
integration technology and BizTalk Server 2010 offers with many industry accelerators and
adapters.
BizTalk Orchestration
As a developer, you can implement this type of business process integration by writing your
own application by using C# or Microsoft Visual Basic®. However, creating, maintaining, and
managing complex business processes in conventional programming languages can be
challenging, costly, and time-consuming. BizTalk Server 2010 enables you to create these
business processes graphically. This results in business process automation applications
being developed faster and more cost effectively than building the process directly in a
programming language. It also makes the process easier to understand, explain, and change.
Explain how BizTalk messaging and orchestration services work to process messages.
Overview
The two main services in BizTalk Server 2010, the messaging engine and the orchestration
engine, form the underlying architecture that enables you to integrate and exchange
messages with the many types of external systems and applications that exist in your
organization and with trading partners.
Messaging Engine
The purpose of BizTalk is to process messages. All communication within BizTalk and
between a BizTalk Server and other systems are based on the exchange of messages. For this
reason, the messaging engine is essential to all BizTalk operations.
The BizTalk messaging engine performs the following tasks:
Message database
The MessageBox database is a Microsoft SQL Server™ database that is used by BizTalk to
store and route messages to orchestrations and send ports. When a message arrives in the
MessageBox database, the metadata associated with the message is matched and evaluated
to determine the services that subscribe to messages of this type.
Publish-Subscribe Model
BizTalk Server implements a publish-subscribe model for the routing of messages. In the
publish-subscribe model, message providers (publishers) submit messages to a central store
(the MessageBox), where subscribers (send ports and orchestrations) can subscribe to
specific messages. After a message of interest is received by the MessageBox, it is sent to all
subscribers.
For example, when a patient is admitted to a hospital, several processes need to be started,
and various systems need to be updated. These systems might include an ERP application
and other proprietary applications. Each of these systems usually requires a unique message
format. The creation of a new patient admission form generates the initial message that
begins the process. Each of the other systems could subscribe to these messages as separate
tasks in an overall business process.
Using the publish-subscribe model, new systems can be added and old systems updated
without the need to rewrite the integration application.
Animation: BizTalk Message Flow
Animation
In this animation, you will see an overview of how the BizTalk messaging and orchestration
runtime components work to process XML and flat-file messages.
BizTalk Job Roles and Tools
Identify common job roles that relate to the design, development, and management of a BizTalk
solution.
Developers
Developers use the design provided by the business analyst to create an application that
models the business process. BizTalk developer tools are integrated in Microsoft Visual
Studio® 2010. The developer uses these tools to perform tasks such as defining XML
schemas for the business documents, specifying the relationships between schemas,
creating the orchestrations necessary to implement the business process, and deploying
applications to servers for testing the business processes.
IT Professionals/Administrators
The administrator plays an important role by establishing a secure BizTalk environment,
setting up communications among the parts, deploying the application, and performing
other administrative tasks to manage the BizTalk environment and applications in a
production environment. The administrator role also includes the installation and
configuration of a stable and high-performance SQL server environment.
BizTalk Server 2010 Editions
Overview
Microsoft BizTalk Server 2010 is available in five editions designed to meet the needs of
organizations of different sizes and needs:
Enterprise Edition. BizTalk Server 2010 Enterprise Edition is targeted to large
organizations and trading hubs as well as digital marketplaces. Enterprise Edition
offers the complete set of BizTalk Server 2010 features. It supports an unlimited
number of internal applications running on multiple processors, and it supports
clustered deployments. Microsoft also offers a specialized edition of BizTalk Server
2010 named the RFID Enterprise Edition that offers only RFID capability for
integration of remote RFID sensors.
Standard Edition. BizTalk Server 2010 Standard Edition is designed for small and
medium-sized organizations. It offers the same set of features as BizTalk Server 2010
Enterprise Edition, but the number of internal applications is limited to five. This is a
decrease of 5 internal applications, but there is no longer a limit to the number of
trading partners. Standard Edition will run on 2 CPUs on a single server.
Branch Edition. BizTalk Server 2010 Branch Edition is a new licensing option. Branch
Edition is designed for intra-enterprise hub and spoke scenarios. You can use Branch
Edition to integrate 1 internal application with a BizTalk Server “hub” that
coordinates/aggregates events across multiple Branch Editions. It is a subset of
BizTalk Server 2010 functionality that includes the technology adapters, RFID, mobile
support and Host Integration Server. Branch Edition does not include the
application adapters, the BizTalk Adapter Pack or any of the BizTalk accelerators.
Branch Edition is limited to 2 CPUs on a single server with a single message box.
Developer Edition. BizTalk Server 2010 Developer Edition is available as a free
download from the Microsoft web-site. It provides the same set of features as
Enterprise Edition, but it is not licensed for production use. Developers can use this
edition of BizTalk Server 2010 in a development environment for application
development and testing, and for deploying applications to a full production
environment.
Lesson 2: What’s New in BizTalk Server 2010?
Lesson objective:
Identify the new features and improvements for developers and administrators.
Overview
BizTalk Server 2010 builds on the previous version, BizTalk Server 2009, by offering many
improvements, including support for more efficient installations, new developer features
new management features and updated adapters. The administration features include a
new BizTalk Server Settings Dashboard, a new System Center Operations Management Pack
and improved trading partner management.
Installation and Setup
Overview
There are two key improvements in the setup functionality provided by BizTalk Server 2010.
First, BizTalk Server 2010 provides full support for SysPrep which improves administrator
efficiency when scaling out a BizTalk Server Group. The second key improvement is the
clustering support offered by Windows Server 2008 R2, offering improved high-
availability/fail-over support.
Overview
The BizTalk developer tools have been enhanced in BizTalk Server 2010 from earlier
versions. BizTalk 2010 adds additional improvements to simplify developing BizTalk
solutions.
Mapper Improvements
The BizTalk 2010 Mapper has been improved with a new user interface that eases
development of large transformations and provides new search and predictive matching
functionality. The new BizTalk Mapper also improves productivity by adding cut, copy, paste,
move and undo functions and improved support for documenting maps and readability.
Readability improvements include a new pan feature, and automatic scrolling that brings all
of the relevant links and functoids in to view when a user clicks on schema node.
Developer Tool Improvements
The BizTalk Server 2010 Management Pack improves the visibility of an environment’s
health status by using color schemes to visually represent the health status of all BizTalk
Server artifacts. A stopped artifact is displayed as red, a started artifact is displayed as
green, and an artifact that has encountered any errors is displayed as yellow. In addition to
indicating highlighting the artifacts with errors, the BizTalk Server 2010 Management Pack
provides improved diagnostic support by including more detailed error information than did
previous versions.
The BizTalk Server 2010 Management Pack offers improved discovery of artifacts across
multiple machines. When SCOM monitors a multiple server environment, monitoring agents
running on the machines discover the same set of artifacts from the configuration database,
resulting in duplicate displays of an artifact in the SCOM console. With BizTalk Server 2010
management pack, the monitoring agents discover the artifacts from a single machine,
avoiding the duplication.
The BizTalk Server 2010 Management Pack also offers improved discovery of relationships
between BizTalk artifacts. It optimizes the discovery of relationships by properly sequencing
the discovery of the artifacts before the discovery of relationships.
Overview
BizTalk Server 2010 includes an improved FTP adapter and updated application adapters.
Describe considerations for upgrading from BizTalk Server 2006 R2 or 2009 to BizTalk Server
2010.
Lesson objective:
Identify system requirements and identify the most common tools used to develop BizTalk
applications.
Overview
The BizTalk Server 2010 development environment includes a number of tools for creating
schemas, designing business processes
System Requirements
Identify hardware and operating system requirements and required prerequisite services.
Hardware Requirements
The minimum hardware requirements for any computer on which you intend to install
BizTalk Server 2010 for application development are as follows:
A 1-gigahertz (GHz) Intel Pentium–compatible CPU
2 gigabytes (GB) of random access memory (RAM)
10 gigabytes (GB) of available hard disk space
Hardware Recommendation (Developer)
For an optimal experience and increased performance when developing BizTalk applications,
it is recommended that you use at least the following hardware:
If using Hyper-V to host a virtual machine for BizTalk development, make sure that the
physical machine has sufficient resources to allocate the resources described above to the
virtual machine.
Software Requirements
Identify prerequisite and optional services required for a BizTalk development environment.
Identify the Visual Studio project templates used to develop BizTalk applications.
Project Template
The BizTalk Server 2010 installation process adds the BizTalk Projects folder to the New
Project dialog box. The BizTalk Projects folder includes templates for creating the following
types of projects:
Empty BizTalk Server Project. Use the Empty BizTalk Server Project template when
you want to create a new application that runs on BizTalk Server 2010. This is the
most common BizTalk project type.
BizTalk Server BPEL Import Project. Use the BizTalk Server Business Process
Execution Language (BPEL) Import Project template to launch the BPEL Import
Wizard. This wizard will guide you through the necessary steps to import BPEL,
WSDL, and XSD files into a BizTalk Project. BPEL will be discussed further in Module
8.
Tools for Developers
Overview
The BizTalk developer tools are hosted in the Visual Studio 2010 environment and are used
for both messaging and orchestrations.
BizTalk Editor helps you define schemas, which are used to describe the format of
messages that are used within organizations and between trading partners and
which will be processed by BizTalk Server 2010.
BizTalk Mapper presents source schemas and destination schemas side by side,
making it possible to define transformations between data fields in messages.
Pipeline Designer is used create custom pipelines that are used to process incoming
and outgoing messages. The pipelines implement such operations as encryption and
decryption, compression, reformatting, and validation.
Orchestration Designer enables you to create orchestrations that are used to model
business processes. The orchestration designer offers a toolbox of components to
model business processes.
Compiled Artifacts
The BizTalk artifacts (schemas, maps, pipelines, and orchestrations) that you create using the
developer tools just listed are compiled in Visual Studio as one or more assemblies (DLLs)
that can then be deployed to the BizTalk Server for testing or production.
BizTalk Schema Editor
Overview
BizTalk Server 2010 uses XML Schema Definition language (XSD) schemas to define the
structure of all messages it processes. Generally it is possible to work with schemas provided
by third-party editors and schema creation tools. The BizTalk Schema Editor helps you define
schemas, which are used to describe the format of data that is processed within
organizations and between trading partners.
Each unique document type requires a separate schema that defines the records and fields
contained in the document. The XML schema defines:
The elements, attributes, and data types that appear on the document.
The ordering of tags in the document.
Fields that are mandatory or that may occur multiple times in a single document.
BizTalk Mapper
Overview
The BizTalk Mapper tool is used when it is necessary to map the contents of an incoming
message to a message format that can be processed by BizTalk. The BizTalk Mapper presents
the source schema and destination schema side by side, making it possible to define
transformations between the data fields in messages. You create a map when you want to
transform data that you receive or send from one message format to another. Compiling a
map created by the BizTalk Mapper generates an XSLT file for data transformation and
translation.
Example
For example, if you receive a purchase order and want to insert the ShipTo address
information from the purchase order into an invoice, you can create a map that specifies
how the appropriate records and fields from an instance message corresponding to a source
schema should be moved to an instance message corresponding to a destination schema.
BizTalk Pipeline Designer
Explain how the how the Pipeline Designer enables developers to create pipelines.
Pipeline Designer
Pipelines are software components that are used to process messages. Messages can be
processed as they are received or just before they are sent through a send port. The Pipeline
Designer is a graphical tool that you can use to provide additional processing to messages
such as:
Normalizing data from various formats to XML.
Denormalizing data from XML to various formats.
Assembling and disassembling documents.
Decoding and encoding documents.
Decrypting end encrypting documents.
Assigning and verifying digital signatures.
Custom processing of messages.
BizTalk Orchestration Designer
Describe the tasks that can be performed using the BizTalk Server 2010 Administration Console.
Learn how BizTalk Server project tools—including Orchestration Designer, BizTalk Editor, BizTalk
Mapper, and Pipeline Designer—are integrated as a unified development environment within
Visual Studio.
Scenario
Adventure Works is a retail sporting goods chain with 10 stores in the Pacific Northwest. The
company headquarters receives daily batches of orders from each retail store. These
batches are processed by a Microsoft BizTalk Server 2010 application.
In this lab, you will examine and test the BizTalk Server application that you will be building
throughout the remainder of this course. This application receives and processes sales
orders. If the application receives an order for a non-cash transaction, the loan application is
automatically approved or denied, based on predetermined business rules. If the credit
application is denied, the loan application is sent to a Microsoft Windows SharePoint
Services site for manual review. If the loan application is denied during the manual review
process, the order is canceled, and the store is notified. If the loan application is approved,
the total loan amount is evaluated to determine who the lender will be. Loans for less than
$1000 are carried by the Adventure Works finance department. Larger loans are managed
by one of two banks, based the customer’s credit rating. For all completed cash or credit
transactions, the inventory system is updated, and a sales order acknowledgement is
generated.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-01 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose
Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click Ask Me Later, and then click OK.
Module objective:
In this module, you will learn how to:
Introduction
Microsoft® BizTalk® Server 2010 can receive messages formatted as XML, flat files, or as
Electronic Document Interchange (EDI). Regardless of the format of the incoming message,
the BizTalk orchestration and messaging engine always processes messages in XML format.
This requires that a schema be defined in order to convert the message to XML format that
can be processed by BizTalk. In the case of flat file or EDI messages, XSD (XML Schema
Definition) annotations are used within the schemas to provide the additional information
required by the relevant parsers. This module provides the knowledge and skills necessary
for developers to create XML and flat file schemas.
Lesson 1: Introduction to BizTalk Schemas
Lesson objective:
Describe how BizTalk uses XML and identify the types of XML message types supported by
BizTalk.
Introduction
Creating schema definitions for the messages to be processed by BizTalk is usually the first
step in developing an integration solution. This lesson provides a review of XML terminology
that you may already be familiar with and identifies how BizTalk implements XML standards.
In this lesson, you will learn how BizTalk uses namespaces as well as the various schema
types that can be created for use by BizTalk.
Reviewing XML Terminology
Overview
BizTalk Server was one of the first applications specifically designed to work with data in
XML format. All documents (messages) that will be internally processed by BizTalk must first
be converted to XML. All XML artifacts that are created by BizTalk are fully World Wide Web
Consortium (W3C) compliant. This means that schemas created using other tools can
generally be used by BizTalk and vice versa.
XML Terminology
The following are some of the terms and XML features supported by BizTalk Server 2010:
Namespace. An XML namespace is a W3C standard for providing uniquely named
elements and attributes in an XML instance. An XML instance may contain element
or attribute names from more than one XML vocabulary. If each vocabulary is given
a namespace, the ambiguity between identically named elements or attributes can
be resolved.
Element. An XML element is a construct used to organize information in a
hierarchical manner. XML elements can either be simple data types (such as strings,
decimals, and unsigned bytes) as defined in W3C standards, or they may be a
complex type containing other elements and/or attributes. Elements and attributes
are case sensitive; that is, Customer is not the same element name as customer or
CUSTOMER.
Attribute. An XML attribute is a construct used to associate additional information
contained with an XML element. Unlike elements, attributes cannot be nested.
Attributes can be associated with any of the simple data types, but because they
cannot be nested, they cannot be a complex type.
In the following example, Customer is an element with a value of Contoso. ID is an
attribute of the Customer element and has a value of 12345.
<Customer ID=”12345”>Contoso</Customer>
XML Schema Definition Language (XSDL). The XML schema definition language is
used to create schemas that represent the message formats that BizTalk will
process. Schemas define nodes such as required and optional fields, recurring fields,
and order. An instance message can be validated against an XSD to verify that the
format is valid.
XML Path Language (XPath). A language used for navigating through the hierarchy
of an XML document. For example, XPath can be used to select data in an XML
document that matches a certain criterion or to perform comparisons on retrieved
data.
Extensible Style Sheet Language Transformation (XSLT). A language definition for
XML data presentation and data transformations. Data presentation refers to how
data is formatted for display purposes in a specific format or style. Data
transformation refers to how data is transformed and exchanged. For example, a
purchase order could be converted from the format submitted by a trading partner
to the format required for your internal processes.
Document Object Model (DOM). The DOM provides a mechanism for navigating
through a message. When working with XML documents, the DOM is often used to
manipulate and query XML data. In BizTalk, when references are made to the XML
DOM, it is usually presumed that the message is being loaded into memory, which
results in slower processing than would be experienced if the data were simply
being streamed.
Web Services Description Language (WSDL). An XML format that describes the
capabilities and characteristics of a Web service. BizTalk can both publish and
consume Web services. That will be discussed in module 12.
Simple Object Access Protocol (SimpleSOAP). Defines a simple way of sending XML
messages across the Internet. SOAP is used in BizTalk Server in conjunction with
Web services.
What Are XML Namespaces?
Overview
An XML namespace is a W3C standard for providing uniquely named elements and attributes
in XML instances. XML namespaces help the BizTalk parser recognize the proper schema or
schemas as well as the tags that describe the structure of the data inside the schema.
XML Namespaces
XML messages (instances) may contain elements or attributes from more than one XML
vocabulary. If each vocabulary is given a namespace, the ambiguity between identically
named elements or attributes can be resolved. Element names within a namespace must be
unique.
A simple example of ambiguous elements would be to consider an XML instance that
contains references to a customer and an ordered product. Both the customer and product
elements could have a child element ID_number. References to the element ID_number
would therefore be ambiguous. By providing namespace references, the two identically
named but semantically different elements can be differentiated.
A namespace is declared by using the reserved XML attribute xmlns, the value of which must
be a Uniform Resource Identifier (URI). The declaration generally also includes a short prefix
with which elements and attributes can be identified, such as
xmlns:prod="http://adventure-works.com/customerOrderl". A maximum of one namespace
per schema (the default namespace) has no prefix. Any elements that are not associated
with a prefix will be presumed to belong to this namespace.
In the following example, the default namespace is http://adventure-
works.com/salesReport, whereas the products namespace (http://adventure-
works.com/products) has a prefix of prod. Without the namespace reference, the id element
as used in the customer and for the product would be ambiguous.
<salesReport xmlns="http://adventure-works.com/salesReport"
xmlns:prod="http://adventure-works.com/products">
<customer>
<id>Fabrikam</id>
<sales>
<prod:id>widget1004</prod:id>
<prod:unitsSold>100</prod:unitsSold>
<prod:price>35</prod:price>
</sales>
</customer>
</salesReport>
How Does BizTalk Use XML Namespaces?
Overview
As previously stated, BizTalk Server relies on the use of structured documents for all internal
messaging and orchestration operations. BizTalk uses W3C standard format XSD but extends
these by referencing additional namespaces. This results in schemas that can still be used by
other systems that understand XML and contain the additional parameters required by
BizTalk.
It should be noted that BizTalk can process strictly binary data—for example, .bmp files and
.pdf files through its routing functionality—from one location to another, and, in this case,
an XML schema is not required. This special handling requires the use of a pass-through
pipeline, which will be addressed in Module 5.
BizTalk Namespaces
BizTalk adds the following namespaces to schemas as necessary to facilitate custom
functionality:
Target Namespace. When creating new schemas by using the BizTalk Editor, a target
namespace is added by default. This namespace is used in conjunction with the root
node name to uniquely identify the schema that relates to an inbound message.
Other operations within BizTalk also rely upon the target namespace.
Schema Extensions Namespace. When working with flat file and EDI schemas,
BizTalk will add a reference to the namespace shown below. This reference provides
the extensions necessary to define delimiters and positional settings while still
allowing the creation of XSD-compliant schemas that can be used by applications
other than BizTalk.
xmlns:b="http://schemas.microsoft.com/BizTalk/2003
Describe how BizTalk uses XML and what is defined in BizTalk XML schema.
Overview
XML schemas define the data structure for all XML business documents that you exchange
within and across organizations by using BizTalk. BizTalk also requires schemas in order to
have an XML representation of the flat file messages that it will be processing.
BizTalk Schemas
BizTalk can use schemas provided by trading partners or created by using other third-party
schema creation tools and applications. BizTalk includes tools for creating (or modifying)
schemas, including schemas to be used for flat file processing. Generally speaking, it is a
good idea to get in the habit of creating your schemas by using the BizTalk Editor, which will
be discussed in the next lesson.
A typical XML or flat file document might be a purchase order, an invoice, or any other type
of document representing a business transaction. Each unique document type requires a
separate schema that defines the records and fields contained in that document.
The XML schema defines:
Elements and attributes, which are the building blocks of a schema.
Data types that appear in document instances, including simple and complex data
types.
Simple data types, which are data types that contain data and cannot be nested.
Examples of simple data types include xs:string, xs:int, and xs:long. Elements or
attributes can be simple data types.
Complex data types. Complex data types can contain both data and nested data. For
example, in the slide for this section, the Item element is a complex type because it
contains other elements. Only elements can be complex data types; an attribute
must be associated with one, and only one, element.
Namespace declarations and version information.
The ordering of tags in the document.
Fields that are mandatory or that may occur multiple times in a single document.
Schema Types
BizTalk Server 2010 can natively process messages in XML flat file and EDI message formats.
BizTalk is extensible, and custom message types can be created in addition to those
supported out of the box.
XML Schema
An XML schema defines the structure of XML messages. XML messages are arranged in a
hierarchical format that is defined by the schema. Messages are identified and validated
against their associated schema.
EDI Schema
BizTalk supports the creation and use of schemas that represent various EDI document
formats such as EDIFACT and X12. An EDI message is a variation of a text message and does
not use typical delimiters such as carriage returns and linefeeds. As with flat file schemas,
BizTalk uses the annotation capabilities of XSD to store the extra information related to the
format of the EDI messages.
EDI messages are beyond the scope of this course. Refer to the BizTalk help files for
additional information on EDI schemas and their uses.
Flat File Structures
Identify the types and characteristics of flat file messages that can be processed by BizTalk.
Flat Files
BizTalk Server is designed to make it easy to create schemas for positional flat files,
delimited flat files, and files that combine positional and delimited records. At the root level,
most flat files are delimited with a carriage return (for example UNIX files), a linefeed, or,
more frequently, both. For this reason, even files that contain mostly positional data will be
defined as delimited at the root.
Delimited Files
A delimited file contains one or more fields separated by a delimiter character. This
character is frequently a comma (,) or pipe symbol (|) but could be any character. BizTalk
Editor does not read delimiters as part of the data. However, if the delimiter character might
appear within the instance as valid data, the data can be formatted so that what would
otherwise be a delimiter character is treated as valid data.
In the following example, the record contains four fields that are delimited with commas.
The fields are first name, last name, address, and a comment. The comment contains a
comma that would normally be interpreted as a delimiter. With the comment enclosed in
quotes (“”) the embedded comma is treated as part of the data.
John, Smith, 123 Main St, “BizTalk, Learning BizTalk Server 2010” ¶«
Lesson objective:
Create an XML schema by using the BizTalk Editor and create a flat file schema by using the Flat
File Schema Wizard.
Overview
In this lesson, students will learn how to use the BizTalk Editor and the Flat File Schema
Wizard to create BizTalk schemas. Students will also learn how to import existing schemas
and how to validate a schema and generate a schema instance.
Methods for Creating BizTalk XML Schemas
Identify the methods and tools available for creating XML and flat file schemas.
Overview
You can use the Generate Schemas dialog box to generate an XSD schema from one of the
following sources:
A well-formed XML instance message
A valid XDR schema
A valid DTD
In each of these cases, you would begin by adding a new generated item to the project (right
click the project, click Add, and then click New Generated Item) and then browsing to locate
the appropriate source file. A new schema with the same name as the source file is created
in the current solution. This schema can be renamed and, if necessary, edited using the
BizTalk Editor.
BizTalk Editor
The BizTalk Editor automatically starts when you add a new schema to a BizTalk project or
open an existing schema in the project. You can use the BizTalk Editor to construct and
modify schemas without the need to learn all of the intricacies of XSD syntax. The schema
tree view is where you actively construct your schema. The XSD view is a read-only view that
represents the XSD syntax for the schema you are creating. When creating or viewing flat file
schemas, this view has an additional page named Flat File that shows the delimiters and
positional spacing in use.
BizTalk creates (and uses) fully W3C-compliant schemas. More information about elements,
attributes, data types, and schema design is available through many online resources,
including MSDN®.
Node Types
The following menu choices are available when inserting nodes into a schema tree:
Field Element. Represents items of information that are simple in nature, such as
strings and numbers. You must use a record if the field has children or is repeated.
Field Attribute. Represents items of information that are simple in nature, such as
strings and numbers.
Child Record. A record is a container object (it cannot directly contain data) that
represents a collection of information. Records have the record icon associated with
them but are implemented as complex data type elements in the schema. A record
node can include element or attribute nodes based on simple data types such as
strings and numbers or can provide nesting of other complex data types (sequence
group or choice group).
Sequence Group. Contains other nodes that must appear in an instance message in
the same order in which they appear within the Sequence Group node.
Auto-Refresh
When working with large schemas, auto-refresh might cause undesirable delays. In such
cases, you can disable automatic (continuous) refresh by clicking the link at the bottom of
the window. You can then click the refresh link as needed to refresh the XSD view.
Using Multiple Schemas
Overview
When your schemas become large and complex, or when schemas that represent different
types of instance messages have some sections in common, it can be useful to include
smaller schemas as building blocks in the larger ones. For example, you might have several
message types, each of which must contain a shipping address. You can define the structure
of a shipping address in a single smaller schema and then include that schema within the
other, larger schemas that define Order, Invoice, and Shipping Notice messages. If this
format changes, there is a single place to update rather than having to update it at each
occurrence.
Overview
After you have constructed or added a schema into your BizTalk project, you can perform
several operations to make sure the newly created schema can correctly validate data.
Regardless of the format of the messages they represent, all schemas can be tested using
these methods. You can also generate sample instance documents, which are helpful for
comparing against provided instances.
Testing a Schema
There are three tests that can be performed on any schema to validate that it is a well-
formed XSD and that it can be used to validate message instances. All of these tests can be
configured in the Microsoft .NET properties of the schema (accessed by right-clicking the
schema in Solution Explorer and then clicking Properties). To perform any of these tests,
right-click the schema in Solution Explorer, and then click the appropriate menu command.
The tests are as follows:
Validate Instance. This test is extremely useful when you have an XML or flat file
document with data that you would like to make sure is valid against a schema. In
many cases, you may find that one instance may validate while another will not, for
example, if the schema was generated with a message that had a single product
instance but you need to validate messages that also have multiple products.
Validate Schema. Schemas generated within BizTalk will always be valid XSD
because BizTalk enforces such rules as the schema is created; however, schemas
provided by others may not adhere to W3C standards as strictly. This step ensures
that the XSD has valid syntax. This step is most often necessary when adding an
existing schema into a project that was not built by the BizTalk Schema Editor.
Generate Instance. You can use this option to generate a sample instance message.
The sample instance message that is generated contains the element and attribute
structure specified by the schema and generates data type–specific sample data.
You can populate this generated instance with realistic data to use in the validate
instance process specified earlier or provide it to partners as a sample of the
messages your processes may output.
You might find it useful to add a folder named Messages inside the BizTalk project into which
the generated instances and test messages can be saved. In this way, the test messages are
always accessible for future testing and schema modification.
Demonstration: Creating and Testing a Schema
In this demonstration, you will see how to create a new BizTalk schema by using BizTalk Editor.
You will then see how to generate an instance of the schema and test the schema against a
sample message.
Create a Schema
1. If it is not already started, start the bt10d-demos virtual machine.
2. In Microsoft Windows Explorer, navigate to C:\AllFiles\Democode\Module2\Demo,
and then double-click Demo.sln.
3. In Solution Explorer, right-click the Messaging project, point to Add, and then click
New Item.
4. In the Add New Item dialog box, in the center pane, click Schema.
5. Change the Name to PurchaseOrder.xsd, and then click Add.
6. In the left pane of BizTalk Editor, right-click the Root node, and then click Rename.
7. Rename the node to PO.
The Root node should always be renamed.
8. Right-click PO, point to Insert Schema Node, and then click Child Record.
9. Name the record Customer.
10. Right-click PO, point to Insert Schema Node, and then click Child Record.
11. Name the record Address.
12. Right-click PO, point to Insert Schema Node, and then click Child Record.
13. Name the record Items.
14. Right-click Customer, point to Insert Schema Node, and then click Child Field
Attribute.
15. Name the attribute FirstName.
16. Right-click Customer, point to Insert Schema Node, and then click Child Field
Attribute.
17. Name the attribute LastName.
18. Right-click Customer, point to Insert Schema Node, and then click Child Field
Attribute.
19. Name the attribute EmailAddress.
20. Right-click Customer, point to Insert Schema Node, and then click Child Field
Attribute.
21. Name the attribute PhoneNumber.
22. Right-click Address, point to Insert Schema Node, and then click Child Field
Element.
23. Name the element Street.
24. Right-click Address, point to Insert Schema Node, and then click Child Field
Element.
25. Name the element City.
26. Right-click Address, point to Insert Schema Node, and then click Child Field
Element.
27. Name the element State.
28. Right-click Address, point to Insert Schema Node, and then click Child Field
Element.
29. Name the element Zip.
30. Right-click Items, point to Insert Schema Node, and then click Child Record.
31. Name the record Item.
32. Right-click Item, point to Insert Schema Node, and then click Child Field Attribute.
33. Name the attribute SKU.
34. Right-click Item, point to Insert Schema Node, and then click Child Field Attribute.
35. Name the attribute Description.
36. Click the Item record.
37. In the Properties window, scroll to the bottom of the list, set the Max Occurs
property to *, and then set the Min Occurs property to 1.
Setting the Min Occurs and Max Occurs properties as shown will make this a
required node within the message (it must occur at least once but can repeat
infinitely).
Generate an Instance
1. In Solution Explorer, right-click PurchaseOrder.xsd, and then click Properties.
2. In the Properties window, click Output Instance Filename, and then click the ellipsis
button (…).
3. In the Select Output File dialog box, navigate to C:\AllFiles\DemoCode\Module2, in
the File name box, type PurchaseOrder-Gen, and then click Save.
4. In Solution Explorer, right-click PurchaseOrder.xsd, and then click Generate
Instance.
5. In Windows Explorer, navigate to C:\AllFiles\DemoCode\Module2, and then open
PurchaseOrder-Gen.xml.
Notice that each node has been populated with sample data.
6. Close Microsoft Internet Explorer.
Overview
The BizTalk Server toolset includes parsers and serializers for transforming data between EDI
or flat file formats and XML format. BizTalk Server 2010 solves the problem of creating
schemas for flat files by introducing a new tool called the Flat File Schema Wizard.
In this demonstration, you will see how to create a flat file schema from a sample message by
using the Flat File Schema Wizard. You will then see how to test a flat file schema.
12. On the Schema View page, ensure that PODetail is selected, and then click Next.
13. On the Select Document Data page, click Next.
14. On the Select Record Format page, ensure that By delimiter symbol is selected, and
then click Next.
15. On the Delimited Record page, in the Child delimiter list, click the comma (,) symbol,
and then click Next.
16. On the Child Elements page, set the Element Name, Element Type and Data Type
for each of the elements in the following table, and then click Next.
Element Name Element Type Data Type
OrderNumber Field attribute string
CustomerName Field attribute string
OrderDate Field attribute date
17. On the Schema View page, ensure that Address is selected, and then click Next.
18. On the Select Document Data page, click Next.
19. On the Select Record Format page, click By relative positions, and then click Next.
20. On the Positional Record page, click the position to the left of each of the elements.
You should have an arrow in each of the following positions: 0 (default), 24, 39, 41.
21. Click Next.
22. On the Child Elements page, set the Element Name and Element Type for each of
the elements in the following table, and then click Next.
Element Name Element Type
Street Field element
City Field element
State Field element
Postal Field element
23. On the Schema View page, ensure that Items is selected, and then click Next.
24. On the Select Document Data page, click Next.
25. On the Select Record Format page, ensure that By delimiter symbol is selected, and
then click Next.
26. On the Delimited Record page, using the drop-down list, change the Child Delimiter
to the comma (,) symbol, and then click the Record has a tag identifier check box.
27. In the Tag box, type Items, and then click Next.
28. In the error dialog box, click OK.
The Flat File Schema Wizard parses the message to verify that the tag identifier
is valid and case-sensitive. Because “Items” is not found within the record, an
error is displayed.
29. In the Tag box, type ITEMS, and then click Next.
30. On the Child Elements page, set the Element Name and Element Type for each of
the elements in the following table, and then click Next.
Element Name Element Type
Item Repeating Record
Items_Child2 Ignore
31. On the Schema View page, ensure that Item is selected, and then click Next.
32. On the Select Document Data page, click Next.
33. On the Select Record Format page, ensure that By delimiter symbol is selected, and
then click Next.
34. On the Delimited Record page, using the drop-down list, change the Child Delimiter
to the pipe (|) symbol, and then click the Record has a tag identifier check box.
35. In the Tag box, type ITEM, and then click Next.
36. On the Child Elements page, set the Element Types for each of the Elements in the
following table, and then click Next.
Element Name Element Type
ISBN Field element
Description Field element
Qty Field element
Price Field element
Overview
A BizTalk project can contain artifacts of many different kinds including schemas, maps,
orchestrations, and pipelines. Before using these artifacts in the messaging and
orchestration engines, the project needs to be built into an assembly.
Scenario
Each type of message processed by a BizTalk server application requires an XML schema that
defines the structure of the message. In this lab, you will create a BizTalk Server project that
will contain your schemas. Adventure Works has defined an internal sales order message
format for which you will create a schema. Next you will use the Flat File Schema Wizard to
create a schema that represents the format of the sales orders submitted by the Adventure
Works stores. Finally, you will generate a schema from a sample loan application message.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-01 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose
Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click Ask Me Later, and then click OK.
Exercise 1: Creating a New BizTalk Project
Overview
A BizTalk Server project contains BizTalk Server artifacts. In this exercise, you will create a
new Microsoft Visual Studio® 2010 solution and a new project that uses the BizTalk Server
Project template. This project will contain the schemas that you will create in the following
exercises.
Create a Blank Solution
Procedure List
1. On the Start menu, click All Programs, click Microsoft Visual Studio 2010, and then click
Microsoft Visual Studio 2010.
2. On the File menu, point to New, and then click Project.
3. In the New Project dialog box, in the Installed Templates pane, click BizTalk Projects,
click the Empty BizTalk Server Project icon, and then create a new project using the
information in the following table.
Property Value
Name Messaging
Location C:\AllFiles\LabFiles\Lab2
Create directory for solution <checked>
Solution Name AdvWorks
6. Click Next.
6. Click Next.
Define the Products Record
Procedure List
1. On the Schema View page, ensure that the Products record is selected, and then click
Next.
2. On the Select Document Data page, ensure that the third line (products) is selected
(excluding the ¶« characters), and then click Next.
3. On the Select Record Format page, verify that By delimiter symbol is selected, and then
click Next.
4. On the Delimited Record page, set the Child Delimiter to , (comma).
5. Check the Record has a tag identifier check box, in the Tag box, type PRODUCTS, and
then click Next.
6. On the Child Elements page, in the first row, change the Element Name to Product, and
change the Element Type to Repeating record. In the second row, change the Element
Type to Ignore, and then click Next.
6. Click Next.
7. Click Finish.
8. On the File menu, click Save All.
Module objective:
In this module, you will learn how to:
Create a BizTalk map and configure functoids to manipulate data within a map.
Overview
Using the Microsoft BizTalk Mapper, you define the relationship between an input and an
output schema using links and functoids. A link defines a direct data copy of a record or field.
Links may directly connect to items in the other schema, or they may form connections to
functoids. Functoids perform more complex data manipulations. This module discusses the
role played by Microsoft BizTalk maps in the BizTalk Server architecture and how to work
with maps and functoids.
Lesson 1: Creating a BizTalk Map
Lesson objective:
Lesson Overview
When building enterprise application–integration solutions, it is usually necessary to convert
between different message types. This could be done by simply converting all of the data
from a trading partner’s format for a purchase order to your company’s internal messaging
format. In other cases, only some of the information from an incoming message may be
required. For example, the information from an incoming purchase order may be used to
create a related invoice. Maps can be applied during run time by the BizTalk messaging
engine, or, as you will see in later modules, within an orchestration.
In this lesson, students will learn how maps are used by BizTalk and how to use the BizTalk
Mapper to create a map. Students will also learn how to use shortcuts to simplify the map
creation process.
What Is a BizTalk Map?
Describe the purpose of a map and explain the difference between transformation and
translation.
Terminology
Map. You create a map when you want to transform or translate data between
message formats.
BizTalk Mapper. A visual tool, hosted within Microsoft Visual Studio®, for
constructing BizTalk maps, which define data transformations.
Data transformation. The process of converting an XML document that conforms to
one schema into an XML document that conforms to another schema. A
transformation can simply change the formatting applied to the data, but more
often, data transformation results in some kind of structural change to the
document. For example, a system that automates purchase order processing will
typically transform purchase order records into one or more invoices.
BizTalk map. A file that defines the correspondence between the records and fields
in one schema and the records and fields in another schema. BizTalk maps are
implemented in XML Extensible Stylesheet Language Transformations (XSLT).
Extensible Stylesheet Language Transformations (XSLT). An industry-standard
specification defined by the World Wide Web Consortium (WC3) for expressing
transformations between two documents. The XSLT generated by BizTalk is fully
W3C compliant.
Data translation. A special case of data transformation that involves changing the
format of an instance message, typically from non-XML (EDI or flat-file) to XML
format, or vice versa. For example, if your internal processes utilize XML data, but
your trading partner needs to receive messages in a flat-file format, you can perform
the necessary translation before you send such messages to the trading partner.
Data translation can be especially helpful in solving enterprise application
integration problems by rendering a given type of message into alternative formats
required by existing systems.
Functoid. An executable module that performs a specific calculation or data
manipulation. Functoids provide BizTalk map developers with the ability to create
richer transformations than what is provided by XSLT on its own.
Use Cases
In addition to simple value mapping, the transformation process can include such operations
as:
Flattening records received in a message that has a hierarchical format to one with a
flatter design.
Averaging data from multiple input nodes and sending the output to a single field in
the destination message.
Applying mathematical functions on values in the source message and then writing
the result to the destination message.
Concatenating multiple elements from the source message into a single field in the
destination message.
Looking up a value from the source message in a database or an in-memory table
and extracting new values to be written to the destination message.
Creating a Map by Using the BizTalk Mapper
Explain how the BizTalk Mapper works to create maps and how maps are compiled as XSLT files.
Mapper Improvements
With the release of Microsoft BizTalk Server 2010, the BizTalk Mapper has been improved
with a new user interface that eases development of large. The new BizTalk Mapper
improves productivity by adding cut, copy, paste, move and undo functions and improved
support for search and readability. The new search feature highlights source and destination
schema nodes, and functoids containing text that match the search criteria.
Readability improvements include new pan and zoom features, and automatic panning that
brings all of the relevant links and functoids in to view when a user clicks on schema node.
The new mapper also hides or dims background schema nodes, links and functoids that are
not relevant to the user’s current selection.
Use the BizTalk Mapper to automate the process of linking nodes within a map.
Overview
The BizTalk Mapper provides a solution for a variety of mapping scenarios, ranging from
simple parent-child tree-type operations to detailed operations that are complex and involve
looping records and hierarchies. Almost all mapping scenarios can fit into one of two
categories: basic mapping and complex mapping.
Basic Mapping
Basic mapping is the most common type of mapping. It involves copying a value from an
element or attribute that occurs once in an input instance message to an element or
attribute that occurs once in an output instance message. In the corresponding source and
destination schemas, the record or field node that corresponds to the element or attribute
and all of its ancestors will be specified such that the element or attribute appears in the
instance messages once and only once.
Complex Mapping
Complex mapping involves records or fields that can occur multiple times for a single
instance of the Record or Field Element node in the schema tree. This type of variable count
mapping is called looping. You create this type of mapping by linking a field in a looping
record in the source schema to a field in a looping record in the destination schema. The
number of corresponding elements in an input instance message will then dictate the
number of elements created in the output instance message. Another type of complex
mapping occurs when a record or element occurs only once in the source schema but must
be mapped to repeating nodes in the destination schema.
Validating, Testing and Debugging a Map
Validating a Map
Before a map is deployed, it should be tested to ensure that the resulting message contains
the desired results. The BizTalk Mapper provides the tools for validating a map and testing a
map with sample data, much as can be done with schemas.
In BizTalk Server 2010, the mapping of small messages occurs in memory. For performance
reasons, by default, mapping (which is a very memory-intensive operation) does not
perform data validation when executed in a pipeline. However, you can create a custom
pipeline and use the XML validator component to perform validation before and after
mapping within the pipeline. A new feature in BizTalk Server 2010 enables the ability to
perform large message mapping, which uses disk cache in addition to memory.
To validate a map, simply right-click the map in Solution Explorer, and then click Validate
Map. The Output pane will display a link with an .xsl extension that displays the actual XSTL
output generated by the map. This can be useful for troubleshooting execution problems
with the map.
Testing a Map
Before you can test a map, you need to specify the type and location of an instance message
to be used for testing. Several properties need to be configured, which are set in the .NET
properties for the map. The .NET properties, as distinguished from the BizTalk properties,
are accessed by right-clicking the map in Solution Explorer, and then clicking Properties.
Validate TestMap Input. Specifies that the input message should be validated.
Validate TestMap Output. Specifies that the output message should be validated.
TestMap Input Instance. This is the message that you will use as the source message
instance for the map. This instance should be validated using the schema validation
steps described in Module 2, “Creating Schemas.”
TestMap Input. This specifies the format of the test message (XML, Native, or
Generated Instance). Native specifies that Visual Studio must convert the input file
from flat file format to XML before executing the map.
TestMap Output. This specifies the format of the test message (XML or Native).
TestMap Output Instance. Specifies the file location for the message to be written
to. If the file exists in the same location, it will be overwritten.
After configuring the test properties, right-click the map in Solution Explorer, and then click
Test Map. A link to the input and output message will be shown.
Demonstration: Creating and Testing a BizTalk Map
Learn how to create a map by using the BizTalk Mapper tool and how to create simple and
automated links. You will then see how to test and validate a map.
Lesson objective:
Lesson Overview
Whereas linking provides for copying values from one message to another, functoids allow
the manipulation of the data contained in the message. There are approximately 70
functoids that provide simple mathematical functions, string manipulation and date and
time insertion, and complex scientific calculations.
Data Manipulation with Functoids
About Functoids
A functoid is an executable module that performs a specific calculation or data
manipulation. A functoid can be used graphically when constructing BizTalk Server maps to
provide the basis for richer transformations than what is provided by XSLT on its own.
The BizTalk functoids allow you to extend the functionality of the map to perform a variety
of operations on data as the data is being transformed from the source message to the
destination message.
The most common use of a functoid is to perform numeric calculations, such as summing the
total number of products ordered. Functoids that can have zero or more inbound links can
be chained to provide additional functionality.
Basic Functoids
There are over 70 predefined functoids included with the BizTalk Mapper. These functoids
can perform such operations as calculations including multiplication and division, adding the
current date and time to an output instance message, and concatenating multiple strings
together to form one node in the destination side of the map. The basic functoid categories
for predefined functoids include:
Conversion. Use the Conversion functoids to perform conversions between numeric
bases, such as from hexadecimal to decimal.
Cumulative. Use the Cumulative functoids to perform accumulation operations for
values that occur multiple times within an instance message.
Date and Time. Use the Date and Time functoids to introduce the current date,
time, or both into the message or to add days to a specified date, in output data.
This enables you to insert the processed date (and time) into a message or calculate
an anticipated ship date.
Logical. Use the Logical functoids either to perform specific logical tests at run time
or determine whether output instance data is created at run time. Returns a string
(True or False).
Mathematical. Use the Mathematical functoids to perform calculations by using
specific values (arguments) in a specified order or structure.
Scientific. Use the Scientific functoids to convert a numeric value to a scientific
value. For example, the Cosine functoid takes a value in radians from a field or
record and returns the value of the cosine.
String. Use the String functoids to manipulate data strings by using string functions.
The String Concatenate functoid combines two or more inputs (nodes, constants, or
other functoids) and builds a string. The String Find functoid finds one text string
within another text string and returns the position of the first character of the found
string.
Adding Functoids to a Map
Adding Functoids
To add functoids to a map, drag a functoid from the Toolbox to the map grid, link a node in
the source schema to the functoid, and then link the functoid to a node in the target
schema. You can also chain functoids to provide a more complex result. For example, a
multiplication functoid could obtain the product of Quantity times Price for each instance of
a product in an inbound message and then add the total to a node in a destination message.
Note: Functoid linking works only from left to right. That is, you cannot link from a functoid
back to a source schema node nor to another functoid that is located to the left of the
source functoid; you can link only from the source schema node to the functoid.
Functoid Properties
The properties of each functoid are displayed in the Visual Studio Properties window when
that functoid is selected in the map zone layer. All functoid properties are categorized as
general properties and are listed in the order in which they appear in the Properties window,
regardless of whether they are being displayed alphabetically or by category.
Functoid properties can be categorized as follows:
Label. The Label property available for links and functoids provides a mechanism for
assigning a descriptive name, which can be extremely useful in map maintenance.
Input Parameters. The Input Parameters property provides access to the Configure
Functoid dialog box, which provides access to all of the functoid properties,
including inputs, label, comments and a functoid description which explains the
usage of the functoid, and lists required inputs.
Name, Help, Maximum Input Parameters, and Minimum Input Parameters. These
properties are always read-only and are informational in nature.
Note: For more information, see the Functoid Reference, provided in BizTalk Server 2010
Help.
Using Map Grid Pages
Map Pages
Maps for many types of business documents can require large numbers of links and
functoids, rendering the map grid complex and difficult to understand. For improved
readability, you can create separate map grid pages to isolate logical groupings of mapping
operations into separate pages. You can then view and work with each grouping individually.
You can add new pages, rename pages, delete pages, reorder pages, and move between and
within them. Map execution is non-deterministic with map pages. In other words, the
mapping will not occur in a top-down or bottom-up order. Similarly, functoids on page 1 are
not necessarily executed before the ones on page 2.
Note: All functoids that are connected together must reside on the same page. Also, if you
delete a grid page, you delete all the links and functoids on that page. The new BizTalk 2010
Mapper allows you to cut/copy and paste links and functoids from one map page to another.
Demonstration: Adding Functoids to a Map
Learn how to add a map page and functoids to a map. You will then see how to test the map to
verify that the functoids are behaving properly.
Lesson objective:
Lesson Overview
Advanced functoids allow more complex types of mapping. For example, you can look up
information in a database or you can call a custom .NET component to accomplish business-
specific tasks.
Using Advanced Functoids
Overview
Advanced functoids allow more complex types of mapping. Advanced functoids allow you to:
Manage looping records. The Index, Iteration, Looping, Record Count, Table
Extractor, and Table Looping functoids are used in various combinations to achieve
appropriate results when the input instance message contains sections that have an
unpredictable number of repeating elements.
Create conditional mapping. The Value Mapping and Value Mapping (Flattening)
functoids are used to provide conditional mapping from an input instance message
to an output instance message.
Define arbitrary scripting. The Scripting functoid is used to run arbitrary script or
compiled code when an input instance message is being mapped to an output
instance message.
Copy entire elements of data. The Mass Copy functoid, which implements the XSLT
<xsl:copy select=”..” /> function, can be used to copy an entire record, including its
subelements, to an arbitrary depth, from an input message to an output message.
Using Looping Functoids
Looping Functoids
Looping functoids are used when the input instance message contains sections that have a
number of repeating elements that need to be mapped to the destination message.
There are several functoids that allow you to loop through records:
Looping functoid. This functoid is used to combine multiple records or fields in the
source schema into a single record in the destination schema. For example, if you
have an unknown number of line items in an inbound message, and you want to set
a grand total in the destination message, you use the looping functoid. There is no
limit to the number of inputs a looping functoid can accept, but only links from the
source schema are allowed as input parameters.
Index functoid. This functoid enables you to select a specific value or set of values in
a source message to be copied to the destination message. This functoid must have
at least one input parameter that is a link from a record or field in the source
schema. The second and succeeding input parameters specify the record. See Help
for more information.
Record Count functoid. This functoid is used to count the number of records in the
input instance message. This functoid takes one input parameter that is the link
from a looping record in the source schema. The output of this functoid is the count
of the looping record in the source instance message. For example, you may need to
create a purchase order summary message that has only the total number of unique
items purchased as indicated in the PO details. This functoid would count the
number of line items in the purchase order details and copy the total results to the
purchase order summary destination message.
Table-Driven Functoids
In a map, you can use a table looping functoid in conjunction with one or more table
extractor functoids when you need an input instance structure to produce multiple output
instance structures. For example, if you have a single address in your source schema that
needs to be entered in both the BillTo and ShipTo address along with a node that indicates
the address type in the destination message, you can use the Table Looping and the Table
Extractor functoids to create these records in the destination schema.
Table Looping functoid. This functoid enables you to create a table of output values
to use in creating the output instance message. The data in the table can consist of
links and constants. This functoid must have at least two input parameters. The first
input parameter configures how many times the table will loop, and the second
input parameter determines how many columns are in the table. Additional
parameters define possible cell values for the table.
Table Extractor functoid. This functoid is used to output the data associated with a
specified column for each row of the table looping grid of the Table Looping
functoid. This functoid must have two input parameters. The first parameter is an
output link from a Table Looping functoid, and the second parameter is the column
number of the table looping grid from which this functoid is meant to retrieve data.
You must use the Table Extractor functoid in conjunction with the Table Looping
functoid.
Using Database Functoids
Overview
The Scripting functoid is used to run arbitrary script or compiled code when an input
instance message is being mapped to an output instance message. The script or compiled
code can be created so that it accepts input parameters from the source instance message,
configured constant values, the output of another functoid, or some combination thereof.
You can call a .NET assembly at run time by using the Scripting functoid. For example, if you
need to calculate the tax for an invoice, you can create a .NET assembly by using Visual
Studio and then calling a method in the assembly to calculate the tax. This can be very useful
when you are performing calculations multiple times on multiple systems and want to
minimize the amount of code to write.
BizTalk Server 2010 supports the following languages and technologies for the Scripting
functoid:
Microsoft Visual Basic®
C#
JScript
Extensible Stylesheet Language Transformations (XSLT) and XSLT Call Templates.
Occasionally it may be easier or more manageable to write your own XSLT to map multiple
nodes or to perform complex computations. For example, a couple lines of well-written XSLT
may replace several functoids.
Any external assemblies called by the Scripting functoid must be located in the global
assembly cache (GAC) of the BizTalk server. By placing the assembly in the GAC, support for
multiple versions of the assembly is provided.
Demonstration: Configuring Advanced Functoids
Scenario
Maps are typically used to convert messages from one format to another. In this lab, you will
create a map that is used to transform data from the flat file format generated by the
Adventure Works stores to the internal sales order format used by the sales order
application. You will configure the map with several functoids to manipulate and modify the
message data. You will also configure the map to retrieve information from a Microsoft® SQL
Server™ database and insert it into the destination message.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-01 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose
Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click Ask Me Later, and then click OK.
Exercise 1: Creating a Map
Overview
A BizTalk map is used to convert message data between XML formats. In this exercise, you
will use the BizTalk Mapper to create a map that transforms data from the SalesOrder_FF
schema to the SalesOrder schema format. This map will contain links that associate the data
fields between these two schemas.
Multiply Two Fields from the Source Schema to a Single Field in the Destination
Schema
Procedure List
1. From the Mathematical Functoids section of the Toolbox, drag the Multiplication
functoid on to the Map grid.
2. From the Cumulative Functoids section of the Toolbox, drag the Cumulative Sum
functoid on to the Map grid.
Because functoids must link left to right, you must drag the Cumulative Sum
functoid to the right of the Multiplication functoid.
3. In the Source Schema, click the Quantity field, and then drag a link to the
Multiplication functoid in the Map grid.
4. In the Source Schema, click the PriceEach field, and then drag a link to the
Multiplication functoid in the Map grid.
5. In the Map grid, click the Multiplication functoid, and then drag a link to the
ExtendedPrice node in the Destination Schema.
6. In the Map grid, click the Multiplication functoid, and then drag a link to the
Cumulative Sum functoid.
7. In the Map grid, click the Cumulative Sum functoid, and then drag a link to the
Order Total node in the Destination Schema.
Each one of these parameters specifies the column from the database from
which the data will be mapped. These functoids will look up the CUSTID field in
the source schema in the AdvWorks database. If the CUSTID exists, the
associated values in the ADDRESS, CITY, REGION, and ZIP columns will be
mapped to the Street, City, State, and PostalCode fields in the destination
schema.
Module objective:
In this module, you will learn:
How Microsoft BizTalk Server applications are deployed, and how to use the tools provided by
BizTalk Server to manage the applications after deployment.
Overview
Microsoft BizTalk Server 2010 includes features that simplify the management and
deployment of BizTalk applications. BizTalk provides an application container for the items in
a business solution. The items that can be grouped as an application include orchestrations,
schemas, maps, pipelines, and Microsoft .NET assemblies. You can manage, modify, deploy,
and install all of the items in an application as a single entity.
Lesson 1: Deploying a BizTalk Application
Lesson objective:
Describe how BizTalk deployment works, and the steps required to deploy a BizTalk application.
Lesson Overview
This lesson provides an overview of BizTalk application deployment and the steps required
to deploy a BizTalk assembly.
A BizTalk Server assembly contains BizTalk artifacts, such as schemas, maps, and pipelines,
which are used for processing and transforming messages through BizTalk Server. For these
artifacts to be available to other processes and components of BizTalk Server, the BizTalk
Server assembly must be deployed first.
Deploying and managing BizTalk artifacts, such as schemas, maps, and orchestrations, can
become cumbersome as the number of artifacts and assemblies increase. To address the
management and deployment issues of large scale integrations, BizTalk Server 2010
supports the concept of a BizTalk application. BizTalk applications allow developers and
administrators to manage, package, and deploy multiple BizTalk artifacts to other physical
environments much more easily.
How Deployment Works
Non-BizTalk Assemblies
Any assemblies in the BizTalk solution that do not contain BizTalk artifacts need to be
installed only in the GAC. A non-BizTalk assembly might contain items such as HTML files,
XML files, forms, Microsoft .NET helper classes, or ASPX pages.
What Is a BizTalk Application?
Overview
In BizTalk Server 2010, an application is a logical grouping of all the compiled BizTalk artifacts
(schemas, maps, pipelines, and orchestrations), messaging components (receive ports,
receive locations, and send ports), and other related items, such as business rule policies
that comprise an integrated business process.
The BizTalk Server administration and monitoring tools take advantage of this concept,
allowing IT administrators to work more efficiently by managing and configuring BizTalk
solutions at the application level, rather than being required to work at the individual
artifact level.
A BizTalk application does not define which Windows process hosts its artifacts or .DLLs, it is
simply a logical grouping of artifacts and .DLLs that are deployed and operate together at
run-time. The BizTalk Administration Console, for example, allows you to start and stop all
of the artifacts within a given application by simply commanding the BizTalk application to
start and stop, rather than always requiring you to start and stop each artifact individually.
As the number of complex applications increases, they can be individually managed in a
simple and intuitive manner.
Default Application
When BizTalk Server 2010 is configured following installation, a default application named
“BizTalk Application 1” is automatically created. You can change or rename the default
application.
Artifacts are automatically added to the default application in the following situations:
When you deploy an assembly from Microsoft Visual Studio® 2010 into BizTalk
Server without specifying an application name.
When you use BTSTask to add an artifact to an application without specifying an
application name.
Application Deployment Steps
Introduction
Each assembly in your project must have a strong name to deploy successfully. A strong
name consists of the assembly’s identity (text name, version number, and culture
information if available), plus a public key and digital signature. When you sign an assembly
with a strong name, you ensure that the name is globally unique. Referencing a strong-
name-signed assembly gives you certain benefits, such as versioning and naming protection,
and strong-name-signed assemblies can reference only other strong-named assemblies.
Strong names satisfy the following requirements:
Uniqueness. Strong names guarantee name uniqueness by relying on unique key
pairs. No one can generate the same assembly name that you generate because any
assembly name generated by using one private key has a different name than any
assembly generated by using another private key.
Versioning. Strong names protect the version lineage of an assembly. A strong name
can ensure that no one can produce a subsequent version of your assembly. Users
can be sure that the assembly version that they are loading originates from the same
publisher that created the original version of the built application.
Integrity. Strong names provide a strong integrity check. Passing the Microsoft .NET
Framework security checks guarantees that the contents of the assembly have not
been changed since it was built. However, strong names do not imply the level of
trust provided by a digital signature and supporting certificate.
Configuring BizTalk Deployment Properties
Deployment Properties
When you are ready to deploy your application, you set deployment properties for the
Visual Studio project. Some of the properties are optional depending on how you plan to
deploy the application.
Server. This is the name of the Microsoft SQL Server™ instance that hosts the BizTalk
Management database on the local computer. In a single-computer installation, this
is usually the name of the local computer.
Configuration Database. This is the name of the BizTalk Configuration database for
the BizTalk group to which you will be deploying your assembly, for example,
BizTalkMgmtDb.
Application Name. This is the name of the BizTalk application to which you will
deploy the assemblies in this project. If the application already exists, the assemblies
will be added to it when you deploy the project. If the application does not exist, the
application will be created in the BizTalk management database specified earlier. If
this field is blank, the assemblies will be deployed to the default BizTalk application
in the current group, “BizTalk Application 1,” by default. Names that include spaces
must be enclosed by double quotation marks (“”).
Redeploy. (True or False) Setting this option to True (the default) enables you to
redeploy the BizTalk assemblies without changing the version number.
Install to Global Assembly Cache. (True or False) Setting this option to True (the
default) installs the assemblies to the Global Assembly Cache (GAC) on the computer
specified in the Server property. Set this property to False only if you plan to use
other tools for this installation, such as gacutil.
BizTalk Application Deployment Tools
Introduction
You can use any of several methods to deploy a BizTalk Server assembly to the BizTalk
management database. These methods include tools for use by developers and IT
professionals.
Visual Studio
Using Visual Studio, you can deploy or redeploy the assemblies in your BizTalk projects. This
method is most useful to developers when deploying an application to a test environment.
From within Visual Studio 2010, you can either deploy each assembly in your solution
separately or deploy all assemblies in a solution at the same time by deploying the entire
solution. The redeploy option allows you to deploy a new assembly with the same name and
strong name key without un-deploying the original assembly.
In this demonstration, you will see how to assign a strong name and application name to a
project. You will then see how to build and deploy the project.
Lesson objective:
Describe the application management tools available to BizTalk developers.
Lesson Overview
After an application is deployed to the BizTalk Server runtime environment, developers and
administrators will need to manage and maintain the application. BizTalk Server provides a
number of management features that are available through the BizTalk Administration
Console, and also through a command-line tool named BTSTask.exe.
Managing Apps with the BizTalk Administration Console
Describe the application management features provided by the BizTalk Administration Console.
Applications
• Import and export applications and binding files
• Configure applications
• Start and stop applications
• Add resources to applications
Orchestrations
• Bind orchestrations to send and receive ports and host, or remove these bindings
from the orchestration.
• Enlist and unenlist orchestrations.
• Start or stop orchestrations.
Send ports and Send port groups
• Create and configure send ports and send port groups .
• Enlist and unlist send ports and send port groups .
• Start and stop send ports and send port groups .
Policies
• Import and export Business Rule Engine policies
• Assign a policies applications, and remove a policies from applications
• Publish, deploy and un-deploy a policies
Schemas
• View the schemas for an application
• Remove schemas from an Application
Maps
• View the maps for an Application
• Remove maps from an Application
Pipelines
• View the pipelines for an application
Resources
Resources are any application files that should be included when an application is migrated
to another server. Resources can be scripts, BizTalk assemblies, pre- and post-processing
deployment scripts, .NET assemblies, COM components, certificates, ad-hoc files, BAM
definitions, binding files and virtual directories. The BizTalk Administration Console provides
features to perform the following tasks.
• Add and remove resources
• Modify deployment information of a resource
• Move a resource to another application
Exporting and Importing a Binding File
Exporting Bindings
You can export bindings for a BizTalk group, assembly, or application to an XML file. A
binding file contains information about hosts, send ports, send port groups, receive ports,
receive locations, parties and their associations with BizTalk assembly orchestrations,
pipelines, maps, and schemas. Binding files are usually specific to a particular version of an
assembly, so be careful if a version of an assembly has been updated. You may need to
update the binding file with the new version, or you may need to create a new binding file,
depending on what has changed since the version has been updated. You can then import
the bindings from the XML file into another group or application. Importing bindings
overwrites any existing bindings in the group or application. You can also add bindings to an
application.
Migrating Applications Using MSI Packages
Explain how applications are deployed by using Microsoft Windows Installer (MSI) packages.
Introduction
BizTalk Server allows entire solutions to be packaged, using the Microsoft Windows Installer
technology, into MSI package files.
MSI Packages
The MSI package contains all of the binaries and configuration information (bindings)
needed to install the application on another system. After it is installed, the MSI package
creates entries in the Add or Remove Programs list on the computer running BizTalk Server.
This allows administrators to manage BizTalk applications in the same way as other
applications running on the computer. Using an MSI package to install a BizTalk Server
application is beneficial for developers because they can control what is included and
deployed with the MSI package, and developers can easily hand off MSI packages to
administrators. MSI packages provide administrators with a GUI interface or the ability to
install in “quiet mode.” Because the application is then registered in the Add or Remove
programs list, if an application needs to be removed, it can be done easily by an
administrator.
Exporting a BizTalk application generates a Windows Installer (MSI) file that contains the
application and some or all of its artifacts. When you export an application, you can select
which of its artifacts to export. The default option is to select all of the application’s artifacts,
but you can select a subset of them. You can later import the MSI file into another BizTalk
group to add the artifacts to an existing application in the new group, update the artifacts in
an existing application, or create a new application in the group that contains the artifacts
being imported.
You can import BizTalk applications, bindings, and policies into a BizTalk group. Exporting an
application creates an MSI file that you can then use to import the application’s artifacts into
an application in a different BizTalk group. If the application that you specify for the import
does not already exist in the group, the application is created. In addition, the application’s
artifacts are registered and their data stored in the BizTalk databases of the group.
Since the application’s assemblies must be installed in the GAC on any BizTalk server that
will host the application, you must run the MSI on each server in the BizTalk group to
complete the import.
Managing Applications from a Command Prompt
Using BTSTask
The BizTalk Server command-line tool, BTSTask.exe, supports the application deployment
and management features of BizTalk Server. It enables you to perform many of the same
tasks that you can perform by using the BizTalk Server Administration Console. Using
BTSTask.exe, you can:
Add a BizTalk application to the BizTalk Configuration database.
Add an artifact, such as an orchestration or a schema, to an application.
Export an application to an MSI file, allowing you to then deploy the application to
another physical computer.
Export binding information to a file, thus saving current binding information for
exporting to another physical computer.
Import an application from an MSI file.
Import binding information from a file, such as from a previously created XML
binding file.
List the artifacts included in an application, such as the schemas, maps, and
orchestrations included in a specific application.
List all applications in the BizTalk Configuration database for the BizTalk group.
List the resources in an MSI file, such as binding files, BizTalk artifacts, and
messaging components such as receive and send ports.
List all of the artifact types supported by BizTalk Server.
Remove an application from the BizTalk Configuration database and the BizTalk
Server Administration Console.
Remove an artifact from an application, such as a schema or a map.
Remove an application from the specified computer.
Managing Project Versioning
Project Versioning
With prior versions of BizTalk, the process of versioning a BizTalk Server application was
cumbersome. Because an assembly cannot be changed after it has been deployed to the
BizTalk Configuration database or to the GAC, you must be careful when deciding which
BizTalk artifacts must reside in each assembly. If you put each artifact in its own assembly,
management can become difficult because you may end up with dozens or even hundreds
of different assemblies. However, if you put too many artifacts into a single assembly and
then need to change just one artifact, such as a map or an orchestration, you will have to
redeploy and reversion the entire assembly even though only one or two artifacts have been
changed.
A good guideline to use when versioning BizTalk assemblies is to group BizTalk artifacts
together that will be versioned together. For example, if you have a map that depends on a
certain schema that might change over time, group the schema and the map together in the
same assembly. If an orchestration also depends on this map, consider putting the
orchestration in the same assembly as well.
Since BizTalk Server determines which schema a message is an instance of using the
combination of the root node name and target namespace of the schema and message, you
cannot have multiple schema versions deployed that have identical root node names and
target namespaces. For this reason, you will have to change the target namespace of each
schema deployed.
Some other things to consider when versioning assemblies:
Verify that an existing version of the assembly is not already deployed. If there is an
existing version, compare its version number with the version number of the new
assembly. If the numbers are identical, the deploy operation will fail. If the version
numbers are different, the assembly will deploy. The two deployed assemblies will
be recognized as separate entities.
Apply the binding file (if specified in the command) to the ports in the deployed
orchestrations, and then install the assembly in the GAC on the local computer.
Binding files contain the assembly name, version, public key token, and the assembly
culture, so if a version of an assembly changes, you may need to change the binding
file to reflect the new version. Or you can always create a new binding file by using
the BizTalk Server Administration Console that will reflect the newest version
information.
Before you remove a BizTalk assembly from the management database, you must
ensure that any orchestrations used in the assembly are not enlisted to receive data.
If any orchestration is enlisted, the removal will fail. Using the BTSTask command-
line tool with the RemoveResource option will remove the assembly from the
BizTalk Management database and, optionally, from the GAC on the local computer.
Demonstration: Managing the Adventure Works Application
Learn to use a binding file, export an application, and how to use BTSTask to remove an
application.
Scenario
All assemblies used by BizTalk Server applications (including non-BizTalk .NET assemblies)
must be in the Global Assembly Cache (GAC) of the computer(s) running BizTalk Server.
Additionally, all BizTalk assemblies must be registered in the BizTalk configuration database.
In this lab, you will prepare a BizTalk assembly to be deployed by assigning a strong name
key an application’s projects. You will then deploy the assembly, and use the BizTalk Server
Administration Console to import a binding file to complete the configuration. You will then
export the new, configured application to an MSI file. You will move all of the application’s
resources to a new application, export it with BTSTask.exe, and then delete the application
from the BizTalk Server Configuration database.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-04 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose
Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click Ask Me Later, and then click OK.
Delete an Application
Procedure List
3. In the command prompt window, type the following command, and then press
ENTER.
4. In the command prompt window, type BTSTask ListApps, and then press ENTER.
Notice that the ExtremeAdventureWorks application has been removed.
5. Close all open windows.
Module 5: Routing BizTalk Messages
Time estimated: 135 minutes
Module objective:
In this module, you will learn the purpose and scope of the Microsoft BizTalk Server publish and
subscribe messaging models and how to configure BizTalk message routing.
Overview
Microsoft BizTalk Server provides a mechanism for routing, processing, and sending
messages between business processes. Content-based routing (CBR) is a method of routing
messages based on the context and/or content of an incoming message. BizTalk provides
two methods of monitoring and tracking message activity, which enables developers,
administrators, and business users to diagnose messaging problems. This module shows you
how to enable message routing and use BizTalk tools to monitor live and archived message
activity.
Lesson 1: Introduction to Message Routing
Lesson objective:
Overview
The BizTalk messaging system consists of components such as receive locations, receive and
send ports, pipelines, and the MessageBox database. The component that is responsible for
the actual message routing process is referred to as the messaging engine. This lesson
provides an overview of how the BizTalk messaging engine works to process messages and
how message routing is enabled.
The Publish and Subscribe Architecture
Describe the publish and subscribe routing model used by BizTalk Server for routing and
processing documents.
Publication
Publication is the process by which messages are placed in the MessageBox database. The
principal publishing component in BizTalk Server is the receive port, which receives and
processes messages into the database. Orchestrations also publish messages as they are
sent from the orchestration to the MessageBox database for further routing. Properties
defining which messages will be routed can be promoted as the message is being processed
through receive pipelines and can also be specified in the business process (orchestration)
itself. Each of these processes will be detailed in upcoming modules.
Subscriptions
Subscriptions are criteria on which message routing is determined. Orchestrations, send
ports, and send port groups can each subscribe to messages. Each subscription allows the
subscriber to initiate or continue the processing of a message. Subscriptions are managed by
the MessageBox database.
When a message meets the specifications of a subscription, the message is passed from the
MessageBox database to the subscriber. If multiple subscribers exist for a given message,
each gets a copy of the message.
The preceding illustration outlines the steps in the publish/subscribe model, as follows:
1. Subscriptions are created for each subscriber (send port, send port group, or
orchestration) by configuring a filter expression. For example, this expression could
be for all purchase order messages with totals over $10,000.
2. A message is received, processed, and published to the BizTalk MessageBox
database. Messages can be received through a variety of different adapters,
including File, FTP, and HTTP.
3. Subscriptions, which are maintained by the MessageBox database, are evaluated to
determine which subscriber(s) should receive a copy of the message.
4. Each subscriber will receive a copy of the message (with a unique message ID). The
message stays in the MessageBox database until all subscribers have received and
successfully processed the message.
At each stage in the processing, data necessary for tracking messages is written to a
separate database (the tracking database), where it resides until deleted by administrative
action.
What Is the MessageBox Database?
Explain the purpose of the MessageBox database and how message subscriptions work.
MessageBox Database
The MessageBox database stores messages and message properties, and it maintains
message subscriptions. The messaging engine delivers the messages from the database to
subscribers. The MessageBox databases also store the queues and state tables for each
BizTalk host.
Messages are immutable once they arrive at the MessageBox database, but beforehand,
messages can be manipulated in a variety of ways, including validating the message against a
known schema, promoting specific nodes to be used in message routing, decrypting a
message, or transforming a message by using a BizTalk map. Each of these processes is
addressed in other modules in this course.
Message Routing
A typical BizTalk Server business process involves receiving, processing, and sending
messages. At times, you may receive messages (such as partner-to-partner correspondence)
that do not require intensive processing in an orchestration, and that could therefore
benefit from a simpler solution. The BizTalk content-based message routing model provides
great flexibility in the way that messages are handled. For example, two incoming messages
of the same type can be processed differently based on a customer name or a total order
amount.
Scenario
One common scenario that requires message routing is when a receive port is configured to
receive a single message type, as in the case of a purchase order (PO). Assume that you have
created a send port to an ERP system and that you have configured a map that needs to
receive a copy of all POs. You can configure the filter on the send port to process all
messages received through the specified receive port. Additional send ports and filter
expressions could be added to route messages based on other properties.
Examples
The preceding illustration shows three send ports, each with a different filter for content-
based routing. All PO messages in which the CustomerName field contains Contoso are to be
routed to send port A. All messages with the Price field greater than 1000 are routed to send
port B. All messages with a quantity greater then 500 and in which the Price is less then
1000 (which may represent an error condition) are routed to send port C. A message is
routed to all send ports for which it meets the filter criteria. Therefore, if a PO is received
from Contoso, in which the Price is over 1000, a copy of the message is routed to both send
ports A and B but not send port C.
What Is a Port?
Describe how BizTalk Server uses receive ports and locations to receive messages and how it
uses send ports to send messages.
Ports
Ports specify how messages are sent and received inside BizTalk Server, as well as between
BizTalk Server and external processes. Each port has a direction, a transport type, and a
binding, which together determine the direction of communication (one-way or two-way),
the pattern of communication (one-way or request-response), the location to or from which
the message is sent or received, and how the communication takes place. A port’s binding
may refer to the physical location of a read or write, the pipeline used for message
processing, or an orchestration.
A port must be associated with:
A Universal Resource Identifier (URI—a physical location).
A transport (examples are File, HTTP, and BizTalk Message Queuing).
A port may be associated with:
A send pipeline, to prepare a message for sending. For example, pipelines can be used
for assembling, encrypting, compressing, or performing some other action on a
message.
A receive pipeline, to prepare a received message for processing. For example, receive
pipelines can be used for disassembling, decrypting, or decompressing a message.
A map, to transform messages from one type to another.
Note: Pipelines are covered in greater detail in Module 6, “Creating Pipelines.”
BizTalk Message Flow
Overview
The two main functions of BizTalk Server 2010—BizTalk Orchestration and BizTalk
Messaging—form the underlying architecture that enables you to integrate and exchange
messages with the many types of external systems and applications that exist in your
organization and in those of your trading partners.
The BizTalk Messaging engine is responsible for performing the following tasks:
Receiving inbound documents through receive ports, which may include the use of a
map for message translation or transformation.
Parsing inbound documents to determine their specific format in a pipeline. Receive
pipelines can also perform data validation to ensure that the message being received is
valid compared with a known schema.
Extracting key identifiers and identifying applicable routing rules. Filters can be placed
on send ports to route documents based on the contents of a message.
Delivering documents to their respective destinations. Some of the options available to
route documents include file drops, databases, or other business processes.
Tracking documents. The BizTalk Group Hub allows developers, IT professionals, and
business analysts to monitor message activity and troubleshoot errors as they arise.
What Is Property Promotion?
Promoted Properties
Property promotion enables BizTalk messaging services to route messages based on the
context and content of the message. You want to promote properties only when required
for message routing, message correlation (a special form of message routing, which will be
covered in Module 9, “Automating Business Processes”), or property-tracking. Excessive
property promotion can adversely affect BizTalk Server performance.
Demonstration: Promoting a Property
Learn how to promote a schema property by using the Quick Promotion option in the BizTalk
Schema Editor.
Promote Properties
1. In Windows Explorer, navigate to C:\AllFiles\DemoCode\Module5\Demo, and then
double-click Demo.sln.
The following demonstration is not dependent upon completion of the previous
demonstrations. This solution provides artifacts and file paths that differ from
those used in the previous demonstrations.
2. In Solution Explorer, double-click PurchaseOrder.xsd to open the schema.
3. Right-click the <Schema> node, and then click Expand Schema Node.
4. Right-click State, point to Promote, and then click Quick Promotion.
5. In the Microsoft Visual Studio dialog box, click OK.
This is a notice that Visual Studio will create a property schema that will contain
this promoted property. In Solution Explorer, notice that the schema named
PropertySchema has been added to the project.
6. PropertySchema.xsd will open in the Schema editor window, and a new Microsoft
Visual Studio dialog box will appear, asking you if you want to reload
PropertySchema.xsd. Click Yes.
Notice that the node you promoted is part of this schema.
7. Right-click Property1, and then click Delete, and then click Yes.
The Property1 node serves no purpose and can be safely deleted.
8. On the File menu, click Save All.
9. In PurchaseOrder.xsd, right-click OrderTotal, point to Promote, and then click Quick
Promotion.
10. Another Microsoft Visual Studio dialog box will appear, asking you if you want to
reload PropertySchema.xsd. Click Yes.
11. In Solution Explorer, right-click the Messaging project, and then click Deploy.
The next demonstration requires that this project be deployed.
12. Pause the bt10d-demos virtual machine.
Lesson 2: Configuring Message Routing
Lesson objective:
Overview
BizTalk Server enables you to route messages directly to a send port or to an orchestration
based on the contents of the message. This feature is very powerful because it can increase
flexibility of business processes by eliminating the need to deterministically configure the
flow of messages.
Steps for Enabling Messaging Routing
Receive Ports
BizTalk Server uses receive ports to receive messages from internal systems and trading
partners. Receive ports can be configured to use one or more maps for incoming message
transformation. If more than one map is specified, only the map that matches the inbound
message will be applied. You can also configure the port to track message bodies or
properties. Although message body tracking provides more information about each
message, it can adversely affect the performance of BizTalk Server.
Additionally, receive ports can function as either one-way ports or two-way ports. A one-way
port only receives messages, whereas a two-way port, otherwise known as a request-
response port, can both receive and send messages. This module focuses on one-way ports
because they are used more often than two-way ports.
Receive ports and receive locations can be created and configured by using BizTalk Explorer
as shown in the preceding illustration. Both receive ports and receive locations can also be
created and configured by using the BizTalk Administration Console.
Receive Locations
A receive port can have multiple receive locations associated with it. This is useful when you
have messages being received from multiple physical locations, such as from a file folder and
an FTP site, but you want all the messages received through any of the locations to be
processed in the same manner.
Receive locations are configured with a URI, an address from which inbound messages
arrive, a receive handler, and a receive pipeline. The URI is specific to the transport or
adapter type (FILE, FTP, HTTP, Microsoft SharePoint® Services, and others). The receive
handler is the BizTalk host under which the receive location will process messages. The
receive pipeline processes the messages between being picked up and being written to the
MessageBox database. BizTalk pipelines will be covered in more detail in Module 6:
“Creating Pipelines”.
For more information on BizTalk hosts, refer to the BizTalk Server 2010 documentation on
“Managing BizTalk Hosts and Host Instances.”
Receive locations can be in one of three possible states:
Enabled. When enabled, receive locations process messages.
Disabled. Disable a receive location if you want to prevent the receive location from
receiving messages or if you want to delete the receive location.
Suspended. If a service window has been configured for the receive location, the
location will indicate that it is suspended while the service window is inactive.
If an error occurs while a receive location is listening for messages, the receive location will
retry the number of times specified in the Retry Count property spaced at the Retry Interval
(minutes) property. If it continues to fail, the receive location may be disabled (this is a
property of the individual adapter).
Demonstration: Configuring a Receive Port and a File Receive Location
Learn how to create and configure a receive port and a receive location, and how to enable a
receive location by using the BizTalk Server Administration Console.
Overview
Send ports are the locations to which BizTalk Server sends messages. A send port can
function as either a one-way port or a two-way port. As specified earlier, one-way ports send
messages, and two-way ports (also known as solicit-response ports) can both receive and
send messages. However, not all adapters support two-way ports. The FILE, MSMQT, and
SMTP adapters are supported only as one-way ports.
There are three general types of send ports:
Static send ports. These send ports contain a fixed destination address. When you
create a static send port, as in the preceding illustration, you specify the adapter type,
destination address (URI), and pipeline used for the static send port.
Dynamic send ports. Dynamic send ports do not contain a fixed destination address.
Instead, the destination address is set within the orchestration.
Direct send ports. In the case of the static and dynamic send ports, the message is
written to the MessageBox database before being processed into the send port. In some
situations, it may be advantageous to have orchestrations communicate directly. In
these cases, direct send ports can be used.
Send ports can be created using either BizTalk Explorer or the BizTalk Administration
Console. Some of the properties you can configure for a send port include:
Send port name. Since you will likely have many send ports in your application, you
should always assign a descriptive name to a send port to help identify which messages
or processes are associated with a specific send port. For example, POAck_to_Vendor is
a much better name then Port_1. Also, descriptive names can help when moving from
one environment to another.
Primary and secondary transport. Examples of transport types include FILE, FTP, SQL
Server, and HTTP. Send ports contain both a primary and a secondary transport type so
that if the primary transport is unavailable for some reason, messages can still be sent
using the secondary transport type. For example, your primary transport type may be an
FTP site. However, if the FTP site is unavailable, you can set the secondary transport to
FILE and still successfully process messages through the send port. Later when the FTP
site is back online, you can manually transfer received messages from the file location to
the FTP site.
Address (URI). The address or URI is the physical location where messages are sent
when processed by a send port. The address is dependent upon the transport type.
Retry count. The retry count is the number of times BizTalk will try to resend a message
if the transmission fails. The default value is 3, which is satisfactory for many situations,
but the allowed range is 0 through 1000, which allows flexibility in use. For example, you
may not want retries to occur at all when communicating with a Web service, whereas
you may want to try continuously until successful when sending to a SQL database.
Service window enabled/disabled. You can enable the service window if you want to
configure a port to send only at specified times of the day. By default, the service
window is disabled, meaning that the send port will send messages at any time. If the
service window is enabled, the Start Time and Stop Time properties must be specified.
You can enable the service window, for example, if you want to send messages to a busy
HTTP site only between midnight and 08:00 to prevent network delays during normal
business hours. The messages will actually be delivered to the send port and be queued
in the spool table in the MessageBox database until the appropriate time.
Other properties that must be specified for a send port include the BizTalk host and the send
pipeline. Both of these properties are configured on the Send tab of the Send Port Properties
dialog box. BizTalk hosts and send pipelines are covered in more detail in Module 6:
“Creating Pipelines”.
Configuring Send Port Filters
Filter Expressions
Filter expressions are used to create subscriptions. Subscriptions determine which messages
will be delivered to a specific port. You can use both the promoted properties from the
inbound message schema and the BizTalk global properties to create the filter expressions
on a send port. This is known as content-based routing because the actual contents of the
message are used to determine how the message should be routed. For example, if you
need to route all messages with an order amount over $500 to a specific folder for
managerial approval, you can promote the amount node in the source schema and then
create a filter expression for a send port to subscribe to messages only with an amount
greater than or equal to $500.
Identify the purpose of a send port group and configure a send port group for message routing.
Describe the various states of a send port group and enlist and start a send port for message
processing.
Overview
Send ports and send port groups always have a state. The state of the send port determines
whether it accepts messages, processes messages, or does neither. The state of the send
port group can be changed by actions invoked on a send port it contains. You can change the
state of a send port by using either BizTalk Explorer or the BizTalk Administration Console.
Enlisting
The actions that can be invoked to change the state of a send port are Enlist, Start, Stop, and
Unenlist. When send port groups are first created, they are in the Bound state. To change
the send port group to the Started state, the send port group must be either started or
enlisted and then started because starting a send port implies enlisting. When a send port or
send port group is enlisted, it is associated with a BizTalk Host, and the subscriptions for the
send port or send port group are created in the MessageBox database. However, if a send
port has been enlisted but not started, it is still in the Stopped state. Stopping a send port
moves the send port state to Stopped but does not delete the subscription in the
MessageBox database. Unenlisting a send port changes the send port state to Bound and
deletes the subscription to that send port in the MessageBox database.
A query can be performed through the BizTalk Administration Console hub page for all
subscriptions. A preconfigured query is accessible at C:\Program Files (x86)\Microsoft
BizTalk Server 2010\SDK\Utilities\BTSSubscriptionViewer.btq.
Demonstration: Configuring a Send Port and a Send Port Group
Learn how to create and configure send ports and send port groups, and how to define filters.
Lesson objective:
Overview
Microsoft BizTalk Server provides tools that can be used to troubleshoot messaging and
orchestration processes. The BizTalk Administration console offers the BizTalk Group Hub
page (the Hub), which can be used for viewing live and completed BizTalk service instances.
Live instances are those that are currently executing, whether in an active, dehydrated, or
suspended state. Dehydrated instances are those whose state information has been
persisted and the resources in use released. These tools provide powerful search and
summary capabilities to assist in identifying the overall health of a BizTalk system.
What Is the BizTalk Group Hub Page?
Describe the capabilities of the BizTalk Group Hub page and use the Hub to monitor and track
live data.
Use the BizTalk Hub page to query and view specific instance details.
Using the Tracked Message Event and Tracked Service Instance queries to monitor and track live
and historical data.
Overview
A BizTalk Server messaging system can process thousands of messages in a day.
Administrators, developers, and sometimes even business analysts require the ability to
track messages and to view, monitor, and query the data related to messages being
processed. The BizTalk Hub Tracked Message Event and Tracked Service Instance queries
give users the ability to view the tracking details related to service instances whether these
relate to message routing or orchestrations.
Benefits
Some of the capabilities of the Tracking queries include the ability to:
Track when a service begins or ends or when a message is sent or received. The Tracking
queries can reveal the start time and the end time for every message processed by
BizTalk Server. The Tracking queries also show the state of any messages processed
through BizTalk Server and the context properties of each of the messages. Message
states include Active, Suspended, Completed, and Terminated.
Monitor the health of operations, and create reports to analyze the current state of
business processes. Every message goes through a series of contiguous processing steps;
you can access this message flow by querying for messages and then right-clicking the
message you want to track. After you click Message Flow from the context menu, you
can see the processing steps for the message, and you can also see if any errors occurred
while the message was being processed by BizTalk Server.
Gather information about the state of a running process to be able to implement
appropriate changes to the business process when needed. You can modify which data
you want to track without affecting the rest of the BizTalk environment. Redeployment
of assemblies is not necessary when changing tracking options. Changes to which
properties are tracked is managed through the BizTalk Administration Console.
Monitoring live data also enables you to monitor your system so you can fix problems in
the development or staging environment.
Make it possible for business users to track message activity when a problem arises at
the business level so that the administrators or developers can investigate the problem
further. A power user may determine that all messages in a particular format are getting
hung up within an orchestration and save the problematic messages to disk to pass this
information on to a developer who can remedy the problem.
Analyze archived information. The BizTalk hub queries allow the user to access both live
data and archived data. Analyzing archived data enables you to examine trends both in
your business and in your system because you can look as far back as is necessary to
troubleshoot a problem in a particular business process.
Debug orchestrations. The Orchestration Debugger enables you to track the activity of a
single orchestration instance on a shape-by-shape basis. It displays a rendered view of
the orchestration created in the Orchestration Designer. You access the Orchestration
Debugger through a shortcut menu by right-clicking any service or message instance
associated with an orchestration type. You can switch back and forth between the
Orchestration Debugger and the Message Flow view.
You can configure exactly what information gets tracked, but note that tracking can have a
negative impact on BizTalk message-processing performance. This is because at each data
collection point, information has to be written to the tracking database. Care should be
taken in enabling message tracking for this reason. The effects of tracking should be
anticipated and included in the testing process to identify the overall impact.
Identifying Types of Events and Data That Can Be Tracked
Identify the types of events and data that can be tracked by BizTalk Server.
Event Tracking
BizTalk Server tracks data as events based on tracking filters you have set. You can configure
BizTalk to track events such as:
The starting or stopping of a service.
The sending or receiving of messages.
The beginning or ending of a pipeline.
The beginning or ending of an orchestration.
The execution of each shape in an orchestration.
Data Tracking
You can turn on tracking for any information in the message, including promoted properties,
routing information, and partner data. The BizTalk Hub also allows you to see suspended
orchestrations and pipeline information.
The BizTalk Hub can be used to track:
Promoted properties. This is useful when you have implemented content-based routing
that uses promoted properties, and you want to locate messages that were processed.
After you have turned on tracking for a promoted property in a schema, you can find
messages in which the promoted property is a specific value. For example, if you want to
see only messages that have a Quantity of less than 100, you can query the tracking
database based on the Quantity promoted property. However, only promoted
properties for which you have turned on tracking will show up in the Property drop-
down list. Tracking is configured in the BizTalk Group Hub.
Routing information. Because the BizTalk Hub allows you to trace the path of a message
as it is routed through BizTalk Server, the BizTalk Hub can be very useful for
troubleshooting errors. The BizTalk Hub can display error codes and routing states for a
message so that you can troubleshoot errors in real time.
Schema information. The BizTalk Hub allows you to find messages based on the schema
type. This can be useful when you want to see only messages associated with a
particular schema. Also, if you have promoted any properties in the schema that you are
tracking, you can select the specific property you want to track from the Property drop-
down list and narrow your search even further.
Viewing and Tracking Message Activity
Identify the types of events and data that can be tracked by using the BizTalk Hub Tracking
Queries.
Overview
You can view both live and archived data by using various BizTalk Hub queries. You must
have message body tracking turned on in order to save messages after processing of service
instances is complete. Also, make sure the SQL Server Agent service is running on all
MessageBox databases. This makes message bodies available to the BizTalk Group Hub and
WMI, and it enables you to perform cleanup in the MessageBox database. Message body
tracking is configured by using the BizTalk Group Hub page and is covered later in this
module.
Learn how to use the BizTalk Group Hub to track message activity and examine message flow.
Scenario
The BizTalk messaging engine allows you to route messages based on message context. In
this lab, you will add existing BizTalk artifacts the messaging project. Next, you will promote
properties in an XML schema to be used to selectively route messages. You will then
configure BizTalk messaging ports to receive and route sales order messages, based on
message context. Finally, you will test the port configuration by submitting test messages.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-05 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose
Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click Ask Me Later, and then click OK.
Promote Properties
Procedure List
1. In Solution Explorer, double-click SalesOrder.xsd.
2. In the Schema Editor, right-click <Schema>, and then click Expand Schema Node.
3. Under the Detail node, right-click OrderType, point to Promote, and then click Quick
Promotion.
4. In the Microsoft Visual Studio message box, read the message, and then click OK. If
a message box appears asking if you want to reload PropertySchema.xsd, click Yes.
Notice in Solution Explorer that the PropertySchema.xsd artifact has been
created. This is the default schema created to hold promoted properties. Also
notice that the OrderType node now has an icon to indicate that the node has
been promoted.
5. Ensure that PropertySchema.xsd is open in the schema editor. If it is not, double-
click PropertySchema.xsd in Solution Explorer.
Notice that the OrderType node is listed in the PropertySchema schema. The
Property1 node is created by default and can be safely deleted.
6. Right-click Property1, and then click Delete.
7. In the BizTalk Editor dialog box, click Yes to confirm the deletion.
8. In Solution Explorer, right-click the Messaging project, and then click Deploy.
Verify in the status bar that the deployment succeeded.
Exercise 3: Creating a Receive Port and a Receive Location
Overview
You can use the BizTalk Server Administration Console to manage the BizTalk configuration
database. BizTalk Server uses receive ports and receive locations to process inbound
messages. In this exercise, you will create a receive port and receive location by using BizTalk
Explorer.
Procedure List
1. Under BizTalk Application 1, right-click Send Ports, point to New, and then click
Static One-Way Send Port.
2. In the Send Port Properties dialog box, in the Name box type CashOrdersFILE.
3. In the Type list, click FILE, and then click Configure.
4. In the FILE Transport Properties dialog box, click Browse, browse to
C:\AllFiles\LabFiles\Lab5, create a new folder named CashOrders, and then click
OK.
5. In the File name box, type Cash%MessageID%.xml, and then click OK.
6. In the Send pipeline list, click PassThruTransmit.
7. In the left pane of the Send Port Properties dialog box, click Filters.
8. In the right pane, click the top box in the Property column, and choose
BTS.ReceivePortName from the drop-down list.
9. In the Value box, type SalesOrder.
10. On the second line, click AdvWorks.Messaging.PropertySchema.OrderType in the
Property list.
11. In the Value box, type CASH, and then click OK.
Exercise 6: Creating a Send Port for Credit Orders
Overview
You want all credit orders to be sent to a different port than the cash orders. In this exercise,
you will create a send port and configure its filter to subscribe to all messages that contain
the word CRED in the OrderType promoted property field, and are received by the
SalesOrder port.
Module objective:
In this module, you will learn how to create send pipelines and receive pipelines for specific
processing scenarios.
Overview
Pipelines enable the pre-processing of messages as they enter or leave the MessageBox
database. Pipelines can also be called from within an orchestration. Pipelines are used to
provide additional processing to messages, such as encoding and decoding, encrypting and
decrypting, and other processing that might be required to work with messages in Microsoft
BizTalk Server.
BizTalk Server supports the ability to modify pipeline properties on a per-use basis, reducing
the need to modify pipelines frequently, and the ability to call pipeline components from
within an orchestration.
Lesson 1: Introduction to Pipelines
Lesson objective:
Describe both send and receive pipelines and explain how BizTalk Server uses pipelines to
process messages.
Overview
A pipeline in BizTalk Server is a software infrastructure that defines and links together one or
more stages of a business process. Stages define logical work groups, determine which
components can belong to a stage, and specify how the pipeline components in the stage
are run. Pipelines are executed in sequence to complete a specific task, such as encrypting a
document or validating a document against a schema.
What Is a Pipeline?
Pipelines
Pipelines are software components that can process messages, either as the messages are
received or just before they are sent out through a send port. A pipeline divides processing
into categories of work called processing stages and specifies the sequence in which each
stage of work is performed. Each stage of a pipeline contains one or more pipeline
components (Microsoft .NET objects or COM objects) that can be configured to work with
the specific requirements of the messaging solution or orchestrated business process.
Processing Stages
Pipeline processing stages can include functions such as decoding or encoding,
disassembling or assembling, and decrypting or encrypting. Processing stages are
implemented in a prescribed order that cannot be modified.
The processing stages for a pipeline depend upon its intended use. BizTalk Server provides
two types of pipelines: receive and send. These two types of pipelines require separate
categories of work, such as the encoding versus the decoding of a message. The pipeline also
governs the process sequence by the use of policy files that specify the order in which each
stage is to be executed. For instance, an incoming message must usually be decoded before
it can be disassembled.
Pipeline Scenarios
Overview
There are a number of reasons why you may need to implement pipelines in your BizTalk
solution. By using pipelines, it is possible to modify the message in many different ways as it
is being passed into and out of the MessageBox database.
Receive Pipelines
Receive pipelines can be used to process messages as they are received by BizTalk Server.
For example, you can use receive pipelines to decode and/or decrypt messages (by using a
private key) as well as verify the sender of messages as they are being received. This is
important because messages exchanged over the Internet must frequently be encrypted,
and it is necessary to confirm the identity of the sender of the message.
Other tasks that can be performed in receive pipelines include extracting individual
messages from a message interchange and validating messages against a schema to ensure
that they meet the requirements of your processes. Validation can be performed in both a
receive pipeline and a send pipeline.
Send Pipelines
Send pipelines are used to process messages as they are being sent by BizTalk Server. For
example, you can use send pipelines to encrypt messages (using a public key), or digitally
sign outbound messages (using a private key) as proof of who the sender is. Before a
message is sent, you can also use the validate component of a send pipeline to ensure that a
message is valid against a known schema.
Receive Pipeline Stages
Explain how each of the receive pipeline stages works to process messages.
Explain how each of the send pipeline stages works to process messages.
Explain how each of the send pipeline stages works to process messages.
Identify each of the default pipelines and describe how they work to process messages.
Default Pipelines
When you create a new application, a reference to the Microsoft.BizTalk.DefaultPipelines
assembly is automatically added to the project. This assembly contains the default pipelines
provided with BizTalk Server. The default pipelines cannot be modified using the Pipeline
Designer.
Flat-File Pipelines
There are no default flat-file pipelines. Any time flat-file messages need to be processed, it
will be necessary to create a custom pipeline as outlined in the following topics. When any
flat-file message is to be processed through BizTalk Server, the pipeline will have at least one
disassembler in which the document property will identify the flat-file message format that
the disassembler can process. Each flat-file disassembler can specify only one document
schema; therefore, if the pipeline can process multiple flat-file message formats, multiple
disassemblers will be required.
What Are Custom Pipeline Components?
Explain when to use a custom pipeline and describe usage scenarios for custom pipelines.
Explain the different types of pipeline components and how they are used.
Overview
You can create three types of pipeline components: general, assembling, and disassembling.
Each of the three types can additionally implement probing functionality. Each type of
pipeline component has an associated interface that must be implemented for the
component to be plugged into the BizTalk Messaging Engine. In order to develop a general
pipeline component, you must implement the following interfaces:
IBaseComponent. This interface contains three functions, one each to retrieve the
computer name, description, and version.
IComponent. This interface contains the single core method for implementing the
pipeline process that allows you to give read and write access to both the message’s
data parts and context.
IComponentUI. The two methods in this component enable you to validate the
component’s configuration and provide a design-time environment icon.
IPersistPropertyBag. This interface enables a component to both retrieve and store
configuration information for the component by using a property bag (used to
persistently save properties).
IProbeMessage. This interface is required for disassembler components. The
pipeline manager will call the disassembler through this interface, allowing the
component to examine a message to determine whether or not it can recognize and
process the message format.
The built-in pipeline components are streaming components which means that they get one
pass at the data as it flows through the pipeline. For performance reasons, and to conserve
memory, you should create streaming pipeline components whenever feasible. Non-
streaming components will consume more memory and can degrade performance.
Lesson objective:
Describe and demonstrate how to design and build send and receive pipelines.
Overview
The send and receive pipelines that you create can be a very important part of your BizTalk
deployment. In this lesson you will learn how to use Visual Studio to design and build
pipelines.
Using the Pipeline Designer
Use the Pipeline Designer to create receive pipelines and send pipelines.
Pipeline Designer
The BizTalk Pipeline Designer is a feature in Microsoft Visual Studio® 2010. The Pipeline
Designer provides a graphical representation of a pipeline and enables you to construct or
edit send or receive pipelines for a BizTalk project. You can navigate between pipelines by
clicking the tabs at the top of the design surface. The file extension for both receive pipelines
and send pipelines is .btp.
You create a new pipeline by selecting a pipeline template for a project. Separate templates
are provided for send and receive pipelines. When you name a new pipeline, you should get
in the habit of indicating the primary purpose of the pipeline along with the pipeline
direction (send or receive), for example, SendEncryptedMessages.
Pipeline Stages
You create or modify pipelines by dragging and dropping components to the different
pipeline stages. If there are no components in any one stage, a placeholder indicates that
shapes can be inserted there from the Toolbox. When the first shape is inserted into a stage,
the placeholder text disappears.
The design surface shows the pipeline vertically, running from the start of the pipeline (at
the top) to the end of the pipeline. Note that with the exception of the disassemble stage (in
the receive pipeline), the execution path goes through each stage indicating that each
component in the stage will be executed in order. In the case of the disassemble stage, the
path is represented as a dotted line that extends around the components in the stage,
indicating that the message will be probed and that the first component that matches will be
executed.
Only components that are valid for the type of pipeline that you are creating are displayed.
For example, the assembler components can be used only in send pipelines so that they are
not visible when creating a receive pipeline. Additionally, the design interface will allow you
to add only those components that are valid for a given stage to that stage. For example,
you can add only a disassembler to the disassemble stage.
Securing Data by Using a Pipeline
Configuring Encoding
If an encoding component in the send pipeline is configured to sign messages, and the
BizTalk group that includes the host running the pipeline is not configured with a signing
certificate, the outgoing message will be suspended (with the appropriate error being
displayed) to the suspended queue of the host running the pipeline. If the signing certificate
cannot be found in the personal certificate store of the current user under which the service
is running, the message will be routed to the suspended queue of the host running the
pipeline.
If there is an encoding component in the outbound pipeline configured to encrypt outbound
messages, and the certificate cannot be found in the certificate store, the message will be
suspended to the suspended queue of the host that is running the pipeline.
Also, if you have a request-response port that is receiving signed and encrypted messages,
and you want to perform response encryption on this port, you must add a custom pipeline
component to the pipeline before the MIME/SMIME Encoder pipeline component that must
identify the thumbprint corresponding to the encryption certificate. You will also need to set
the BTS.EncryptionCert property on the message context.
Note: In BizTalk 2010, the MIME/SMIME encoder pipeline component will not have native
64-bit support. This means that this component must be run in a 32-bit emulation mode
process (WOW64), which implies that the host instance in which this encoder component (or
the send pipeline of which it is a part) runs must be running in 32-bit emulation mode. Be
aware of the performance (and other) implications of this restriction for other elements of
BizTalk Server running in this same host instance.
Processing Interchanges by Using a Pipeline
What Is an Interchange?
An interchange is a group of messages that are contained within one larger message.
Depending upon the design of the messaging or orchestration solution, BizTalk Server can
often process many small messages faster than it can process a single large message. For
example, you can think of an interchange as a manila envelope that contains ten individual
paper purchase order (PO) documents. Once you open the envelope, you will want to
process each PO separately. Interchange processing in BizTalk Server is used to extract these
individual messages so that they can be processed separately.
BizTalk Server 2010 supports a feature called recoverable interchange processing.
Configure schemas to enable interchange processing of flat files and XML files through a pipeline.
Overview
A message interchange can be a single XML document that contains other messages, or it
may be a collection of flat-file messages contained within a single flat-file message. BizTalk
Server has different requirements for processing flat-file interchanges than for XML
interchanges. As does all flat-file processing, flat-file interchanges require a custom pipeline,
whereas XML interchanges can use the default XML pipeline. Additionally, you can create a
custom XML pipeline to process interchanges.
Flat-File Interchanges
Processing of flat-file messages always requires a custom pipeline containing the flat-file
disassembler. A pipeline for flat-file interchanges requires you to configure a flat-file
disassembler that specifies the schemas that make up the entire interchange message. This
will necessarily include a document schema and may optionally include header and/or trailer
schemas.
The document schema needs to represent the individual messages (which may be one or
more records) to be extracted by the disassembler. The Header schema must define any
records that occur before individual documents in the interchange. The trailer defines any
records in the interchange that appear after the end of the last document message. After
adding the flat-file disassembler component to a custom receive pipeline, set the Document
schema, Header schema, and Trailer schema properties of the flat-file disassembler pipeline
component to schemas you have created that match the header, body, and trailer of the
interchange that will be processed. Each flat-file disassembler must be associated with only
a single message type, so it is necessary to create a separate receive pipeline for each type
of flat file that your BizTalk Server system will be processing.
Once the interchange is processed, each resulting message will be sent on through the
remaining stages (validation and party resolution) individually.
XML Interchanges
Since BizTalk Server comes with a default XML receive pipeline, it is typically not necessary
to create custom pipelines to process XML documents. BizTalk Server evaluates each
received XML message to determine its document type (this is the combination of the
namespace and root node) and then locates any deployed schema that matches the
message instance. In this way, the standard pipeline can be used to process any type of XML
message. If a custom pipeline is defined with a collection of XML schemas specified in the
XML disassembler, that pipeline can be used with only the specified message types. All other
messages will be suspended. This is useful if you want to limit the types of messages
processed through a given pipeline.
When a message that represents an interchange is received, BizTalk Server evaluates the
document type of the message and then locates the appropriate schema (known as the
envelope schema). Envelope schemas have two special BizTalk Server properties that specify
that these messages will be split into individual messages to be processed and saved to the
MessageBox. The first property is the Envelope property, which you will find in the reference
section of the Properties window when the Schema node is selected. The Root node of the
schema has a Body XPath property in the Parse section, which is used only when the schema
is an envelope. This expression should be set to identify the immediate parent node of the
body messages.
For example, assume that you must process the following message, which contains multiple
updates. You want to split up the batch so that each update is processed separately by an
orchestration that can process only a single update at a time.
<Batch Department=“Sales">
<Updates>
<CustomerUpdate CustID=“12345" Address=“123 My Street" />
<CustomerUpdate CustID=“12346" Address=“246 Your Street" />
<CustomerUpdate CustID=“98765" Address=“564 Any Street" />
</Updates>
</Batch>
You must first create a CustomerUpdate.xsd schema. This schema has no special properties
and could in fact be the same schema that you are processing individual updates with
already:
Next, you must create an envelope schema that represents the rest of the message with an
Any Element element in place of the <CustomerUpdate> section. The Body XPath expression
would identify the <Updates> section.
<Batch Department=“Sales">
<Updates>
<ANY Element>
</Updates>
</Batch>
When these two schemas are deployed and an interchange message is received, BizTalk
Server will identify the envelope schema, and when it encounters the Body XPath node, it
will emit one message for each child within that node.
If this same envelope is used to process other types of updates, vendor updates for example,
only the vendor update schema needs to be created. A single update message can now
contain both the vendor and customer updates.
Testing an Envelope Schema
Overview
Pipeline Tools is a set of tools that are used for execution, debugging, and profiling of
pipelines and pipeline components, namely flat-file and XML assembler and disassembler
components. The individual tools are as follows:
Pipeline.exe. This tool executes a specific send or receive pipeline. It accepts one or
more input documents and their parts, XSD schemas and their related information,
and after a pipeline execution, it produces an output document.
FFAsm.exe. This tool executes the flat-file assembler component, directly invoking it,
and then it emulates a send pipeline, thereby enabling the user to see how the send
pipeline processes (serializes/assembles) the user’s XML document into a flat-file
document.
FFDasm.exe. This tool executes the flat-file disassembler component, directly
invoking it, and then emulates a receive pipeline, thereby enabling the user to see
how the receive pipeline processes (parses/disassembles) the user’s flat-file
document into one or more XML documents.
XMLAsm.exe. This tool executes the XML assembler component, directly invoking it,
and then emulates a send pipeline, thereby enabling the user to see how the send
pipeline processes (serializes/assembles/envelopes) the user’s XML document into
an output XML document.
XMLDasm.exe. This tool executes the XML disassembler component, directly
invoking it, and then emulates a receive pipeline, thereby enabling the user to see
how the receive pipeline processes (parses/disassembles/un-envelopes) the user’s
XML document into one or more XML documents.
Note: You can find these tools in the <Installation Path>\SDK\Utilities\PipelineTools folder.
Demonstration: Creating and Testing a Pipeline
Learn how to create a receive pipeline and a send pipeline and use the command-line tool to test
a pipeline.
Scenario
Pipelines allow you to customize the processing of messages within send or receive ports. In
this lab, you will create and test a custom send pipeline that encrypts communications
between Adventure Works and Woodgrove Bank. Next, you will configure a receive pipeline
that splits a batch of messages (an interchange) to be processed as individual messages.
Finally, you will enable recoverable interchange processing to address issues that arise from
malformed messages within the batch.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-06 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose
Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click Ask Me Later, then click OK.
Module objective:
In this module, you will learn how to identify the various adapter types and how to configure
adapters for use in an integration scenario.
Overview
Because Microsoft® BizTalk® Server 2010 must be able to exchange messages with a variety
of other systems and applications, specialized adapters are required. An adapter is a COM or
Microsoft .NET–based software component that provides the functionality required to
interface with different types of applications and sometimes proprietary communications
mechanisms. This module explains how adapters work and shows you how to configure
specific types of adapters that are included with BizTalk Server 2010.
Lesson 1: Introduction to BizTalk Adapters
Lesson objective:
Describe how adapters are used to create integration solutions and how the BizTalk Adapter
Framework can be used to create custom adapters.
Introduction
BizTalk Server 2010 includes a number of adapters that can access common data storage
locations, such as email servers, file servers, web servers and SharePoint servers. BizTalk
Server 2010 also offers a variety of adapters for connecting to third-party applications. This
lesson shows you how to use adapters to connect BizTalk Server to external systems and
applications.
What Is an Adapter?
Adapters
BizTalk adapters are the first and last software components used by BizTalk Server to
exchange messages with disparate applications and systems. An adapter is a software
component that enables messages to be received or sent by BizTalk Server using a specific
delivery mechanism. This mechanism is commonly a recognized standard, such as HTTP, FTP,
or POP3, but it could also be a method of communicating with a proprietary third-party
application, such as a vendor’s Enterprise Resource Planning (ERP) application.
Adapter Sources
You can acquire an appropriate BizTalk adapter through four primary sources:
Standard BizTalk Server 2010 adapters. These adapters, also known as native adapters, are
included in the installation of BizTalk Server 2010. The standard adapters include Base EDI,
FILE, FTP, HTTP, WebsSphere MQ, MSMQ, POP3, SMTP, SOAP, SharePoint and WCF
adapters. Multiple instances of each adapter can be configured by adding multiple receive
locations and send ports. The FTP adapter has been improved, adding support for secure
FTP.
BizTalk Server 2010 Adapter Pack. Microsoft makes available additional specialized adapters
for connecting BizTalk Server to a number of proprietary systems. The release of the BizTalk
Server 2010 Adapter Pack includes updated adapters that support the latest versions of JD
Edwards, Oracle eBS, SAP and Siebel. These adapters can be installed individually as
required. A complete list of the BizTalk Server 2010 adapters is available on the Microsoft
web site.
Third-party adapters. Third-party adapters can be purchased by companies who specialize in
developing adapters or from companies that provide adapters to enable integration with
their proprietary applications. Examples of third-party adapters include Lotus Notes, and
CICS. Once the adapter has been installed, you can use the BizTalk Administration console to
configure these adapters. If an adapter is no longer required, it can be removed without the
need to reconfigure the BizTalk application.
Custom adapters. A custom adapter could be required if no adapter exists for a system or
application to integrate with BizTalk Server 2010. Microsoft provides the BizTalk Adapter
Framework documentation and a software development kit (SDK) toolkit for developers to
use for creating custom adapters.
What Is the BizTalk Adapter Framework?
Adapter Framework
Microsoft provides the BizTalk Adapter Framework to enable developers to create custom
adapters for interfacing and integrating with a proprietary system or with a system
unsupported by existing adapters. This framework provides a common means of creating
and implementing adapters and includes the specifications for building BizTalk adapters
using open standards based on Web Services. The Adapter Framework consists of a set of
extensible APIs that enable developers to access relevant BizTalk Server services used to
integrate applications and platforms. Once an adapter has been built for BizTalk Server by
using the Adapter Framework, the standard BizTalk administration tools can be used to
manage and configure the adapter. The Adapter Framework is provided as part of the
BizTalk Server 2010 product SDK.
Lesson 2: Configuring a BizTalk Adapter
Lesson objective:
Overview
Configuring a BizTalk Server 2010 adapter involves setting the properties required for the
adapter to communicate among BizTalk Server, external systems and trading partners. In
this lesson, you will learn about the difference between a protocol adapter, a WCF adapter,
and an application adapter, and you will learn how to configure adapters.
Configuring an Adapter
Adapter Configuration
Each adapter must be configured with specific properties to enable it to function. The
properties differ depending on how the adapter will connect to the intended endpoint. For
example, an FTP adapter has specific settings that are unique to the FTP protocol and the
specific FTP server that it must connect to. This includes properties such as the polling
interval, logon user name, and the password. Obviously, these properties would not be
appropriate for the FILE adapter.
Adapters also have default global properties that can be modified through the BizTalk
Administration console. The global settings are augmented or can be overridden for a
specific adapter that is configured though a receive or send port. Because adapter
configurations contain potentially sensitive information, such as connection strings and
logon credentials for external systems, the configuration information is encrypted and
stored in the Single Sign-On (SSO) database at design time. At run time, the Messaging
Engine retrieves the configuration for the adapter.
You can add instances of an adapter by using the BizTalk Administration console.
File Adapter
The FILE receive adapter reads files from a folder on the local file system or on a network
share. Secure access through the network share can be maintained by setting appropriate
user account permissions and configuring the adapter to use the required user account. The
FILE receive adapter creates a BizTalk Message object so that BizTalk Server can process the
message.
The FILE send adapter transmits messages from the MessageBox database to a specified
destination address. The destination address is defined by a file path and file name using
macros (wildcard characters) related to the message context properties. The FILE send
adapter gets the message content from the body of the BizTalk Message object, and after
the message is processed by the pipeline, the adapter writes the message to a file and then
deletes the message from the MessageBox database. The FILE adapter writes files to the file
system either directly or by using the lazy write-behind cache, which can improve
performance, particularly for large files.
Integrating with Protocol Adapters
Protocol Adapters
Protocol adapters process messages by using common networking protocols. The protocol
adapters that are included with a BizTalk Server 2010 installation include:
FTP. The FTP adapter enables you to move messages between BizTalk Server and an FTP
server. The FTP receive adapter allows you to pull files from the FTP server on demand by
polling on a configurable schedule. The FTP send adapter sends messages to the configured
FTP site on demand. BizTalk Server 2010 includes an improved FTP adapter that supports
secure FTP, and it can also handle downloading from read-only locations. The new FTP
adapter maintains a list of previously downloaded file names to avoid reading the same file
more than once. The list is stored in the MessageBox database.
HTTP. The BizTalk HTTP adapter provides support for communication with external systems
by using industry-standard HTTP GET and PUT functionality. You can also configure
appropriate proxy settings to support your network configuration. As is the case with most
of the adapters, there are also several new performance counters for the HTTP adapter
available to you in Performance Monitor.
MSMQ. With the BizTalk 2010 adapter for MSMQ, you can send and receive messages to
Microsoft Message Queuing (MSMQ) queues. This adapter works with transactional and
non-transactional, public and private, and local and remote queues. The MSMQ BizTalk
adapter supports large messages (greater than 4 MB) and provides access to other features,
such as messaging over HTTP and multi-cast messaging.
POP3. The POP3 adapter is a built-in adapter that enables BizTalk applications to poll for e-
mail messages and their attachments from a mailbox by using the POP3 protocol. The POP3
adapter can be used to retrieve e-mail messages from Microsoft Exchange, the Windows
Server POP3 Service, or any third-party POP3-compliant system. Configurable properties for
the POP3 adapter include mandatory properties such as the name of the mail server, the
user name and password for the mail server, and the polling interval. All of these settings
are securely stored in the Enterprise Single Sign-On (SSO) database.
SMTP. The Simple Mail Transfer Protocol (SMTP) adapter enables messages to be sent to
other applications by creating an e-mail message and delivering it to a specified e-mail
address. The target e-mail address is a property of the SMTP adapter. By default, the
message text of SMTP messages is plain text, but you can also configure the adapter to use
the contents of an HTML file or a text file as the message body. These features, plus the
ability to send multiple attachments, are new features of the SMTP adapter for BizTalk
Server 2010.
WebSphere MQ. The WebSphere MQ adapter acts as a bridge between BizTalk Server and
an IBM WebSphere MQ messaging system. You can use this adapter to send and receive
messages from local and remote queues, transmission queues, and alias queues. One new
feature of the WebSphere MQ adapter is the ability to perform dynamic receives as part of
solicit-response.
SOAP. The SOAP adapter has been superseded by the WCF adapters. It is still included with
BizTalk Server 2010 in order to maintain backward compatibility. The SOAP adapter actually
consists of two adapters: the SOAP receive adapter and the SOAP send adapter. The SOAP
receive adapter works through the Microsoft ASP.NET runtime via Web services and passes
messages to BizTalk Server through the Isolated Host adapter. The SOAP send adapter is
used to call a Web service from BizTalk Server. This adapter also supports SSO, which is used
for secure access through Web services.
FTP Adapter Improvements in BizTalk Server 2010
Describe the new and enhanced features of the FTP adapter available in BizTalk Server 2010.
Learn how to create a receive port and a receive location configured with the FTP adapter.
Describe how the BizTalk WCF adapters are used to send and receive messages.
Introduction
Windows Communication Foundation (WCF). The BizTalk WCF adapters allow BizTalk Server
to communicate with service-based interfaces of other applications, including database
servers such as SQL Server 2008 and Oracle 11g. The WCF adapters offer a new and more
flexible way to access data. The BizTalk WCF adapters include five physical adapters that
represent the WCF predefined bindings:
WCF-WSHttp: This adapter provides WS-* standards support over the HTTP
transport.
WCF-BasicHttp: This adapter provides communicates with ASMX-based Web
services and clients and other services that conform to the WS-I Basic Profile 1.1.
WCF-NetTcp: This adapter provides WS-* standards support over the TCP transport.
WCF-NetMsmq: This adapter provides support for queuing by leveraging Microsoft
Message Queuing (MSMQ) as a transport.
WCF-NetNamedPipe: This adapter provides secure optimization for on-machine
cross-process communication using named pipes.
WCF-Custom: This adapter allows you to configure a WCF binding and the behavior
information for the receive location and send port, and take advantage of the WCF
extensibility features.
WCF-CustomIsolated: This adapter allows you to configure a WCF binding and the
behavior information for the receive location running in an isolated host, and take
advantage of the WCF extensibility features over the HTTP transport.
WCF-Custom Adapter
The WCF-Custom adapter replaces the SQL adapter that was included in previous versions of
BizTalk. With the WCF-Custom adapter, BizTalk Server can exchange messages to and from
a Microsoft SQL Server™ 2008 and Oracle 11g databases. You can use the WCF-Custom
adapter to poll data from one or more data tables or stored procedures and retrieve the
data and place it in a BizTalk messaging solution or into an orchestration as one or more
XML messages. You can also use the WCF-Custom adapter to insert, update, or delete data
in SQL Server 2008 and Oracle 11g tables. This adapter can be configured by using the
BizTalk Administration console.
The WCF adapters will be covered in more detail in Module 13 “Using WCF Receive
Adapters” and Module 14 “Using WCF Send Adapters”.
Demonstration: Configuring a WCF Adapter
Learn how to create WCF-Custom metadata that BizTalk uses to communicate with SQL Server.
This metadata is in the form of a schema and special orchestration port types.
Describe how the Windows SharePoint adapter is used to send and receive messages to and
from a SharePoint site.
Application Adapters
Application adapters allow BizTalk Server to communicate with certain Microsoft
applications or with third-party applications. BizTalk Server 2010 includes new adapters for
the latest versions of the most popular enterprise applications, including Siebel, Oracle eBS,
and JD Edwards. Additionally, you can write your own custom application adapter by using
the BizTalk Adapter Framework.
Integrating with Application Adapters
Describe how the Windows SharePoint adapter is used to send and receive messages to and
from a SharePoint site.
Learn how to configure the Windows SharePoint adapter to send to and receive messages from a
SharePoint form library.
Filename Loan%MessageID%.xml
Scenario
BizTalk Server uses adapters to communicate with external systems and processes.
Adventure Works needs to integrate with several systems. Sales orders can now be sent
from stores as HTTP messages in addition to the file receive process already in place. Loan
applications that require approval are sent to a Microsoft Windows SharePoint Services form
library for manual review. All completed sales orders will be sent to an FTP site. In this lab,
you will configure the HTTP adapter, the FTP adapter, and the Windows SharePoint Services
adapter.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-07 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose
Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click Ask Me Later, then click OK
Examine a Sales Order That Was Created by Using the SalesOrderForm InfoPath
Form
Procedure List
1. In Windows Explorer, navigate to C:\AllFiles\LabFiles\Lab7, and then double-click
CashSalesOrder1Info.xml. In the Microsoft Office Activation Wizard window, click
Cancel.
Notice that an InfoPath form has also been created for the Sales Orders.
2. Close CashSalesOrder1Info.xml.
Exercise 2: Configuring and Testing the HTTP Receive Adapter
Overview
The BizTalk Server HTTP receive adapter accepts messages that are sent to Internet
Information Services (IIS). The HTTP receive adapter accepts HTTP POST messages that are
sent to a preconfigured IIS virtual directory, and it publishes the messages to the BizTalk
MessageBox. In this exercise, you will configure and test a new receive location that uses
the HTTP receive adapter to process incoming sales order messages.
Filename CreditOrder%MessageID%.xml
This is the form library that you created in the first exercise of this lab. All credit
orders received will be sent to this form library for manual approval of the loan.
5. In the Send pipeline list, click XMLTransmit, and then click the ellipsis (…) button.
6. In the Configure Pipeline dialog box, in the ProcessingInstructionsOptions box,
type 1.
Setting the ProcessingInstructionsOptions to ”1” will remove all existing InfoPath
processing instructions and then insert the processing instructions you specify in
the XmlAsmProcessingInstructions box.
7. In Windows Explorer, navigate to and open
C:\AllFiles\LabFiles\Lab7\ProcessingInstructions.txt.
8. Copy all of the text that appears in ProcessingInstructions.txt, and then close
Notepad.
These are the processing instructions for the form that you published in the first
exercise.
9. In the Configure Pipeline dialog box, in the XmlAsmProcessingInstructions box,
paste the text you just copied, and then click OK.
This message will no longer open using the processing instructions for the
SalesOrder form. When opened, it will use the InfoPath form that you published
to the SharePoint library.
10. Click OK to close the Send Port Properties dialog box.
11. Right click the CreditOrdersSharePoint send port, and click Start.
Polling Interval 15
The SharePoint adapter will process all messages displayed by the view specified.
This receive location will process messages displayed by the Evaluated view.
7. Click OK three times.
8. In the BizTalk Server Administration Console, click Send Ports, right-click
CashOrdersFTP, and then click Properties.
9. In the Send Port Properties dialog box, click Filters.
10. On the second line of the existing filter expressions, in the Group by list, click Or.
11. Add two filter expressions and configure according to the information in the
following table, and then click OK.
Property Operator Value Group by
12. In the BizTalk Server Administration Console, click Receive Locations, right-click
LoanApplicationsSharePoint, and then click Enable.
13. In Internet Explorer, browse to http://BIZTALKDEMO/LoanApplications.
14. Click CreditOrder{GUID}, and then, in the File Download dialog box, click Open.
15. In the CreditOrder{GUID}.xml window, in the Loan Status list, click Approved.
16. Close CreditOrder{GUID}.xml, and then click Yes to save your changes.
17. In Internet Explorer, browse to ftp://localhost/CashOrders.
It may take up to a minute for the message to be processed.
18. Click the new Cash{GUID}.
19. Examine and then close the message
Module 8: Creating a BizTalk Orchestration
Time estimated: 105 minutes
Module objective:
In this module, you will learn how BizTalk orchestration services work, how to create a
BizTalk orchestration, and how to use debugging tools to monitor a running orchestration.
Overview
By using Microsoft BizTalk Server, you can orchestrate dynamic business processes both
within and between organizations. By using BizTalk Server, developers, information workers,
and IT professionals can work together to rapidly design, create, and deploy integration
solutions that work across applications, platforms, and organizations.
Lesson 1: Introduction to BizTalk Orchestration
Lesson objective:
Explain how BizTalk processes orchestrations, and identify the steps required to create an
orchestration.
Overview
A business process is a set of actions that, taken together, meet a business need. You can
use the Orchestration Designer to define these actions graphically. Rather than requiring you
to express the various steps in a programming language, this tool makes it possible to create
an orchestration by connecting a series of graphical shapes in a logical way.
Modeling a Business Process
Define the term business process and describe the concept and benefits of business-process
modeling.
Business-Process Modeling
Business-process modeling is a technique that you can use to describe and optimize business
processes in an organization. It provides a set of understandable, repeatable structures for
defining business processes. By using a highly structured approach to process automation,
you can increase throughput, reduce cycle times, improve efficiency, and maximize
customer satisfaction.
Business-process modeling improves the interaction and coordination between people and
systems throughout the organization by automating the flow of each business process, and
it provides tools for managing day-to-day business processes. At any given time, there may
be many instances of a given process. Because every instance follows the same flow and
therefore has an identical structure, you can easily automate process management to derive
answers to important questions, such as:
What are the bottlenecks?
What resources are required within the process?
What commitments are not being met?
How can processes be optimized?
What Is an Orchestration?
Define BizTalk orchestration and describe how the BizTalk run-time engine processes
orchestrations.
Orchestration Designer
BizTalk Orchestration Designer is a tool that is hosted within Microsoft Visual Studio®. The
Orchestration Designer is used to create visual representations of your business processes.
The actual underlying code that carries out the business process gets built into an
executable module that runs on a BizTalk Server computer.
The Orchestration Designer design environment provides a versatile drawing surface and a
comprehensive set of implementation tools. These tools include shapes (such as Send,
Receive, Transform, and Construct) that you can use to coordinate all of your business-to-
business orchestrations on the screen using a graphical interface. The addition of each shape
generates code that becomes part of the eventual business process.
Orchestrations designed using Visual Studio 2010 are saved with an .odx extension and are
built as part of a Microsoft .NET assembly DLL. This DLL is then deployed into the run-time
environment to be accessible to BizTalk.
BizTalk Orchestration
BizTalk orchestrations provide the services that make it possible for you to design, execute,
and manage business processes. An orchestration represents the underlying logic for
processing messages similar to traditional procedural programming languages. An
orchestration is a graphical rendering of the processing logic, providing many of the normal
programming constructs as well as additional features needed to address requirements such
as long-running transactions, parallel actions and decisions. An orchestration can be viewed
as an event-driven, finite state machine in which the state-transition events are the arrivals
of messages or ticks of the clock.
Run-Time Engine
The BizTalk orchestration run-time engine executes the orchestration by creating individual
instances of the business process. The run-time engine coordinates multiple instances of a
business process, ensuring, for example, that a response message gets routed to the correct
orchestration instance, which it does by using a specialized routing pattern called
correlation. For example, you may create a process involved with hiring new employees. For
each employee, there are a number of messages that need to be sent and tasks that need to
be performed. BizTalk Server can manage several instances of the orchestration for each
new employee and correlate each incoming message to the correct orchestration instance.
How the BizTalk Orchestration Engine Works
Explain how the BizTalk orchestration engine works and describe the concept of dehydration and
rehydration.
Introduction
The BizTalk orchestration engine is a highly optimized service that monitors and executes
orchestrations. The orchestration management tasks the orchestration engine is responsible
for include:
Creating instances of and executing orchestrations.
Maintaining the state of a running orchestration instance so that it can be restored
to memory when required.
Performing optimizations of running orchestrations to maximize scalability,
throughput, and efficient use of resources.
Providing a reliable shutdown-and-recovery system.
Introduction
BizTalk orchestration is a flexible and powerful capability that provides various services and
tools to enable you to design, automate, and manage business processes. Similar to
traditional procedural programming languages, an orchestration represents the underlying
logic for processing messages.
BizTalk orchestration provides a transactional programming model that includes support for
exception handling and recovery from failed transactions. You can define two types of
transactions when creating an orchestration:
Atomic transaction. Enables a transaction to automatically role back to a previous state in
case the transaction does not successfully complete.
Long running transaction. Can span days, weeks, and longer time durations, contain nested
transactions, and use custom exception handling to recover from error scenarios.
As a result, orchestrations provide you the flexibility to define the course of action in the
event of a business process failure.
Stages of Orchestration Development
Identify and describe each of the steps involved in developing a BizTalk orchestration.
Orchestration Steps
To develop an orchestration, you will typically perform the following basic steps:
1. Define schemas to describe the format of those messages that the orchestration will
process. Because BizTalk Server is message based, all actions that are to be
performed will relate to messages.
2. Define and assign orchestration variables to declare and manage the data that is
used in your running orchestration.
3. Define ports to specify how and where messages are sent and received. Ports are
the mechanism whereby BizTalk communicates with external systems and
processes.
4. Add shapes to represent the various actions that are required to define the business
process. Many shapes require configuration to identify the messages that they will
interact with.
5. Construct new message instances within the orchestration. BizTalk Server provides
transformation and message assignment shapes to create new messages within an
orchestration. Because messages are immutable within BizTalk orchestrations, if a
message must be modified, it is necessary to construct a new instance.
6. Bind the Send and Receive shapes to ports and specify the physical ports that they
will use.
7. Build and deploy the orchestration.
8. Test the orchestration for any errors.
Importing and Exporting BPEL
Define BPEL and explain how BPEL files can be imported into an orchestration or exported from
an orchestration.
What Is BPEL?
Microsoft and IBM, working together with other companies, have created the Business
Process Execution Language (BPEL) as an industry standard to support the interaction of
business processes between heterogeneous systems. A business process defined by using
the BizTalk Orchestration Designer can be exported to BPEL, and similarly, the BizTalk
Orchestration Designer can import processes defined in BPEL. This interactivity makes it easy
to import designs created using other BPEL-compliant tools into BizTalk. BPEL is built entirely
on Web services, whereas BizTalk Server 2010 supports a broader set of services. For
example, BizTalk Server 2010 supports mapping between differing XML schemas, calling
methods in local objects, broad support for transactions, and other features that are not
available in BPEL.
Importing BPEL
You can use the BizTalk Server BPEL Import Wizard to import BPEL, Web Service Description
Language (WSDL), or XML Schema Definition (XSD) language files into a BizTalk project. To
import BPEL into an orchestration, create a new BizTalk project choosing the BizTalk Server
BPEL Import Project template, which starts the BPEL Import Wizard.
Exporting BPEL
If you are exporting to BPEL, the orchestrations can contain only features that are common
between BizTalk Server and BPEL or features that can be translated into BPEL without
affecting behavior. To export BPEL from an orchestration, first modify the orchestration
properties to make the orchestration exportable, right-click the orchestration in Solution
Explorer, and then click Export To BPEL.
Lesson 2: Building an Orchestration
Lesson objective:
Create message variables and types and use the Orchestration Designer to create a basic
orchestration.
Introduction
The BizTalk Orchestration Designer provides a graphical method of designing, deploying, and
maintaining distributed business processes. In this lesson, you will learn how you can use
BizTalk Orchestration Designer to design business processes for managing the logic that is
needed for processing business documents.
What Is the Orchestration Designer?
Introduction
BizTalk Orchestration Designer provides a visual drawing surface that you use to represent a
business process. The design surface is a working canvas to which you drag shapes from the
Toolbox. In most cases, you must configure options for each shape that you use when you
build the orchestration.
Zoom Support
BizTalk Server 2010 provides the ability to zoom the Orchestration Designer window. You
can zoom by right-clicking a clear area of the Orchestration Designer surface and then
clicking Zoom. You can then select the percentage of magnification that you would like to
apply. Alternatively, you can press the CTRL key while using the scrolling function of your
pointing device to zoom in and out.
Using Message and Data-Handling Shapes
Message Variables
Before working with messages in an orchestration, a message variable must be defined using
the Orchestration View in Visual Studio. A message variable represents an instance of an
incoming message to be processed by the orchestration. This is true whether the message
will be received through a port or constructed within the orchestration itself.
In many cases, multiple message variables may need to be defined. For example, if an
orchestration receives a purchase order from which an acknowledgement message and
shipping advice message need to be generated, three different message variables need to be
defined.
Orchestration View
Visual Studio provides the Orchestration View window while you are actively working on an
orchestration. To display the Orchestration View window if it is not already displayed, from
the View menu, click Other Windows. This view allows developers to define variables,
correlation sets, and ports for use in the orchestration. The bottom section displays the
types defined anywhere within the current project or from any referenced project. Types
defined in conjunction with the currently selected orchestration are modifiable, whereas
those defined elsewhere are read-only and unavailable. The Orchestration View window
allows specifying user-defined multi-part message types; however, the simple types upon
which you may want to create messages are not shown in the Types section. This is because
these messages will be based on deployed schemas that have no properties that are
configurable within the orchestration context.
Logical vs. Physical Ports
Introduction
BizTalk Server uses two different types of ports: physical ports (used for messaging) and
orchestration or logical ports.
Example
The following example shows how messages are passed through BizTalk messaging and
orchestration services.
1. A message is received by a physical receive port through an associated receive
location.
2. The message is passed through the receive location (and any associated pipelines)
and then saved in the MessageBox database.
3. The message is picked up by a subscribing orchestration and then passed to the
logical receive port in the orchestration. This subscription is generated by binding
the logical port to the physical port that received the message.
4. The message is processed by the orchestration, and a resulting message is passed
back to the MessageBox database through the logical send port.
5. A subscribing physical send port picks up the message and then passes it through an
associated pipeline.
6. The message is sent to the target destination.
Creating and Configuring Orchestration Ports
Introduction
Each orchestration (logical) port added to a BizTalk orchestration must be based on a port
type. Port types and ports are defined within the Orchestration View window in Visual
Studio 2010. Ports and types have properties that must be configured before linking the
ports to send and receive shapes.
Orchestration Ports
Orchestration ports have Identifier and Description properties, as well as the type with
which they are associated. Additionally, ports identify the direction of communication,
which for one-way ports will be either sending or receiving. For two-way ports, the direction
of the first communication is identified; for instance, a port can receive a request from an
outside process and return a response (request-response), or it may solicit an external
process to perform some action and wait for the receipt of a response (solicit-response).
Learn how to create message variables and configure a receive shape, a transform shape, and a
send shape. You will then see how to create logical send and receive shapes.
Before starting this demonstration, delete the existing Demos application in the
BizTalk Server Administration Console. The Demos application might need to be
stopped before it can be deleted.
Lesson objective:
Introduction
BizTalk Server 2010 provides tools for monitoring business processes at various stages. The
BizTalk Group Hub provides features for reporting, analyzing, and debugging both live and
archived data and messages.
Using the Group Hub to View Orchestrations
Group Hub
The Group Hub page (the Hub) in the BizTalk Administration console is used to view current
service instances. The Hub displays links arranged in categories such as Work in Progress, or
Suspended, or grouped by other characteristics such as Application, Service Name, or Error
Code. Clicking any link initiates a query that returns all instances presently in the selected
state or condition.
The BizTalk Group Hub also provides features for searching, reporting, analyzing, and
debugging data and messages that are archived in the BizTalk Tracking databases. You can
use the Group Hub to locate an orchestration based on the message that initiated the
orchestration.
Use the Orchestration Debugger to track orchestration activity and diagnose problems with
orchestration processing.
Learn how to use the BizTalk Group Hub to track message and orchestration activity.
Scenario
BizTalk messaging can be used for basic message transformation and routing. Processing
that requires decisions or multiple actions generally requires the use of orchestrations. The
IT manager of Adventure Works has asked you to create orchestrations for processing both
cash and credit sales orders. In this lab, you will create the orchestration for processing cash
sales orders. In subsequent labs, you will create the orchestration responsible for processing
credit sales orders.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-08 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose
Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click Ask Me Later, then click OK.
Create an Orchestration
Procedure List
1. In Solution Explorer, right-click Processes, point to Add, and then click New Item.
2. In the Add New Item dialog box, click Orchestration Files, click BizTalk
Orchestration, in the Name box, type ProcessOrder_Cash.odx, and then click Add.
The ProcessOrder_Cash orchestration opens automatically.
Create Messages
Procedure List
1. In Orchestration View, right-click Messages, and then click New Message.
2. In the Message_1 Properties window, in the Identifier box, type msgSalesOrder.
3. In the Message Type list, under Schemas, click <Select from referenced assembly>.
4. In the Select Artifact Type dialog box, in the left pane, click AdvWorks.Messaging, in
the right pane, click SalesOrder, and then click OK.
This is the message variable for the incoming sales order.
5. In Orchestration View, right-click Messages, and then click New Message.
6. In the Message_1 Properties window, in the Identifier box, type
msgSalesOrder_Complete.
7. In the Message Type list, under Schemas, click <Select from referenced assembly>.
8. In the Select Artifact Type dialog box, click in the left pane, AdvWorks.Messaging, in
the right pane, click SalesOrder, and then click OK.
This is the message variable for the completed processing acknowledgement
message.
9. In Orchestration View, right-click Messages, and then click New Message.
10. In the Message_1 Properties window, in the Identifier box, type msgRestock.
11. In the Message Type list, under Schemas, click <Select from referenced assembly>.
12. In the Select Artifact Type dialog box, in the left pane, click AdvWorks.Messaging, in
the right pane, click Restock, and then click OK.
This is the message variable for the restock message sent to the inventory
system.
19. Right-click the arrow immediately below the Construct msgRestock shape, point to
Insert Shape, and then click Send.
20. Configure the Send_1 shape with the properties shown in the following table.
Property Setting
Name Restock
Message msgRestock
Module objective:
In this module, you will learn:
Overview
Orchestration is a flexible, powerful tool for representing your executable business
processes. You can design the message flow, interpret and generate data, call custom code,
and organize it all in an intuitive visual drawing. It is important for you to become familiar
with the various shapes that Microsoft® BizTalk® Orchestration Designer provides to
represent the logical flow of your orchestration. You should also know how to manipulate
data and manage exceptions within an orchestration.
Lesson 1: Controlling the Flow of an Orchestration
Lesson objective:
Overview
Orchestration Designer provides a number of shapes that you can use to control the flow of
your orchestration. In this lesson, you will learn how to use and configure the Group and
Scope shapes to organize your orchestration and how to use different shapes to control
parallel processes and conditionally control the flow of messages through the orchestration.
Scope and Group Shapes
Explain how scope shapes and group shapes are used to organize actions in an orchestration.
Scope Shape
A scope acts as a framework for organizing actions. You use it primarily for transactional
execution and for exception handling. You also use a scope when you want to define
variables, messages, and correlation sets that must remain local within the scope and when
you need to use variables and classes that are non-serializable.
A scope contains one or more blocks or other nested scopes. It has a body and can have
appended to it any number of exception-handling blocks. It may also, depending on the
nature of the scope, include an optional compensation block. For more information on
compensation, see Module 10, “Creating Transactional Business Processes”.
Some scopes exist solely for the purpose of exception handling, and these do not require
compensation. In Microsoft .NET terms, a scope is a Try block that can have multiple catch
(exception-handling) blocks. Other scopes are explicitly transactional. Transactional scopes
always have a single compensation block and can include a time-out value. You can write
your own or use the default compensation handler.
The scope shape creates an additional context within the orchestration. The scope can have
its own variables, messages, and correlation sets. The memory used for these will be freed
up when all of the actions within the Scope shape complete.
Group Shape
A Group shape is used to arrange actions in an intuitive and visually manageable way. You
can use the Group shape as a placeholder for functionality yet to be added, or you can use it
to make annotations about what actions take place within it. The name property on the
Group shape can be up to 512 characters long. You can type annotations into the name
property, and when the shape is collapsed, the entire name will be displayed.
Orchestration Flow Control Shapes
Configure orchestration shapes to enable decision logic and event timing within an
orchestration.
Configure orchestration shapes to enable repeating actions and concurrent processing and to
suspend or terminate an orchestration process.
Expression Shape
The Expression shape allows you to enter complex expressions into your orchestration easily
and quickly; however, you cannot use it to enter an arbitrary amount of code. For example,
you can initialize and manipulate the values of your orchestration variables, assign values to
dynamic ports, or make a .NET call to run an external program. You use the Expression Editor
to define the expression.
Overview
Two shapes that can be used to make your business processes more understandable and
easier to deploy and test are the Call and Start Orchestration shapes. These two shapes let
you effectively nest orchestrations within other orchestrations whether they are
transactional or not.
Lesson objective:
Overview
Before you build an orchestration, you may need to designate specific fields as being
distinguished fields so that the data within a message can be referenced within an
orchestration. When building an orchestration, you can create expressions to make
decisions, set delays, make .NET calls, and test while loop conditions. You can also configure
correlation so that incoming messages can be matched with an instance of a currently
running orchestration. Finally, you can use exception handling to specify the actions that
must take place when an error occurs.
Distinguished Fields
Explain the purpose of distinguished fields and the difference between distinguished fields and
promoted properties.
Promoting a Distinguish field is done in the BizTalk Editor in Microsoft Visual Studio® 2010 by
right-clicking the node, pointing to Promote, and then clicking Show Promotions. The
resulting dialog box displays the Schema tree in the left pane and has Distinguished Fields
and Property Fields tabs. On the Distinguished Fields tab, select the node in the schema tree,
and then click Add. The node is added to the Property list with its corresponding XPath
listed.
msgSalesOrder(AdvWorks.Messaging.PropertySchema.OrderTotal)
Learn how to promote distinguished fields and then use a distinguished field in a decide shape.
msgSalesOrder_Complete.Comment =
“Processing of this order is now complete.”;
6. Right-click the placeholder below the Large branch, point to Insert Shape, and then
click Send.
7. Name the Send shape Snd Approval Request, and in the Message list, click
msgSalesOrder.
This will cause the orchestration to wait 30 seconds for an approval message.
8. Right-click the placeholder beneath the Delay shape, point to Insert Shape, and then
click Suspend.
9. In the Properties window, name the Suspend shape Timed Out, then click the Error
Message property, and then click the ellipsis (…) button, and enter the following line
of code, and then click OK.
System.String.Format(
“Order# {0} did not receive an approval to proceed.”,
msgSalesOrder.Detail.OrderNumber);
Using Expressions
The Expression shape enables you to create expressions within an orchestration. Expressions
can be used to add logic and to manipulate and test values. For example, you can initialize
and manipulate the values of your orchestration variables, assign values to dynamic ports
and message context, and make a .NET call to run an external program.
Expressions should not be used to perform high-level orchestration logic, which preferably
would be visible in the orchestration drawing itself. In general, it is easier to understand and
maintain your orchestrations if your Expression shapes contain simple and modular
expressions.
Expression Editor
The BizTalk Expression Editor enables you to create expressions to define the capabilities of
various orchestration shapes. Expressions created within the Expression editor are written
using C# syntax. An expression can span multiple lines, but it must end with single semicolon
(;). You can create expressions to make decisions, set delays, and test while loop conditions.
For more information, see “Shapes that Take Expressions” in BizTalk Help.
Only expressions created for the Expression shape can end in a semicolon; no other
expression can. This is because the expression for other shapes is a single Boolean test (the
equivalent of the contents of a set of parentheses in C#). In addition to the standard .NET
operators, you can also use the exists operator to determine if a value is present in a
message instance.
Using Expression Editor, you can assign values to messages or message parts in the Message
Assignment shape. You can also use Expression Editor to construct complex Boolean
expressions in the Loop and Decide shapes and set the delay in the Delay shape.
IntelliSense
The BizTalk Expression Editor is a standard Visual Studio text editor, which means that it
offers IntelliSense®. The IntelliSense feature will help guide you in creating expressions—for
example, it can display a list of class members for you when you type in a .NET class name
followed by a period (.).
Correlating Messages
What Is Correlation?
Correlation is a special variation on message routing that matches an incoming message to
the appropriate instance of an orchestration. Often, there may be many instances of a given
orchestration running, and although each of the instances will perform the same actions,
they will do so on different data contained in messages. For example, if your orchestration is
designed to issue a purchase order, receive an invoice, and then send a payment, you must
ensure that the invoice message is received by the orchestration instance from which the
corresponding purchase order was sent. (Imagine ordering a single item and receiving an
invoice for 1,000 items, or vice versa, and you can understand the importance of
correlation.) Likewise, if two related messages are meant to be kept together and sent
consecutively, you can use correlation to ensure that they are received in the proper order
by the same instance.
Correlation Sets
Each correlation set is based on a correlation type, which is simply a list of properties. These
properties might be data (found in the message itself) or context properties that describe
system-defined details or transport properties for the message that have no relation to the
data actually being conveyed in the message. In order to use message data for a correlation
type, the nodes must be promoted to make the values accessible to the messaging engine.
You can use a single correlation type in more than one correlation set. If you need to
correlate based on different values for the properties in a correlation type, you must create
a new correlation set, because each correlation set can be initialized only once.
Demonstration: Correlating Messages
Explain how exceptions are generated and how the BizTalk Exception Handler works.
Exceptions
Exceptions are raised by the orchestration engine when an error occurs in the orchestration.
Microsoft BizTalk Server provides various mechanisms for throwing and handling exceptions.
Exception Handler
When an exception occurs in a scope, each logical thread of execution in that scope stops.
The run-time engine attempts to locate an exception handler for the appropriate exception
type. If it succeeds in locating an exception handler that matches either the specific
exception type or one of its base types, control passes to that handler, and the exception
code runs.
Each scope shape within an orchestration may have one or more exception handler blocks
appended to it. The relative cost of catching and handling an exception is high, so as with
.NET exception handling, you should reduce the likelihood of exceptions occurring whenever
possible. Don’t use exception handlers to catch common conditions; use a decide shape
instead. For example, it’s always easier to determine if you are going to divide by zero than
to catch a divide-by-zero exception.
Each exception block can contain zero or more orchestration shapes, which act exactly as
they do in an orchestration. As a result, anything that can be done in an orchestration can be
undone with an exception handler. In some situations, you may want to catch an exception
and not do anything as a result. This will prevent the exception from being passed up to the
next scope looking for an exception handler.
The arrangement of exception handlers is important in situations in which multiple
exceptions blocks exist. The first block that can catch the exception will catch it and execute
without evaluating other handlers. Place the most specific exceptions first working toward
more general exceptions, the most general of which is the General Exception.
Note: The process of adding and configuring exception handing for an orchestration is
covered in detail in the Module 10 Lab.
Scenario
BizTalk orchestrations can be used to automate business decisions and other processes. In
this lab, you will create a new BizTalk orchestration that will process credit sales orders.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-09 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose
Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click Ask Me Later, then click OK.
You will make the necessary changes to the Else branch in a later lab.
Exercise 4: Create Orchestration Ports
Overview
The ports in this orchestration ports are configured as late bound (Specify Later), so they
must be bound to a physical port after the assembly is deployed. Using late binding
separates the design of an orchestration and its implementation. In this exercise, you will
add a new late bound orchestration port and reconfigure the existing ports to use late
binding.
In the previous lab, this orchestration was configured with “early binding,”
meaning that the physical ports were automatically created and bound to the
logical ports when the assembly was deployed. In this lab, you are using late
binding, so the logical ports must be bound to the physical ports manually.
10. In the Configure Application dialog box, click ProcessOrder_Credit, configure the
settings using the information in the following table, and then click OK.
Property Setting
Host BizTalkServerApplication
SalesOrder SalesOrder
Restock RestockFILE
SO_Complete CompleteFILE
BankNotification BankNotifyFILE
Both orchestrations use the SalesOrder receive port. The filter expressions you
configured on the receive shapes in each orchestration will prevent an
orchestration from getting any message it shouldn’t.
11. In the BizTalk Server Administration Console, right-click AdventureWorks, click Start,
and then in the Start ‘AdventureWorks’ Application dialog box, click Start.
12. In Windows Explorer, navigate to C:\AllFiles\LabFiles\Lab9, and then copy all four
XML files to the SalesOrderIN folder.
It may take a moment for the messages to be processed and moved from the
SalesOrderIN folder.
13. Open the OUT folder, and then examine each of the messages.
Notice that the Cash and Restock orders have been processed and that the Credit
order over $1000 has a BankNotify message.
14. Close all open windows.
Module 10: Creating Transactional
Business Processes
Time estimated: 90 minutes
Module objective:
In this module, you will learn:
Overview
A Microsoft® BizTalk® Server orchestration provides a transactional programming model
that includes support for both atomic and long-running transactions, in addition to support
for nested orchestrations, exception handling, and methods for recovering from failed
transactions.
Lesson 1: Introduction to Transactions
Lesson objective:
Explain how transactions work and how persistence points affect the performance of a BizTalk
orchestration.
Overview
BizTalk orchestration provides a transactional programming model that includes support for
exception handling and recovery from failed transactions. You can create atomic
transactions that automatically roll back their actions if an error occurs or long-running
transactions that can contain other transactions and custom exception handling. This means
that if your business process fails for any reason, you can choose what happens, whether it’s
sending an error notification to a person or system or updating a SQL database.
What Are Transactions?
Overview
The BizTalk Server orchestration engine manages the state of running processes, applies
business logic, and supports the invocation of complex processes and transaction sets, as
well as the persistence of running and saved business processes. Business processes can be
composed as discrete pieces of work that can consist of:
Atomic transactions that automatically roll back all changes in case of errors, much
like database transactions.
Long-running transactions that can span days, weeks, and longer time durations;
they contain nested transactions and use custom exception handling to recover
from error scenarios.
Scopes
These transactional mechanisms are managed through Scope shapes in the Orchestration
Designer. A scope contains one or more blocks. It has a body and can optionally have
appended to it any number of exception-handling blocks. It may have an optional
compensation block as well, depending on the nature of the scope. Each Scope shape that is
added adds an additional Context, which has its own Messages, Variables, Segments, and
Class Types.
What Is Instance Persistence?
Describe what a persistence point is and how a persistence point affects performance of a
BizTalk orchestration.
Persistence
The orchestration engine saves the entire state of an orchestration instance at various
points during processing to the BizTalk MessageBox Database. This enables BizTalk to
recover an orchestration from a catastrophic failure or to conserve memory for a business
process that may be waiting hours, weeks, or days for input before processing can continue.
If the orchestration engine needs to rehydrate the orchestration instance, start up from a
controlled shutdown, or recover from an unexpected shutdown, it will run the orchestration
instance from the last persistence point as though nothing else had occurred. For example, if
a message is received, but there is an unexpected shutdown before state can be saved, the
engine will not record that it has received the message, and it will receive it again upon
restarting.
Persistence Points in an Orchestration
Persistence Points
The state of an orchestration includes any Microsoft .NET–based components that may be
used in the orchestration, in addition to all messages and variables. The engine stores state
at the following persistence points:
End of a transactional scope (atomic or long running).
Debugging breakpoints.
The execution of other orchestrations through the Start Orchestration shape.
A Send shape; except when contained by an atomic transaction, or immediately
followed by the end of the orchestration.
When an orchestration instance is suspended.
When the system is shut down in a controlled manner.
When the engine determines that it will dehydrate the orchestration instance.
When an orchestration instance completes.
Steps for Setting Up a Transaction
Steps
The steps for setting up a transaction within an orchestration and configuring exception
handling are:
1. Create a scope.
2. Identify the type of transaction that is needed and configure the scope as
transactional; also identify an appropriate value for the transaction timeout.
3. Determine the level at which the transaction will be compensated, if at all.
4. Identify the potential errors that will cause the need for compensation.
5. Add the appropriate exception handlers to scopes.
6. Define the code that will be used to compensate the completed transaction.
Lesson 2: Configuring Transactions
Lesson objective:
Overview
An orchestration or scope can be treated as an atomic transaction, a long-running
transaction, or neither. In this lesson, you will learn how to configure long-running and
atomic transactions, how to create modular orchestrations, and how to add compensation
code to your transactions.
Defining an Orchestration as Transactional
Overview
You can configure your orchestration as a transaction in much the same way that you can
configure a Scope shape as a transaction. An orchestration can be treated as an atomic
transaction, as a long-running transaction, or as neither. The transaction type is specified by
setting the Transaction Type property for the orchestration to Atomic, Long Running, or
None.
You cannot nest a transactional scope within a scope or orchestration that is not
transactional. An enclosing scope or orchestration that is not transactional will not manage
state as is necessary to properly handle the state management of any scopes within it.
Creating a Long-Running Transaction
Overview
You use a long-running transaction when the transaction may need to run for an extended
time and you do not need full ACID (Atomicity, Consistency, Isolation, and Durability)
properties—that is, you do not need to guarantee isolation of data from other transactions.
A long-running transaction may include long periods of inactivity, often because it is waiting
for external messages to arrive.
Characteristics
Long-running transactions possess consistency and durability, but not atomicity and
isolation. The data in a long-running transaction is not locked; therefore, other processes or
applications can modify it. The isolation property for state updates is not maintained within
the orchestration because holding locks for a long duration is impractical. A long-running
transaction is considered committed when the last statement in it has been completed.
Long-running transactions can contain both atomic transactions and other long-running
transactions—in fact, they can be nested many levels deep. For example, your long-running
transaction may contain two other long-running transactions, each of which contains atomic
transactions. Nesting is particularly useful if one or more components of an overall
transaction must be atomic but the overall transaction itself must be long running.
Example
Consider the process of receiving and approving a loan application. The application can
arrive at any time, and the various steps in the process of fulfilling the application may take a
considerable time, but you may still want to treat the entire process as one transaction. In
this case, the overall transaction clearly needs to be long running, but any one individual
step (such as acknowledging a deposit) could be atomic.
Creating an Atomic Transaction
Overview
Atomic transactions guarantee that any partial updates will be rolled back automatically in
the event of a failure during the transactional update and that the effects of the transaction
will be erased. You can use atomic transactions when you require full ACID properties on the
data, such as when you must isolate the data from other transactions. However, the full
ACID properties are only achieved when making updates or communicating with a system
that is transactional aware. For example, if you are updating a Microsoft SharePoint® site or
sending an e-mail message, an automatic rollback may not be achieved.
Characteristics
An atomic transaction ensures that state changes within the transaction (such as
modifications to variables, messages, and objects) are visible outside the scope of the
atomic transaction only upon commitment of the transaction. The intermediate state
changes are isolated from other parts of an orchestration.
If an atomic transaction contains a Receive shape, a Send shape, or a Start Orchestration
shape (a shape that invokes another orchestration asynchronously), the corresponding
actions will not occur until the transaction has been committed.
Atomic Orchestrations
You can also define an entire orchestration as an atomic transaction when you need to
provide ACID properties for the data within an entire orchestration. See “Defining an
Orchestration as Transactional” earlier in this module.
Creating Modular Business Processes
Overview
You can use either the Call Orchestration shape or the Start Orchestration shape to invoke
one orchestration from another. You can nest orchestrations many levels deep. For example,
a called orchestration can call a third orchestration, which can call a fourth, and so on.
Parameters
In either case, you can specify parameters to be passed to the called orchestration.
Parameters can be messages, variables, or port references. Parameters supply information
to the invoked orchestration, which in turn sends information back to the enclosing
orchestration. Parameters can be specified as in, out, or to be passed by reference on an
orchestration instance.
Demonstration: Creating Transactions
msgCancelOrder = msgSalesOrder;
msgCancelOrder.Comment =
System.String.Format(
“Order canceled. Error: Delivery of loan document failed.
[{0}]”,
ex.Message);
8. Right-click beneath the Message Assignment shape, point to Insert Shape, and then
click Send.
9. In the Send Shape Properties window, change the Name to Cancel Order, and then
in the Message list, click msgCancelOrder.
10. Connect the Send shape to the CancelOrder port.
11. Right-click beneath the Message Assignment shape, point to Insert Shape, and then
click Terminate.
12. Double-click the Terminate shape, and in the BizTalk Expression Editor window,
enter the following line of code.
This exception block will create a new message to cancel the order, and then it
will terminate the orchestration.
13. Pause the bt10d-demos virtual machine.
Adding Compensation Code
Overview
You can add compensation code to your orchestration so that if an error occurs during a
long-running transaction, the effects of the transaction will be reversed. When necessary,
the compensation code is called after the transaction has completed its actions. At that
point, the state of the orchestration is known, and the appropriate compensation code can
be applied.
You can also use compensations for atomic transactions. These compensations can be called
only after the atomic transaction commits. You must write code to undo or reverse the path
of the normal execution in the compensation.
Default Compensation
If you do not add your own compensation, the run-time engine performs a default
compensation that invokes the compensations of any nested transactions in the current
transaction. The run-time engine first invokes the compensation of the most recently
completed transaction, and then it works backward until it has compensated all nested
transactions.
Demonstration: Adding Compensation Code
msgCancelOrder = msgSalesOrder;
msgCancelOrder.Comment =
“Customer cancelled order. Transaction Compensation executed”;
7. Right-click beneath the Message Assignment shape, point to Insert Shape, and then
click Send.
8. In the Send Shape Properties window, change the Name to Cancel Order, and then
in the Message list, click msgCancelOrder.
9. Connect the Send shape to the CancelOrder port.
This scenario assumes that additional shapes will eventually be added to follow
after the Send Loan to Lender scope shape.
This compensation block would execute if any of those subsequent shapes threw
an exception. The orchestration’s default exception handler would catch the
exception, and execute the compensation blocks on any of its scope shapes.
This compensation block would create and send a new message to cancel the
order, and then it will return control to the orchestration run-time, allowing
other compensation blocks to execute.
10. Close all open windows, and shut down the bt10d-demos virtual machine.
Lab: Creating Transactional Business Processes
Scenario
Exception handling can be added to scope shapes within orchestrations to specify actions to
be executed in the event that an exception occurs. BizTalk orchestrations can include both
long-running and atomic transactions. Compensation, a feature of transactions, allows for
the reversal of previously completed processes. In this lab, you will configure exception
handling and compensation for the ProcessOrder_Credit orchestration.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-10 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose
Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click Ask Me Later, then click OK.
Configure the Orchestration and the Send Loan to Lender Scope Shape as a Long-
Running Transaction
Procedure List
1. Click any white space on the ProcessOrder_Credit orchestration, in the Properties
window, in the Transaction Type list, click Long Running, and then in the
Transaction Identifier box, type LR_ProcessOrder_Cred.
2. In the ProcessOrder_Credit orchestration, click the Send Loan to Lender scope
shape, and then configure its properties as shown in the following table.
Property Value
3. Drag the Construct msgRestock and Restock send shapes to a location inside the
Restock Inventory scope shape.
2. Right-click the Completed Sales Orders scope shape, and then click New
Compensation Block.
3. In the Compensation_1 Properties window, change the Name to Complete Sales
Order Comp.
4. In the Complete Sales Orders Comp compensation block, right-click Drop a shape
from the toolbox here, point to Insert Shape, and then click Send.
5. In the Send_1 Properties window, change the Name to Rescind Complete Sales
Order, and then in the Message list, click msgSalesOrderComplete.
6. Connect the Rescind Complete Sales Order send shape to the CompletedSalesOrder
operation on the Rescind port.
Exercise 3: Calling Compensation
Overview
Transactions can be nested to provide a parent/child hierarchy. Parent transactions can call
the compensation for each child transaction from the parent’s exception handler, or as part
of the parent’s compensation. In this exercise, you will first add a long-running transaction
to the orchestration. Next, you will move all the existing shapes, including the transactional
scope shapes, into the parent transaction. Finally, you will add an exception handler to the
parent transaction that will call the compensation of some of the child transactions.
3. Double-click the icon at the top of the Send Loan to Lender scope shape to collapse
it.
4. Repeat step 3 to collapse the Restock Inventory scope shape and the Completed
Sales Order scope shape.
5. Drag the Completed Sales Order scope shape inside the Credit Process scope shape.
6. Drag the Restock Inventory inside the Credit Process scope shape, and above the
Completed Sales Order scope shape.
7. Drag the Send Loan to Lender scope shape inside the Credit Process scope shape,
and above the Restock Inventory scope shape.
Host BizTalkServerApplication
SalesOrder SalesOrder
Restock RestockFILE
SO_Complete CompleteFILE
Host BizTalkServerApplication
SalesOrder SalesOrder
BankNotification BankNotifyFILE
Rescind RescindFILE
Restock RestockFILE
SO_Complete CompleteFILE
Module objective:
In this module, you will learn how to compose and deploy business rules.
Overview
The Microsoft® BizTalk® Server Business Rule Engine allows business users to work with
developers to create and maintain policies containing business rule sets. These policies can
be quickly updated and immediately applied without the need to recompile and redeploy a
BizTalk assembly. Policies can be called from within a BizTalk orchestration and from other
Microsoft .NET applications. This module provides an overview of the Business Rule Engine
and describes the use of policies, rules, and vocabularies. This module also covers execution
of business policies from BizTalk Server 2010.
Lesson 1: Introduction to Business Rules
Lesson objective:
Describe the concepts and terminology used when working with business rules in BizTalk Server
2010.
Lesson Overview
Because an organization’s business rules can change frequently, BizTalk Server enables you
to create business rules that can be modified quickly and easily to meet changing business
needs and the needs of your customers. In this lesson, you will learn what a business rule is
and how business rules are integrated into a BizTalk application environment. You will also
see how developers, business analysts, and administrators work together in order to create,
deploy, and maintain business rules.
What Are Business Rules?
Describe business rules and explain how they can be used to make business decisions.
Business Rules
Business rules are statements that govern the conduct of business processes. A policy is a
collection of related rules that are evaluated together, for example, a bank’s loan approval
policy might be composed of several different rules that need to be evaluated. The policy is
executed, and each rule is evaluated and possibly applied.
Each rule consists of a condition (an if clause) and a resulting action (a then clause). The
conditions and actions can be quite simple or very complex. The condition is evaluated, and
if it evaluates to True, the specified actions are performed by the rule engine. Unlike in most
programming models, there is no else action. For example, if you want to perform an action
on all purchase orders, but the action varies based on the total order amount, you would
need to create two rules, one for purchase orders with a total of less then $1,000 and one
rule for purchase orders with totals greater than or equal to $1,000. These two rules would
make up the discount policy.
Within a policy, the various rules can have different priorities assigned. These priorities do
not modify the order of evaluation but rather the order that the rules are fired in. That is, if
multiple rules are to be fired (on the agenda), the priority will determine the order that the
rules are applied. In this case, the rule that has the highest assigned priority will be fired.
Example
Consider the following example business rule from the preceding illustration.
A manufacturer has received a purchase order from a customer and needs to fulfill the
purchase order request. In order to process the purchase order, the manufacturer must
answer a series of questions:
Is this purchase order from an existing customer or a new customer? If the customer
is new, the customer must be added to the database. If the customer already exists,
the next step in the business rule can be called.
Is the product being ordered a product that we manufacture? If so, we can continue
processing the purchase order. If not, the purchase order must be declined.
Can we supply the product being requested? If the quantity on hand is less than the
order quantity, we can supply the product. If not, we will either have to decline the
purchase order or send a backorder notice.
Notice in the example that each question can be answered either True or False. These rules
apply basic business logic to find out whether or not a purchase order can be fulfilled.
Business rules can be used to:
Trigger notifications. For example, if a product is low on inventory, a business rule
could trigger a reorder notice for the product.
Automate approvals. You could use a business rule, for example, to route
documents with a total order amount over $10,000 to a manager for approval.
Reroute documents. If a purchase order is from a new customer, you could route the
purchase order to another business process that handles new customers.
Overview
The following sections describe common business rule terminology.
Rule
Business rules are statements that govern the conduct of business processes. Business rules
consist of a condition and one or more consequent actions. Conditions are true/false,
otherwise known as Boolean expressions, that consist of one or more predicates applied to
facts. Multiple conditions can be combined to provide for complex computations. Complex
conditions can be constructed by joining multiple simple conditions using AND, OR, and NOT
modifiers. For example, when evaluating a customer order, you could have a rule such as: If
customer exists AND total order amount > 1000 OR if customer exists AND customer rating =
excellent THEN set discount amount = 10%.
Policy
Policies are logical rule sets. You compose a version of a policy, save it, test it by applying it
to facts, and when you are satisfied with the results, publish it and deploy it to a production
environment. Policies are versioned and deployed, so if a rule changes, you simply create a
new version of the policy, test the policy, and then deploy it. You do not have to recompile
or modify orchestrations or other business processes that are using a particular business
policy.
When called from an orchestration, the Business Rule Engine will always execute the latest
version of a policy. Changes made to a business rule policy will be immediate. The next time
the policy is called from an orchestration, the most recently deployed version will be used.
After it is published, a business rule policy is immutable and can be changed only by creating
a new version.
Vocabulary
Vocabularies are user-defined names for the facts used in rule conditions and actions.
Vocabulary definitions render rules easier to read, understand, and share for the various
workers within a particular business domain. For example, the source location for a
particular fact might be a field in a particular record within a database, represented as an
SQL query. Instead of employing the SQL query (an abstract procedural statement, difficult
for most people to memorize or recognize) in the rule, a name meaningful to all the relevant
parties in the development and deployment process can be associated with the query by
creating a vocabulary definition. When you create a new vocabulary definition, you can
choose from one of the following:
Rule Store
The rule store is a repository for business policies and vocabularies. Policies and vocabularies
are deployed to the rule store. The rule store is by default the Business Rule Database
(BizTalkRuleEngineDb). This database is created when configuring business rules for the
BizTalk group. Additionally, policies and vocabularies can be exported to an XML file to
simplify modification and deployment between test and production environments.
How Rules and Facts Work
Business Rules
A business rule consists of a condition and one or more resulting actions. As mentioned
before, business rules are If/Then conditions, and there is no Else clause. Each business rule
either returns True or False.
Conditions
A condition is a True/False (Boolean) expression that consists of one or more predicates
applied to facts. Predicates can be combined with the logical connectives AND, OR, and NOT
to form a logical expression that is potentially quite large but that will always evaluate to
either True or False.
Actions
An action is the functional consequence of condition evaluation. If a rule condition is met, a
corresponding action or actions are initiated. Actions are represented in the Business Rule
Framework as Microsoft .NET–based objects or as set operations on XML documents or
database tables. For example, if a business rule that checks whether or not a customer is
preferred returns true, you could then call a method of a .NET class to execute code in the
class. You could also update elements or attributes in an XML schema document, or you
could update data in a Microsoft SQL Server™ database. You can execute more than one
action within the THEN clause.
Facts
Facts are the data that rules use to make decisions. Facts can be derived from multiple data
sources and must be fed into the rule engine through pre-defined vocabularies, XML
schemas, .NET classes, or database row sets. Many facts are instance facts that will be
different for each firing of the rules. For example, the customer name and account number
fields in a PO message are instance facts. Other facts may be long term. For example,
interest rates usually change infrequently and do not need to be looked up each time a rule
is fired. Long-term facts are determined once and then held in the cache until refreshed,
whereas instance facts are determined for each rule execution. A fact can be configured as a
long-term fact by setting the Fact Retriever property for each version of the policy in the
properties window for the version of the policy. A fact retriever object must be created to be
able to fetch the facts from a persistent storage and present them to the policy object.
For More InformationFor more information on creating a long-term fact, refer to the BizTalk
Server 2010 documentation “Creating a Fact Retriever” and “Short-Term Facts vs. Long-Term
Facts.”
Business Rule Execution
The Business Rule Engine uses a three-stage algorithm for policy execution. The stages are as
follows:
Match. In the match stage, facts are matched against the predicates that use the fact type
(object references maintained in the rule engine's working memory) using the predicates
defined in the rule conditions. For the sake of efficiency, pattern matching occurs over all
the rules in the policy, and conditions that are shared across rules are matched only once.
Partial condition matches may be stored in working memory to expedite subsequent
pattern-matching operations. The output of the pattern-matching phase consists of updates
to the rule engine agenda.
Conflict resolution. In the conflict resolution stage, the rules that are candidates for
execution are examined to determine the next set of rule actions to execute based on a
predetermined resolution scheme. All candidate rules found during the matching stage are
added to the rule engine's agenda.
The default conflict resolution scheme is based on rule priorities within a policy. The priority
is a configurable property of a rule in the Business Rule Composer. The larger the number,
the higher the priority; therefore if multiple rules are triggered, the higher-priority actions
are executed first.
Action. In the action stage, the actions in the resolved rule are executed. Note that rule
actions can assert new facts into the rule engine, which causes the cycle to continue. This is
also known as forward chaining. It is important to note that the algorithm never preempts
the currently executing rule. All actions for the rule that is currently firing will be executed
before the match phase is repeated. However, other rules on the agenda will not be fired
before the match phase begins again. The match phase may cause those rules on the agenda
to be removed from the agenda before they ever fire.
Business Rules Orchestration Scenarios
Overview
You can integrate business rules into your orchestrations to support a variety of scenarios:
You can use rules to determine whether another business process needs to be
executed. For example, after successfully placing a customer order, you might want
to call a second orchestration that handles the shipping of orders.
You can use rules to evaluate business logic and to determine when a business
process requires a variable delay. For example, you might set up a loop to check on
the status of an item to see if the item is in stock. After initially checking the stock of
an item that is not available, the rule delay would be one minute. The next time, the
rule would wait five minutes before executing, the following time, the rule would
wait 30 minutes before executing, and so on.
You can use rules to determine the execution path for a business process, basing the
determination on the results of the rule execution. For example, if the customer
submitting the purchase order does not exist in the database, you could route the
document to another business process to add the customer to the database before
continuing to process the purchase order.
Identifying Business Rule Personas
Overview
The Business Rules Framework incorporates a graphical user interface—the Business Rule
Composer—that developers, information workers, and administrators can all use in various
ways to develop and apply both rules and policies.
Developers can:
Create the orchestrations from which the business rules will be called, and they
define the action to be taken when a decision is returned to the orchestration. As
long as the decision path within the orchestration does not change, the
orchestration will not need to be redeployed.
Create the initial business rule policies and create vocabularies to make it easier for
information workers to edit and understand business rule policies.
Information workers can:
Design, test, and manage business policies. Changes made to a BRE policy will be
executed from an orchestration without having to recompile and redeploy the
BizTalk assembly. The BRE always calls the latest deployed version of the policy.
Administrators can:
Secure business rule policies. By default, when a new policy or vocabulary is created
in the rule store, only the user who created it and the rule engine administrator
have both read/execute and modify/delete access. The rule engine administrator
can configure which users have the access level, or rights, to perform different
operations (processes operate under user credentials).
Deploy business rule policies from one physical environment to another. Deploying
business rules to other physical environments is accomplished by using the Rules
Engine Deployment Wizard and is covered later in this module. Rules can also be
exported and imported using Microsoft Windows® Installer (MSI) packages.
Monitor the results of executed business rules by using the BizTalk Administration
Console. This tool allows auditing of the rules-based decision made within each
orchestration instance.
Lesson 2: Integrating Business Rules
Lesson objective:
Overview
BizTalk provides several tools for developing and deploying business rules and for applying
them to business processes. In this lesson, you will learn how to integrate a business rule
policy into an orchestration and how to use the Business Rule Composer to create easy-to-
understand vocabularies and policies. These policies can then be versioned and deployed
before being called from an orchestration. You can also track business rules to find out the
true or false outcome of a rule.
Steps for Integrating Business Rules
If
Company.Namespace.ShoppingCart.PurchaseAmount > Qualifying
Amount as System.Decimal
Then
Company.Namespace.Customer.DiscountAmount =
Company.Namespace.ShoppingCart.PurchaseAmount * .1
Deploy policies.
Overview
After a policy is published, it must be deployed before it can be used by external processes.
The shortcut menu in the Business Rules Composer has an option to deploy the policy. The
Rule Engine Deployment Wizard, found on the BizTalk program menu, can be used to export
and import business rule policies to and from a Business Rule Language (BRL) file and to
publish policies to the SQL rule store. You can use this wizard in development, staging, and
production environments.
BizTalk Server provides the ability to import, export, deploy and undeploy policies and
vocabularies in the Business Rules database by using the BizTalk Server Administration
Console. This assumes, however, that the policies and vocabularies are exported and
imported as part of a BizTalk application’s MSI package.
You may also export and import policies and vocabularies as XML files by using the Rule
Engine Deployment Wizard.
The Rule Engine Deployment Wizard allows you to:
Export a version of a policy or a vocabulary from an SQL rule store into a file rule
store. This creates an XML file that contains the configuration information for the
policy or vocabulary being exported. This XML file can then be copied to another
computer to be imported at a later date.
Import a version of a policy or vocabulary from a file rule store into an SQL rule
store.
Deploy a version of a policy and publish a vocabulary from an SQL rule store to a
production SQL rule store so that the policy can be run within a rule-based
application. Deploying a rule makes the rule available to other business processes.
Undeploy a version of a policy and remove a vocabulary from an SQL rule store to
make the policy unavailable for use by a rule-based application. Undeploying a
version of a policy does not remove the policy from the database. The policy is still
saved in the Rules Engine database, but it cannot be used by other applications. Use
this if you want to revert to a previous version of the policy.
Integrating Business Rules into an Orchestration
Tracking Options
To configure tracking properties for a policy, right-click the policy to access its properties and
to configure tracking. There are four options for tracking business rules from the BizTalk
Server Administration Console:
1. Fact Activity. Select this check box when tracking the instance data on which the
policy operates.
2. Condition Evaluation. This check box allows you to track the True/False result of the
conditions in the selected policy.
3. Rule Firings. This check box allows you to track the actions triggered as a result of
the policy.
4. Agenda Updates. Select this check box when you want to track updates to the
agenda, which contains a list of actions that evaluated to True and a list of rules that
fired.
Once you have turned on tracking for your business policies, execute your queries as normal
in the BizTalk Server Administration Console. You should see a link to access the business
rule execution for each message that was processed by the Business Rule Engine. You can
then see the True/False values of policies that were executed in the BRE along with the
If/Else condition that was evaluated.
Polices that have been added to an application can be managed with the rest of the
application. This includes the ability to undeploy policies and to include the policies when
the MSI is exported. Undeployed policies will still be visible within the application. In this
way, policies can be managed by undeploying and redeploying the application as necessary.
Lab: Integrating Business Rules
Scenario
The Microsoft Business Rule Engine (BRE) enables you to apply declarative rules based on
messages from BizTalk orchestrations. Using the BRE enables you to separate the
implementation of the business process (orchestration) from business decisions that are
likely to change over time. Vocabularies are a collection of easy-to-read definitions for the
facts used by the BRE. When vocabularies are used to create rules, the rules can easily be
updated and maintained by business analysts who have little or no understanding of the
BizTalk implementation. In this lab, you will create a vocabulary with several definitions. You
will then create a rule policy by using the vocabulary you created. Finally, you will integrate
the Business Rule Engine policy into an orchestration.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-11 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose
Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click Ask Me Later, then click OK.
Create Messages
Procedure List
1. In Orchestration View, right-click Messages, and then click New Message.
2. In the Message_1 Properties window, in the Identifier box, type msgInterimLoan, in
the Message Type list, expand Schemas, and then click
AdvWorks.LoanApproval.FinalLoanDocument.
3. In Orchestration View, right-click Messages, and then click New Message.
4. In the Message_1 Properties window, in the Identifier box, type msgLoanApp, in the
Message Type list, expand Schemas, and then click
AdvWorks.LoanApproval.LoanApplication.
msgLoanApp.LoanConditions.LoanStatus==“Approved”
parFinalLoan.Loan.Amount =
msgLoanApp.LoanConditions.LoanAmount;
parFinalLoan.Loan.LoanToIncomeRatio =
msgLoanApp.LoanConditions.LoanToIncome;
parFinalLoan.Loan.Status =
msgLoanApp.LoanConditions.LoanStatus;
parFinalLoan.Loan.Term = msgLoanApp.LoanConditions.Term;
4. Change the Expression in the Add Loan Properties shape below the Else branch to
the following expression (four lines).
msgInterimLoan.Loan.Amount=msgLoanApp.LoanConditions.Loa
nAmount;
msgInterimLoan.Loan.LoanToIncomeRatio =
msgLoanApp.LoanConditions.LoanToIncome;
msgInterimLoan.Loan.Status=msgLoanApp.LoanConditions.LoanStatu
s;
msgInterimLoan.Loan.Term=msgLoanApp.LoanConditions.Term;
5. Right-click below the construct message shape in the Else branch, point to Insert
Shape, and then click Send.
6. Right-click below the send shape in the Else branch, point to Insert Shape, and then
click Receive.
7. Configure the Send and Receive shapes as shown in the following table.
Send Shape
Property Value
Initializing Correlation ManualApprovalCorrSet
Set
Message msgInterimLoan
Name SharePoint Processing
Receive Shape
Property Value
Following Correlation Set ManualApprovalCorrSet
Message parFinalLoan
Name SharePoint Processing
3. Right-click the right Port Surface, and then click New Configured Port.
4. Configure the port as shown in the following table.
Property Value
Name SharePointResp
Port Type Name (existing Port Type) SharePointType
Direction Receive
Binding Specify later
5. Connect the Send shape to the SharePointReq port, and then connect the Receive
shape to the SharePointResp port.
6. In Solution Explorer, right-click the AdvWorks solution, and then click Build Solution.
msgFinalLoan.Loan.Status=="Approved"
5. Drag a Send shape from the Toolbox to the Else branch of the Is Loan Approved?
decide shape.
6. In the Properties window, in the Name box, type Loan Denial, and then in the
Message list, click msgSalesOrder.
7. Drag the Loan approved so several things need to be done group shape to the
Approved branch of the Is Loan Approved? decide shape.
Configure a Send Port
Procedure List
1. Right-click the right Port Surface, and then click New Configured Port.
2. Configure the port as shown in the following table.
Property Value
Name LoanDenial
Port Type Name (new Port Type) LoanDenialType
Direction Send
Binding Specify later
3. Connect the Loan Denial send shape to the LoanDenial send port.
4. In Windows Explorer, navigate to C:\AllFiles\LabFiles\Lab11, and then open
ProcessOrder_Credit.png.
Your ProcessOrder_Credit orchestration should look similar to the one shown in
this picture.
5. Close ProcessOrder_Credit.png.
Module objective:
In this module, you will learn how to monitor business activity by using Business Activity
Monitoring (BAM).
Overview
Getting the correct information at the correct time is of critical importance to any business.
Business deals and partnerships are often made or broken solely over questions of
information access. The decisive advantage frequently goes to the business that is armed
with the best information.
The Business Activity Monitoring (BAM) Framework in Microsoft® BizTalk® Server gives you
just such an indispensable advantage. By opening a real-time window into running business
processes, BAM provides business analysts with a direct view of transactions as those
transactions occur—a view that has traditionally been unavailable.
Lesson 1: Introduction to Business Activity Monitoring
Lesson objective:
Explain Business Activity Monitoring and why it can be an important feature of BizTalk Server
solutions.
Gaining Visibility into Business Processes
Describe how BAM is used to gain visibility into running business processes.
Overview
Business Activity Monitoring (BAM) is a tool for monitoring and analyzing data from business
process information sources. The data is presented in a real-time view of business state,
trends, and critical conditions. BAM’s open application programming interface (API) can be
used to gain visibility into data external to BizTalk processes, such as archival data or other
non-BizTalk processes and systems. BAM gives business analysts the data they need when
they need it, enabling them to make better business decisions based on more relevant data.
BAM provides interceptors that can gather data from messages as they are received and
from any point within the business process, such as an orchestration, pipeline, or message
type. BAM also provides auditing capabilities by being able to answer the how and why
behind business decisions.
BAM allows you to determine how your business is performing by answering questions such
as:
1. How long did it take for this process to be approved?
2. How quickly was this order filled after it was received?
3. How many process cycles occurred in the last month? In the last year?
4. How many purchase orders were processed last week?
5. How much is our total revenue this year so far?
By aggregating data, BAM provides an overview of trends experienced in the business while
allowing users to examine individual instances. You can also use BAM to link together
various messages as they travel through the system to create a unified BAM view, which
gives visibility of the entire business process, spanning multiple orchestrations and even
including data external to BizTalk. This visibility is tremendously beneficial for making critical
business decisions.
BizTalk administrators sometimes use BAM to gather and monitor IT operations data in
addition to monitoring business data. Using BAM to monitor IT operations can be
particularly useful when supporting Service Level Agreements.
What Is Business Activity Monitoring (BAM)?
Give a brief introduction of Business Activity Monitoring and the business value that it provides.
Overview
BAM makes it possible for developers, business analysts, and end users, working individually
or collaboratively, to extract the data they need from their business processes.
To gather the necessary business data for business analysts to make decisions regarding
business processes, the business analyst and developer will need to work together to create
one or more BAM activities. BAM activities represent a unit of work in a business, such as
processing a purchase order or a loan application. Activities are used to show the history, or
milestones, and data about a unit of work to the business analysts. BAM activities are
independent of the actual implementation of your BizTalk Server solution. Think of a BAM
activity as a record in a SQL table that you are keeping in synchronization with the actual
unit of work. You can relate multiple BAM activities together as well. An example of relating
activities would be a situation in which a single purchase order contains multiple shipments.
Properly configured BAM activities can allow business users to look at a purchase order and
be able to see shipping information for each item in the purchase order. Developers can use
the BAM API to create BAM activities that span multiple disparate systems. For example, if
one step in a loan process is to execute a Web service or make a call to a mainframe system,
business analysts can include this data in their analysis. BAM activities can also contain
milestones (a date/time measure) throughout the business process that allow business
analysts to see the overall progress of the process and investigate each individual step of the
process.
Key performance indicators (KPIs) allow business analysts to view specific pieces of data in a
business process.
Business analysts can also define views to specify how the activity data will be displayed.
Views can be used to filter the data from BAM. This can be useful if analysts want to see
loans that were processed from a certain state or by a certain loan officer or between two
dates. Filtering allows business analysts to focus only on the data they need to answer
questions on how their business is performing. BAM databases can be shared across BizTalk
Server groups to present an aggregated view of a business process.
Additionally, BAM views can be used to secure and filter information for different audiences.
Overview
The Business Activity Monitoring Framework includes interceptors for both pipelines and
orchestrations. These interceptors retrieve specific data as it is being processed and send
the data to the Primary Import database. The other components that BAM utilizes include:
BizTalk Primary Import database. This database acts as the principal collection point for
real-time data collected by the BAM interceptors. This database contains stored
procedures, tables, triggers, and views that are dynamically generated based on the
BAM Definition Workbook. Data for a specified database is maintained in the Primary
Import tables and is then moved to the archive database.
BAM activity aggregations and OLAP cubes. The activity aggregations are maintained in
the form of online analytical processing (OLAP) cubes, which are dynamically generated,
along with the necessary Data Transformation Services (DTS) packages and a staging
database for non-real-time data.
Real-Time Aggregations (RTA). These are special tables, created in the Primary Import
database, that have triggers that are used to maintain the aggregations synchronously
with the incoming events.
BAM interceptors. The collection of data (message context properties and message data)
from orchestrations and pipelines is implemented as BAM interceptors. These
interceptors monitor the data as it is being processed and collect information that has
been identified as being a KPI. No programming is required to change the BAM tracking.
Tracking Profile Editor (TPE). Developers use the TPE to define the mapping of
orchestration actions to business milestones and the mapping of XML schema nodes to
the business data items. Because no programming is required to collect or modify this
data, changes to tracking can be made easily at any time.
Lesson 2: Enabling Business Activity Monitoring
Lesson objective:
Describe the role of the business analyst in enabling Business Activity Monitoring.
Overview
The creation and implementation of BAM to monitor business processes usually involves
several different roles with different skill sets and tools.
Create Activity
Analysts use Microsoft Excel 2010 to create activities that identify in list form the key
performance indicators (KPIs) of the business processes, for example, receiving and
processing a purchase order (PO). These activities will include milestones (a date/time
measure for the receipt of a PO or the sending of an invoice) in addition to data points of
interest, such as the order date, PO number, total, and discounted total amounts. These
data points might be of interest for tracking and auditing purposes.
Enabling Business Activity Monitoring (Administrator)
Describe the role of the system administrator in enabling Business Activity Monitoring.
Example
In the following example, the SalesManagerView workbook is being deployed to create the
database structure based on the activity defined in the workbook.
BM deploy-all -DefinitionFile:SalesManagerView.xls
The BAM Management tool enables administrators to view, add, update and remove BAM
Management data.
Enabling Business Activity Monitoring (Developer)
BAM Portal
The BAM Portal is a tool in BizTalk Server 2010 that is used to view data collected in the BAM
databases from a business process. When the model is deployed by using the BAM Manager,
the views included in the data collection model are rendered as views for the BAM Portal.
The BAM Portal is a Microsoft ASP.NET application (it does not rely on Windows SharePoint
Foundation). For companies that already have SharePoint sites, Web parts are available to
simplify integration of BAM data into those sites.
The BAM Portal gives you the ability to:
Access pre-created views of the business data created by the business analyst and work
with PivotTables® in real time. In this way, users can customize the view to their own
preferences.
Perform activity searches against BAM data to find specific BAM activity. For example,
the preceding slide shows sales manager data for the OrderMgmt application. Queries
can be saved and reused. They can also be the basis for an alert, such as notification
when a purchase order arrives from the specified customer.
Drill down to see detailed information. This example shows the activity status for the
city of Los Angeles. The Activity Status view shows the dates on which several business
milestones were reached and tracking information (the Activity ID), in addition to the
other data. With this functionality, it is easy to start with aggregated data (all orders
processed) and see the details for orders that make up the totals.
Configure and share alerts to notify specific users in the event that particular threshold
conditions are met—for example, if the number of unprocessed purchase orders
exceeds 100, send an e-mail message to the sales manager. Once created, alerts can be
subscribed to by other users who are interested in the same information.
Escalate issues to the systems administrator. A link is provided to send feedback to a
preconfigured e-mail address notifying the recipient of problems that are identified by
portal users.
Demonstration: Monitoring Business Activity
Learn to implement an existing Business Activity Monitoring activity for a BizTalk Server solution.
bm deploy-all
-DefinitionFile:C:\AllFiles\DemoCode\Module12\OrderMgmt.xml
Scenario
Business Activity Monitoring (BAM) is a tool designed to be used by business analysts for
gathering business data from both archived and running business processes. In this lab, you
will see how to use several new tools, including the Microsoft Excel Business Activity
Monitoring Add-In and the BAM Portal, for analyzing business data that was processed by
BizTalk Server.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-12 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose
Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click Ask Me Later, then click OK.
Define Milestones
Procedure List
1. On the Start menu, click All Programs, click Microsoft Office, and then click
Microsoft Excel 2010. In the Microsoft Office Activation Wizard window, click
Cancel.
2. On the File menu, click Options
3. In the Excel Options window, in the left pane, click Add-Ins.
4. In the right pane, at the bottom, in the Manage list, click Excel Add-ins, then click
Go.
5. In the Add-Ins dialog box, click Browse, and navigate to C:\Program Files
(x86)\Microsoft BizTalk Server 2010\ExcelDir, then click Bam.xla and click OK.
6. In the Add-Ins dialog box, in the Add-Ins available list, ensure that the Business
Activity Monitoring box is checked, and then click OK.
7. In the Excel menu ribbon, on the Add-Ins tab, click BAM, and then click BAM
Activity.
8. In the Business Activity Monitoring Activity Definition dialog box, click New Activity.
9. In the Activity name box, enter OrderMgmt.
10. Click New Item, and in the New Activity Item dialog box, in the Item name box,
enter received, in the Item type list, click Business Milestones then click OK.
This milestone allows a timestamp value to be gathered from the message after
the message is received by the business process.
11. Repeat step 9, substituting in the following values to create the remaining Activity
Items needed to monitor the OrderMgmt business process.
Item Name Item type
denied Business Milestones
approved Business Milestones
acknowledged Business Milestones
City Business Data - Text
State Business Data - Text
Product Business Data - Text
Amount Business Data - Decimal
Later in this lab, you will specify the points in the business process at which each
of these data values will be collected by the BAM infrastructure.
12. Click OK twice.
Exercise 2: Define an Observation Model
The BAM definition that you initialized in the preceding exercise specifies the information to
be collected by BAM. In this exercise, you will create a BAM view. You will design this view
by adding progress dimensions and measures that categorize the data gathered by the BAM
activity. The data in the view is displayed as a Microsoft Office Excel PivotTable.
Select the Target BAM Activity for Which to Create a Tracking Profile
Procedure List
1. On the Start menu, click All Programs, click Microsoft BizTalk Server 2010, and then
click Tracking Profile Editor.
2. In the left pane, click Click here to import a BAM Activity Definition.
3. In the Import BAM Activity Definition dialog box, in the bottom pane, click
OrderMgmt, verify that Retrieve the current tracking settings for this activity
definition check box is cleared, and then click OK.
Create a Continuation
A BAM continuation is analogous to a correlation set in an orchestration. Continuations are
sets of unique values that allow the BAM infrastructure to identify all messages that belong
to the same instance of a BAM activity. In this lab, you must define a continuation to
indicate that the messages accepted by the receive port belong to the same activity as those
that are processed by the orchestration.
Procedure List
1. In the left pane of the Tracking Profile Editor, right-click OrderMgmt, and then click
New Continuation.
2. Set the name of the new continuation to OrderMgmtContinuation.
3. In the Tracking Profile Editor, in the top-right corner, click Select Event Source, and
then click Select Messaging Property.
4. In the right pane, expand Schema and MessageProperties.
5. From the right pane, drag the InterchangeID node to the new
OrderMgmtContinuation node in the left pane.
6. In the left pane, right-click InterchangeID, and then click Set Port Mappings.
7. In the Select Ports dialog box, click OrderMgmt_RcvPO, click the > button to map
the port, and then click OK.
This step instructs the BAM infrastructure to initialize the continuation with the
value of the message’s interchange ID. The interchange ID is a GUID that
identifies this message and any of its descendants.
8. In the left pane of the Tracking Profile Editor, right-click OrderMgmt, and then click
New ContinuationID.
9. Set the name of the new continuation ID to OrderMgmtContinuation.
The name of the continuation ID must match the name of the original
continuation.
10. Click Select Event Source, and then click Select Orchestration Schedule.
11. In the Select Event Source Parent Assembly dialog box, under Assembly name, click
TheImplementationOfOrderMgmt, and then click Next.
12. In the Select Orchestration dialog box, under Orchestration Name, click
OrderMgmt.OrderMgmtProcess, and then click OK.
13. Right-click the ReceivePO shape, and then click Message Property Schema.
14. In the right pane, expand MessageProperties, and then drag the InterchangeID
node to the new continuation ID node that you just created.
The ReceivePO shape will report the message’s interchange ID to the BAM
infrastructure, allowing BAM to associate this message with the correct BAM
activity.
Launch the BAM Portal and View Order Progress Data Aggregation
Procedure List
1. In Internet Explorer, navigate to http://localhost:8080/BAM.
2. In the My Views navigation pane, expand the Sales Manager view.
3. Click the plus sign (+) to expand the function named Aggregations, and then click
Order Progress.
4. In the Microsoft Office 2003 Web Components message box, click OK.
If you do not see any data in the Pivot Table View, click the button with the red
exclamation point (!) icon in the PivotTable tool bar to refresh the view. Because
of SQL Server / OLAP caching, it might take up to one minute for the data to
appear.
5. Click the plus signs (+) to expand cells in the PivotTable until Evaluation is shown
with a corresponding Total amount.
Module objective:
In this module, you will learn how to configure BizTalk Server 2010 receive locations to receive
messages via the Windows Communication Foundation (WCF) receive adapters.
Introduction
Web services provide industry-standard mechanisms for conducting e-business by
communicating across disparate systems. Microsoft BizTalk Server 2010 includes a number
of receive adapters that support integration with web services by making use of the
Windows Communication Foundation (WCF).
WCF provides support for a wide array of the current web service standards. This support
enables developers to both consume a web service as part of a business process and to
publish a business process as a web service that can be consumed by external applications.
In this module, you will learn how to configure BizTalk receive locations that accept
messages via the BizTalk WCF receive adapters, and to publish BizTalk orchestrations and
schemas as WCF web services.
Lesson 1: Introduction to WCF Receive Adapters
Lesson objective:
Describe how the WCF Receive Adapters work in BizTalk Server 2010
Introduction
This lesson provides an overview of Windows Communication Foundation (WCF) and the
capabilities that it provides for interacting with web services. This lesson then focuses on
the Microsoft BizTalk Server 2010 WCF receive adapters, providing examples for usage, and
followed by a discussion of the architecture on which the WCF receive adapters are based.
Windows Communication Foundation (WCF)
Introduction
Windows Communication Foundation (WCF) is a framework for building service-oriented
applications. WCF is included in the .NET Framework, and it provides a basis for writing code
to communicate across components, applications, and systems. A service is a piece of code
that clients interact with through messages. Services are passive -- they wait for incoming
messages to arrive before starting any work. A client requests a service to perform work by
sending a message to it.
Services expose one or more endpoints where messages can be sent. An endpoint consists
of an address, a binding, and a contract. The address specifies where to send messages. The
binding describes the transport details required. And the contract describes what the
messages contain. Clients need to know all of this information before they can access a
service.
Services typically offer descriptions of their capabilities and their requirements by using Web
Services Description Language (WSDL). Clients can use the service description to generate
code within their environment capable of sending and receiving the proper messages.
WCF 4.0 Web Service Standards Support
Explain the features and benefits of using Windows Communication Foundation (WCF).
Introduction
Windows Communication Foundation (WCF) supports a wide array of the web service
standards that have been defined since the SOAP specification was first published. WCF
enables you to develop secure, interoperable web services based on open industry-standard
specifications. In addition to supporting the fundamental standards, such as XML, SOAP and
WSDL, WCF includes support for standards covering end-to-end message level security,
content-based routing, and web service policies.
WS-I Profiles
The Web Service Interoperability Organization (WS-I) has published guidelines, sample
applications and testing tools to help developers implement web service standards to
achieve the best possible levels of interoperability.
A WS-I Profile consists of a set of guidelines, sample applications and testing tools that
address a fixed set of web service specifications.
WCF 4.0 provides built-in support for the following WS-I profiles.
WS-I Basic Profile, Datatypes – XML Schema 1.0 base and complex data types
WS-I Basic Profile 1.1 – SOAP 1.1, WSDL 1.1
WS-I Basic Profile 1.2 – SOAP 1.1, WS-Addressing 1.0
WS-I Basic Profile 2.0 – SOAP 1.2, WS-Addressing 1.0, MTOM
WS-I Basic Secure Profile 1.1 – WS-Security 1.1
There are asome dditional profiles under development in WS-I working groups that WCF 4.0
does not yet support, including:
Reliable message exchange – WS-ReliableMessaging 1.1
Reliable, secure message exchange – WS-ReliableMessaging 1.1, WS-SecureConversation 1.3
WCF Receive Adapter Scenarios
Introduction
With the WCF adapters built-in to Microsoft BizTalk Server 2010, developers can expose
WCF Web Services to external systems and benefit from the rich integration support offered
by WCF. Developers can make use of the WCF native support for the major web service
specifications, rather than resort to writing custom code.
Some common integration scenarios in which a developer might want to publish a WCF web
service include:
Introduction
If your organization requires a specific business process to be accessible via the Web to
trading partners, customers, or other applications, you can publish an orchestration or a
message schema as a web service. You can do this by running the BizTalk WCF Service
Publishing Wizard.
When publishing an orchestration as a web service, each public receive port is presented as
a .svc file, which is handled by the Windows Communication Foundation (WCF) framework
on a computer running Internet Information Services (IIS) Manager. The web service is
called using the SOAP protocol. The data is sent to and from the web service as XML.
WCF Receive Adapter Architecture
Introduction
The BizTalk WCF receive adapters create WCF endpoints to listen for messages. When a
message arrives at the endpoint, the WCF adapter receives the message and publishes it to
the MessageBox.
BizTalk Server 2010 provides a number of different WCF adapters to meet the requirements
of various messaging and transport protocols. The WCF adapters share a common
architecture and base implementation. Each WCF adapter, however, requires a different set
of configuration data as dictated by its transport, encoding and WS-* protocol support.
When a WCF receive adapter starts running, it creates a BizTalk Service Host, which
dynamically builds the WCF runtime components that are required to accept and process
messages. When a message arrives, the WCF receive adapter passes it through a series of
WCF channel components. A channel consists of one transport component, one message
encoder, and zero or more protocol components.
The transport component is responsible for reading in the raw bytes of the message. The
encoder component is responsible for converting the raw bytes in to a WCF message. The
protocol components are responsible for processing any WS-* protocols that are configured
on the adapter.
When the WCF channel components have completed processing, and if they have not
rejected the message for security reasons, the message will be passed to the receive
location’s pipeline. At this point, the pipeline will process the message in the same manner
as it would if the message were received by any other of the built-in BizTalk adapters.
Lesson 2: Configuring a WCF Receive Adapter
Lesson objective:
Introduction
To create a receive location that presents a WCF service to external systems, you must
determine which WCF adapter best meets the application requirements, and then configure
the WCF adapter and BizTalk pipeline in the BizTalk Administration Console.
Steps for Configuring a WCF Receive Adapter
Introduction
To configure a WCF receive adapter, you must:
1. Select a WCF receive adapter that best meets the receive location’s message
transport, encoding and WS-* protocol requirements -- each of the WCF adapters is
preconfigured with a set of WCF channel components.
2. Specify an endpoint address at which the WCF service will be hosted.
3. Set the configuration properties for the WCF adapter. Any of the preconfigured
WCF adapters will display a set of properties, reflecting the properties of the
channel components that it contains.
Types of WCF Adapters
Describe the types of BizTalk WCF adapters, and explain how each one can be used
Introduction
With the wide range of possibilities presented by the BizTalk WCF adapter architecture and
the WCF framework, it could become a rather time consuming task to determine which
features are required for a given receive location, and to build a corresponding WCF binding
each time.
For ease of configuration, BizTalk Server 2010 provides a collection of WCF adapters that are
preconfigured with WCF bindings:
The WCF-WSHttp adapter provides the WS-* standards support over the HTTP transport.
The WCF-WSHttp adapter implements WS-Transaction for the transactional interactions
between external applications and the MessageBox database, and WS-Security for message
security and authentication. The transport is HTTP or HTTPS, and message encoding is a Text
or Message Transmission Optimization Mechanism (MTOM) encoding.
The WCF-BasicHttp adapter communicates with ASMX-based Web services and clients and
other services that conform to the WS-I Basic Profile 1.1. The transport is HTTP or HTTPS,
and message encoding is a text encoding.
The WCF-NetTcp adapter provides the WS-* standards support over the TCP transport. The
WCF-NetTcp adapter provides efficient communication in a WCF-to-WCF environment. The
adapter implements WS-Transaction for the transactional interactions between external
applications and the MessageBox database, and WS-Security for message security and
authentication. The transport is TCP, and message encoding is binary encoding.
The WCF-NetMsmq adapter provides support for queuing by leveraging Microsoft Message
Queuing (MSMQ) as a transport and enables support for loosely coupled applications, failure
isolation, load leveling, and disconnected operations.
The WCF-NetNamedPipe adapter provides secure optimization for on-machine cross-
process communication. The WCF-NetNamedPipe adapter uses transport security for
transfer security, named pipes for message delivery, and binary message encoding.
Learn how to select the message content that the adapter will publish to the MessageBox.
Introduction
The WCF receive adapters offer the option to configure how much of the content of an
inbound SOAP message should be published to the message box. As was the case with the
SOAP adapter, the default behavior of a WCF receive adapter is to publish only the message
body, and to discard the SOAP envelope.
By configuring a WCF receive adapter to publish the entire SOAP message, including the
envelope and headers, it is possible for other components within BizTalk to receive the
message with any encryption and digital signatures intact. When selecting this option, you
must configure the receive location with a pipeline that does not include the XML
disassemble component pipeline, otherwise the SOAP body will automatically be extracted
during pipeline processing, and published to the message box.
If your application requires only a subset of the SOAP message body, you can choose the
Path option and provide an XPath statement to select a specific node to be published to the
message box. This is particularly useful when external systems send large messages, and the
receiving application requires only a small subset of the data.
Specifying the Format of a Selected Node
Learn how to specify the format of a content node that has been selected with XPath.
Introduction
When the Path option is selected, the WCF receive adapter requires a second configuration
property that specifies the type of encoding of the selected node.
It will decode the XML node as specified by the configured encoding type, and publish the
resulting decoded message data to the MessageBox.
Configuring Two-way Receive Ports
Introduction
In a two way receive location, the WCF receive adapters provide two options for populating
the body of the SOAP response message. The WCF receive adapters default to the Body
option, which instructs the adapter to insert the body of the BizTalk message into the SOAP
body, which is the same behavior as the original SOAP receive adapter.
The WCF receive adapters also offer a Template option, which provides the ability to wrap
the body of the outbound BizTalk message in custom XML, and then insert the customized
XML in to the outbound SOAP body.
When you choose the Template option, you must provide an XML template that includes a
bts-msg-body element. The location of the bts-msg-body element indicates the position at
which the BizTalk message body should be inserted.
Demonstration: Creating a net.tcp Receive Location
Lesson objective:
Use the WCF Service Publishing Wizard to publish orchestrations and schemas as web services.
Introduction
You can publish a BizTalk orchestration or schema as a WCF web service. BizTalk WCF web
service consists of a .svc file, a web.config file, and metadata files. To publish your Web
service, you can use the BizTalk Web Services Publishing Wizard.
Steps for Publishing a WCF Service
Introduction
When you publish an orchestration as a WCF Web service, you expose the orchestration’s
receive ports as web services. This enables external business processes to access the
orchestration from any type of service-enabled client.
To publish an orchestration, you must:
1. Compile the BizTalk Server project that contains the orchestration, and install the
assembly in the GAC. Any orchestrations that are to be published as web services
must contain at least one public logical port for receiving messages into the business
process.
2. Create and configure both the receive port and the receive location in the BizTalk
Administration Console.
3. Create the WCF service and configuration files by running the Web Services
Publishing Wizard. By default, it will store all the files that are created by the wizard
in the C:\InetPub\WWWRoot directory. You will want to check the permissions on
this folder to ensure that this project is secure.
4. Associate the web service with the desired application pool. When a web service is
published, it is associated with the default application pool, which generally does
not have access to the BizTalk MessageBox.
Prerequisites
The server to which you will be publishing your WCF web services must have both Internet
Information Services (IIS) and the .NET 4.0 framework installed.
Configuring an Orchestration for Publishing
Lesson objective:
Use the WCF Service Publishing Wizard to publish an orchestration as a web service.
Learn to publish an orchestration with the BizTalk WCF Service Publishing Wizard
Publish a schema
The BizTalk WCF Services Publishing Wizard can also be used to create web services that are
based solely on existing schemas. This option offers greater flexibility, since it allows a schema
to be published as a web service whether or not it is not used in an orchestration. You can
define the web services, service operations, and request-and-response message types by
specifying the schemas that you want published.
Using the wizard, you define the target namespace, specify the names of the services and
service operations, and set the location of the generated web service files. Publishing schemas
as web services allows third-party vendors or trading partners to see how to format messages
before sending them to your organization for further processing.
Lab: Receiving Messages with a WCF Adapter
Overview
This lab will introduce you to the integration between the BizTalk Server messaging components
and Web services. You will use a built-in WCF adapter, which provides integration with Web
services using Windows Communication Foundation.
First, you will generate a Web service from an existing schema definition using the BizTalk WCF
Service Publishing Wizard. Then you will learn how to properly configure a receive port and the
virtual directory containing the generated service endpoint.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-13 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click “Ask Me Later”, then click “OK”
3. Verify that a dialog box appears confirming that the order was submitted successfully.
If you get an error, try running the application in debug mode with a breakpoint on
the catch block to get more detail on the error. Make sure your receive location is
enabled and the host instance are running.
4. In Windows Explorer, navigate to C:\AllFiles\LabFiles\Ports\BillingDept and verify that
a new message has been created.
Module 14: Using WCF Send Adapters
Time estimated: 90 minutes
Module objective:
In this module, you will learn how to configure BizTalk Server 2010 send ports to send messages
and call web services using the Windows Communication Foundation (WCF) send adapters.
Introduction
Microsoft BizTalk Server 2010 includes a collection of send adapters that support integration
with web services by making use of the Windows Communication Foundation (WCF).
You can use the BizTalk WCF Service Consuming Wizard to import the metadata for a web
service and generate the schema and binding files that are required to integrate with it.
Lesson 1: Introduction to WCF Send Adapters
Lesson objective:
Describe how the WCF send adapters can be applied to BizTalk Server 2010 applications
Introduction
This lesson then focuses on the Microsoft BizTalk Server 2010 WCF send adapters. It
provides examples for usage, and it includes a discussion of the architecture on which the
WCF send adapters are based.
WCF Send Adapter Scenarios
Describe some common scenarios for using the WCF send adapters.
Overview
With the WCF send adapters built-in to Microsoft BizTalk Server 2010, developers can
consume web services that are exposed by external systems, and they can benefit from the
rich integration support offered by WCF.
Some common integration scenarios in which a developer might want to consume a WCF
web service include:
1. To enable a BizTalk application to send invoice messages to an external trading
partner’s supply chain system over the internet, making use of WS-Security features
such as encryption and digital signatures to ensure that the message has not been
compromised while en-route.
2. To enable a BizTalk application to query a warehouse database, such as Oracle 11g,
to check the availability of stock to meet the requirements of a new purchase order.
3. To enable a BizTalk application to update to an internal SQL Server 2008 database,
and to make a web service call to a vendor server, with full support for ACID
transactions across the disparate systems.
WCF Send Adapter Architecture
Overview
A BizTalk WCF send adapter receives messages from the BizTalk MessageBox, communicates
with a service endpoint, and publishes any service response messages back in to the
MessageBox.
BizTalk Server 2010 provides a number of different send WCF adapters to meet the
requirements of various messaging and transport protocols. The WCF send adapter
architecture is somewhat simpler than the receive adapter architecture because it acts as a
WCF client, and therefore it doesn’t have to deal with the issues that arise from WCF
hosting. Each WCF send adapter requires a set of configuration data as dictated by its
transport, encoding and WS-* protocol support.
When a WCF send adapter is activated, it prepares the BizTalk message to be processed by a
WCF channel. A WCF send adapter does not check the format of a message that it is
transmitting. Consequently, you need to ensure that the application’s send ports are
configured with the pipelines and maps that produce the message format required by the
destination service. In lieu of schema type information, the send adapter requires you to
specify the service “action” value that that should accompany the message as it is sent via
the transport.
An important consideration is that the WCF send adapter is only compatible with request-
reply operations even when used on one-way send ports. WCF service operations can return
void but they shouldn’t be marked with IsOneWay=true if you want to call them from a WCF
send port. The only exception is when you’re using NetMsmqBinding, in which case the
service operations must be one-way. This is a common for developers to stumble on when
they first start using the WCF send adapters, but the constraint is by design in order to
support transactional consistency within the message box.
Finally, send ports can be configured to route incoming fault messages (returned by the
service) through traditional message box subscription techniques. This functionality,
however, is disabled by default.
Lesson 2: Consuming a Web Service
Lesson objective:
Introduction
Consuming WCF services enables you to add existing web services to your business process.
You can aggregate several web services into a single orchestration.
You can begin to configure your application to make a web service call by using the BizTalk
WCF Service Consuming Wizard. The BizTalk WCF Service Consuming Wizard creates the
schema and binding files that are required to call a given web service.
Steps for Consuming a Web Service
Overview
BizTalk Server 2010 provides tools that simplify the procedure to implement web service
calls in a BizTalk application. You can get started by performing the following four steps:
1. Add Generated Item. In your Microsoft Visual Studio BizTalk project, in Solution
Explorer, right-click your project, click Add, and then click Add Generated Items. In
the Add Generated Items - <Project name> dialog box, in the Templates section,
select Consume WCF Service, and then click Add.
2. Complete the BizTalk WCF Service Consuming Wizard. The BizTalk WCF Service
Consuming Wizard walks you through the process of importing the service’s
metadata, and then it creates the schema and binding files that are required to call
the web service. It also generates an orchestration containing type definitions for
the web service messages and orchestration ports.
3. Build and deploy the project. In most cases, this step will be necessary, since your
application will probably need to map a message to the web service call format. In
the rare cases that this mapping is not necessary, you can skip this step.
4. Import generated binding file. The WCF Service Consuming Wizard creates two
binding files: <ServiceName>.BindingInfo.xml and
<ServiceName>_Custom.BindingInfo.xml. The first file contains the settings required
to configure a send port with the standard binding WCF adapters—for example, the
WCF-NetMsmq and WCF-WSHttp adapters. The second binding file contains the
settings required to configure a send port with the WCF-Custom adapter.
The BizTalk WCF Service Consuming Wizard
Describe the process of completing the BizTalk WCF Service Consuming Wizard
Overview
The BizTalk WCF Service Consuming Wizard simplifies the process of importing web service
metadata and creating the corresponding BizTalk artifacts. You can launch and complete the
BizTalk WCF Service Consuming Wizard by completing the following steps:
1. Add Generated Item. In your Microsoft Visual Studio BizTalk project, in Solution
Explorer, right-click your project, click Add, and then click Add Generated Items. In
the Add Generated Items - <Project name> dialog box, in the Templates section,
select Consume WCF Service, and then click Add.
2. Complete the BizTalk WCF Service Consuming Wizard.
a. On the Welcome to the BizTalk WCF Service Consuming Wizard page, click
Next.
b. On the Metadata source page, select the source of the metadata to import,
and then click Next.
i. To download metadata documents from the metadata exchange
endpoint of a running service, select the Metadata Exchange (MEX)
endpoint option. This allows you to create a send port that acts as a
client to the WCF service. To use this option, the service endpoint
must publish service metadata for retrieval using an HTTP/GET or
HTTPS/GET request. The service endpoint must also allow access to
the metadata with anonymous user credentials or user credentials
in the form of a user name and password with the basic
authentication scheme.
ii. For any other metadata documents to import, select the Metadata
Files (WSDL and XSD) option to import metadata from a file system.
c. If you selected the Metadata Exchange (MEX) endpoint option on the
Metadata source page, the Metadata Endpoint page appears. On the
Metadata Endpoint page, specify the URL to the running service that
provides metadata for download through WS-Metadata Exchange or Http-
Get. To get the metadata document from the URL, click Get. If the running
service requires a user credential with the basic authentication scheme, click
Edit to open the BizTalk WCF Service Consuming Wizard dialog box in which
you can supply user name and password to use when accessing running the
service.
d. If you selected the Metadata Files (WSDL and XSD) option on the Metadata
source page, the Metadata Endpoint page appears. On the Metadata
Endpoint page, specify metadata files to import. Click Add to add the
metadata files to import to the Metadata Files view. This opens the Add
metadata files dialog box in which you can search disk locations for
metadata files.
i. In the Add metadata files dialog box, select a complete set of WSDL
and XSD files to use for metadata.
e. On the Import WCF Service Metadata Summary page, review your settings.
You can click Back to make any changes. Then click Import to create the
BizTalk artifacts and types to be used for consuming the WCF service.
f. On the Completing the BizTalk WCF Service Consuming Wizard page, click
Finish. If you want to run this wizard again, select the Run this wizard again
option, and then click Finish.
Demonstration: Consuming a Web Service
Lesson objective:
Introduction
Orchestrations offer the ability to provide error handling and transaction compensation
while they coordinate calls to web services. This lesson will show you how to use the type
definitions created by the BizTalk WCF Service Consuming Wizard to make a web service call
from an orchestration.
Steps for Consuming a Service from an Orchestration
Overview
After completing the BizTalk WCF Service Consuming Wizard, you will find that an
orchestration and two schema files have been added to your BizTalk project.
The orchestration will be named after the service, following the naming convention of
<ServiceName>Type.odx. There are no shapes in this orchestration. It simply contains a port
type definition, and one or more multipart message type definitions. The recommended
approach for using the type definitions is to avoid modifying the generated orchestration,
and then simply reference the type definitions from other orchestrations in the BizTalk
project.
One schema file will be named after the service following the naming convention of
<ServiceName>Type_biztalk_WCF_<AdapterBindingType>.xsd. This schema defines the
format of the web service request and response messages.
The other schema file will be named following the naming convention of
<ServiceName>Type_schemas_microsoft_com_2003_10_Serialization.xsd. This schema is
exported by DataContractSerializer for the types, elements, and attributes from the
namespace, http://schemas.microsoft.com/2003/10/Serialization/.
Implementing the web service call in the orchestration takes four steps:
1. Create a new configured port in the orchestration. You can use the Orchestration
Designer’s port wizard to create a send port of the wizard-generated port type.
2. Define message variables using new message types. Create one message variable
for the web service request and, if the service will be returning a response, create a
message variable for the response as well. Assign the corresponding generated
multipart message type(s) to the new message variable(s).
3. Construct the web service request message. Use either a Transform shape, or a
Message Assignment shape to construct the web service request message.
4. Connect send and receive shapes to the new port. Drag and drop connections
between the send and receive shapes, and their corresponding operations on the
send port.
Mapping Operations to Actions
Overview
When you import the generated binding file, it populates the WCF.Action property in the
action mapping format. To see how this property is configured, look at the Action text box
on the General tab in the WCF send port transport properties dialog box in the BizTalk
Administration console.
You can specify the WCF.Action property in two different ways: (1) the single action format
and (2) the action mapping format.
If you set this property in the single action format, for example,
http://contoso.com/Svc/Op1, then the SOAPAction header for outgoing messages is always
set to the value specified in this property.
If you set this property in the action mapping format, the outgoing SOAPAction header is
determined by the outbound message’s BTS.Operation context property. For example, if this
property is set to the XML format shown below, and the BTS.Operation property is set to
Op1, the WCF send adapter uses http://contoso.com/Svc/Op1 for the outgoing SOAPAction
header.
<BtsActionMapping>
<Operation Name="Op1" Action="http://contoso.com/Svc/Op1" />
<Operation Name="Op2" Action="http://contoso.com/Svc/Op2" />
</BtsActionMapping>
Orchestrations set the BTS.Operation property with the operation name of the orchestration
send port. The ports generated by the BizTalk WCF Consuming Wizard have operations with
names that match the Name attributes in the <BtsActionMapping> element, so you do not
have to explicitly set the BTS.Operation property in orchestrations when you send messages
through ports that were generated by the wizard.
Formatting the Request Message
Understand how to specify the format of the body of the outbound SOAP message.
Overview
The WCF send adapters offer two options for constructing the SOAP message from the
outbound BizTalk message. You can choose to use the body of the BizTalk message as the
body of the <soap:Envelope> or you can provide an explicit XML template that specifies
what should go in the <soap:Body>.
Within the custom XML template, you use <bts-msg-body> to indicate where the BizTalk
message body should go. The <bts-msg-body> element also has an “encoding” attribute that
you can use to specify how the BizTalk message body should be encoded in the <soap:Body>
element: “xml”, “base64”, “hex”, or “string”.
The following template will wrap the outbound BizTalk message within an <Invoice>
element:
<Invoice xmlns="http://northwind.com/billing">
<bts-msg-body xmlns="http://www.microsoft.com/schemas/bts2007"
encoding="xml"/>
</Invoice>
Selecting Content from the Response Message
Understand how to specify the content to be extracted from the body of the SOAP response message.
Overview
The WCF send adapters offer the option to configure how much of the content of a response
message should be published to the MessageBox. The send adapter is responsible for
creating the BizTalk message (multi-part) consisting of a message context and a single body
part. You can choose which node from the incoming SOAP envelope to use in the BizTalk
message body.
You can choose to use the entire SOAP envelope, the body of the SOAP envelope, or a
particular element within the SOAP envelope identified by an XPath expression. The default
setting is “Body”, which means the first child of the <soap:Body> element will be used in the
BizTalk message body.
When you select “Envelope”, the entire <soap:Envelope> will be used within the BizTalk
message body, which means the SOAP headers will be found within the BizTalk message
body for future processing. However, if you are using the XmlDisassembler in your receive
pipeline, it will actually strip everything from the SOAP message except for the first child of
the <soap:Body> (similar to the “Body” option), thereby negating the “Envelope” behavior if
that was the selected option. This behavior stems from the fact that the SOAP schema is
registered with BizTalk Server as an “envelope” schema. Hence, you will want to ensure
you’re using the PassThruReceive pipeline when selecting the Envelope option above.
The final option is to specify a node within the <soap:Body> to use within the BizTalk
message body. You provide an XPath expression (in the “Body path expression” text box) to
specify exactly which node to use. The expression is evaluated relative to the <soap:Body>
element, which means an expression of “*” (short for “child:*”) identifies the children of
<soap:Body>. If the expression selects more than one node, only the first selected node will
be used. Also, another important point is that you can’t use XML namespace prefixes in the
XPath expression. Instead, you’ll need to use full XPath expressions that test the local name
and namespace values manually as illustrated in this example:
*/*[local-name()="invoice"]/*[local-name()="CustomerName"]
This XPath expression identifies the <CustomerName> element within <invoice>. Since
BizTalk Server uses an optimized forward-only XPath reader to process these XPath
expressions, you must ensure that your expressions only use forward axes (e.g., child,
descendant, etc). You must avoid any axis that requires reverse navigation (e.g., preceding,
preceding-sibling, ancestor, etc).
The node encoding controls how the node is processed after it has been selected. The
available options include Xml, Base64, Hex, and String. The default is “Xml”, which means
the XML representation of the selected node will be used in the message body. When the
selected node doesn’t contain XML but rather some form of text, you specify what encoding
should be used to extract the text. You can specify “String” if the node contains UTF-8
encoded text, or “Base64” or “Hex” if the node contains either form of encoded binary data.
If the matched node doesn’t have data encoded as specified in the node encoding, an empty
BizTalk message body is created by default. This general functionality is handy when you
only want to publish the binary data found in a particular element to the message box.
Demo: Consuming Services from Orchestrations
BillingMessage.OrderTotal = BillingMessage.OrderTotal +
ShippingQuoteResponse.parameters.GetShippingPriceQuoteResult.Price;
11. Click the ShippingChargesClient orchestration, and in the Host list, click
BizTalkServerApplication, then click OK.
12. Right-click the Demos.Northwind application, and then click Start twice.
13. Drop a copy of the OrderExternal.xml message from
C:\AllFiles\DemoCode\Module14\ in to the
C:\AllFiles\DemoCode\Northwind\Ports\FileIN folder.
14. Open the order message that appears in the
C:\AllFiles\DemoCode\Northwind\Ports\Audit folder, and take note of the
OrderTotal value.
15. Open the billing message that appears in the
C:\AllFiles\DemoCode\Northwind\Ports\BillingDept folder, and verify that shipping
charges have been included in the OrderTotal value.
16. Close all open windows, and shut down the bt10d-demos virtual machine.
Lesson 4: WCF Send Adapter Security
Lesson objective:
Introduction
WCF provides numerous security options that differ across the various bindings, and you can
take things even further via custom bindings. The purpose of this section is not to cover the
details of the various WCF security features, but rather to show how the adapters surface
those configuration settings.
Configuring WCF Send Adapter Security
Overview
WCF provides numerous security options that differ across the various bindings, and you can
take things even further via custom bindings. Since the set of security options vary across
the different WCF bindings, each WCF adapter only provides configuration options that are
consistent with the underlying binding.
Each of the WCF adapter configuration dialog boxes provides a “Security” tab, which
surfaces the security options available for that particular adapter. The main setting you
choose is the WCF security mode, either “None”, “Message”, “Transport”, or
“TransportWithMessageCredential”. Not all WCF adapters support all the different security
modes. For example, the WCF-NetNamedPipe adapter only supports “Transport” or “None”.
Also, the WCF-NetMsmq adapter supports “Transport”, “Message”, or “Both”, which is a full
combination of transport + message security.
When you select message or transport, you must specify the type of client credential to use.
For message security the options include “None”, “Windows”, “Username”, and
“Certificate”. When you choose anything but “Windows”, you must provide a service
certificate allowing clients to authenticate the service. For transport security the client
credential options include “None”, “Basic”, “Digest”, “Ntlm”, “Windows”, and “Certificate”.
With message security, you can also specify the algorithm suite to use for message
encryption and key wrapping. And you can control whether the service credential is
negotiated (as with Kerberos) or provisioned at the client (as with certificates) and whether
a secure session should be established. These settings control whether WS-Trust and WS-
SecureConversation are used within the channel stack.
Most of the WCF receive adapters support SSO – simply select “Use Single Sign-On” to
request an SSO ticket using the client credentials – check the documentation for details on
which configurations do support SSO and which do not. When specifying “User name
credentials” in the send port adapter configuration, you can indicate you want to use SSO for
the outbound credentials.
Configuring WCF-Custom Send Adapter Security
Overview
If you are configuring a WCF-Custom adapter, you have a wider array of options for security
configuration. If you are passing simple credentials, such as name and password, then you
can use the Credentials tab to specify the credential values.
Otherwise, you will need to open the Behavior tab to configure the WCF behaviors that
support the security features required by your application. You will need to ensure that the
BizTalk Host user account has the privileges that might be required by the WCF behavior,
such as privileges to access a certificate store.
Lab: Calling a Web Service from an Orchestration
Overview
The purpose of this lab is to introduce you to the integration between the BizTalk Server
messaging components and Web services. You’ll use a built-in WCF adapter, which provides
integration with Web services using Windows Communication Foundation.
First, you will add a service reference to generate the necessary artifacts for consuming a
web service using the WCF adapters. Next you’ll walk through the process of consuming a
web service from within an orchestration.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-14 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose
Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click “Ask Me Later”, then click “OK”
Module objective:
In this module, you will learn how to make use of additional features of BizTalk
orchestrations to implement commonly used messaging patterns.
Module Overview
By gaining a deeper understanding of the features of BizTalk orchestration ports, you can
design and implement more flexible messaging patterns to meet the needs of a wider array
of business scenarios.
This module examines the different styles of bindings that can be applied to orchestration
ports. It also revisits correlation, focusing on special cases called convoy messaging patterns
that arise when an orchestration is designed to receive multiple related messages.
Lesson 1: Creating Adaptable Orchestration Ports
Lesson objective:
Lesson Overview
BizTalk server offers five different types of port bindings that you can specify in the BizTalk
Orchestration Designer. Each style of binding offers a unique set of benefits.
Previous modules have covered the Specify Now and Specify Later binding types. This lesson
focuses on the additional types: Dynamic, Direct and Role Links.
Dynamic Binding allows you to set send port configuration settings at runtime. It
accommodates scenarios in which the destination URL for a message is not known at design
time.
Direct Binding provides a means for orchestration ports to define custom subscriptions,
opening up the possibility of communicating between orchestrations without requiring
physical ports to pass the messages between them.
Role Links provide a way to maintain sets of physical send and receive ports that are
assigned to trading partners. Role links enable reuse of common orchestrations, making it
easier to accommodate a growing number of trading partner systems.
Configuring Port Properties at Runtime
Overview
Dynamic port binding is fairly straightforward. In this case, the orchestration is bound to a
minimally configured physical send port. At runtime, the orchestration passes configuration
settings as context properties of each outbound message. The settings are applied to the
physical send port configuration immediately before the message is transmitted.
The orchestration relies on application code to determine the send port configuration
settings. The URL and settings might come from different sources, which could include a
business rule, a database query, or it might even come within the content of an inbound
message (e.g. a confirmation might be sent to an email address that which is provided in a
purchase order message).
Communicating between Orchestrations
Overview
Applying direct binding to orchestration ports opens up possibilities that are not available
with the other types of binding. Direct binding allows you to send messages to other
orchestrations, while retaining the option of sending messages to physical send ports.
With direct binding you can design extensibility in to your BizTalk applications. By designing
your applications to maintain loose coupling between systems, you can minimize the impact
required to integrate with future systems.
BizTalk offers three styles of direct binding. MessageBox, Self-Correlating, and Shared Ports.
MessageBox. Binding an orchestration port directly to the MessageBox offers the most
flexibility amongst all of the binding styles. Directly binding to the MessageBox provides
both publishers and subscribers with complete control over their interactions with a
message’s context properties. Consequently, rather than having to deal with fixed
subscription patterns, BizTalk application designers can work at a higher level of abstraction
and increase the potential for loose coupling and greater maintainability.
Self-Correlating Ports. Direct binding with a self-correlating port imposes constraints that
are not present when binding directly to the MessageBox, but this approach can be easier to
work with, since some of the subscription details are handled by the BizTalk runtime. In this
case, one orchestration passes a port object to a second orchestration which uses the port
to send messages back to the first orchestration.
Shared Ports. The third direct binding option, shared ports, impose further constraints, but
they offer a convenient method to implement communication between orchestrations. In
this case, you configure the shared port in the port settings in the Orchestration Designer,
and the compiler and BizTalk runtime handle the subscription details.
Direct Binding with the Message Box
Direct binding to the MessageBox is the most powerful option. Use it carefully.
Overview
Direct binding with the MessageBox provides unobstructed access to BizTalk’s publish-
subscribe architecture. MessageBox direct bound ports enable an orchestration to drop
messages directly into the MessageBox database without an explicit recipient, and to
subscribe to messages that meet certain criteria rather than only messages that come from
a particular sender. BizTalk application designers can take advantage of this binding style to
create more flexible and reusable systems.
Promoting the right properties, and setting up the filters is the hardest part of working with
this style of binding. There can be any number of subscribers for any published message,
and if there are no subscribers interested in the message at the time that it is the BizTalk
runtime will throw an exception in the orchestration. Any orchestration that includes send
ports bound directly to the MessageBox should implement an exception handler to account
for that possibility.
Caveat
Also, think carefully about subscription filters when binding a port directly to the
MessageBox, it can be easy to accidentally create a subscription filter that recursively
creates orchestration instances.
An orchestration, for example, might publish a message that matches its own subscription
filter. If such an orchestration receives a PurchaseOrder and later publishes a copy of the
PurchaseOrder directly to the MessageBox, then a new instance of the same orchestration,
along with all of the other PurchaseOrder message subscribers, will be activated to process
the new copy of the message. The cycle will repeat until BizTalk runs out of resources to
process the unintended orchestration instances.
Direct Binding with Self Correlation
Direct binding with self-correlation off-loads some of the correlation details to the BizTalk
runtime.
Overview
Using direct binding with self-correlating ports is not as flexible as binding to the
MessageBox, but it makes it easier to get the subscriptions right. The BizTalk runtime
handles more of the subscription details in this case.
You set up a self-correlating port by using the Orchestration Designer to configure one
orchestration to start another orchestration, passing a port as a parameter. The second
orchestration can use the port to send messages back to the first orchestration.
Other than passing the port as a parameter in the start shape, self-correlating ports hide
most of the details of the direct binding. The BizTalk runtime handles the message
correlation behind the scenes with a custom correlation token that is generated by the
orchestration engine.
In the event that the second orchestration implements a commonly used business process,
such as a credit card authorization, the option remains open for other orchestrations to
make use of it by starting new instances, and passing ports of their own. The only
stipulation is that the port being passed must match the parameter’s type definition.
Direct Binding with Shared Ports
Direct binding with shared ports hides most of the correlation details.
Overview
Direct binding with shared ports fully encapsulates the details of the underlying message
correlation. imposes further constraints beyond those of self-correlation. This binding style
imposes further constraints beyond those of self-correlation. All of the direct binding details
are established up-front when a shared port is defined in the Orchestration Designer. When
defining a shared port, you need to specify the intended sending orchestration, or the
intended receiving orchestration of a message that is to be passed through the MessageBox.
Assigning Ports to Trading Partners
Role Links offer the ability to share a common business process amongst different trading
partners.
Overview
When working with multiple trading partners, you probably will not be able to use the same
physical send port to communicate with the entire group. You could, of course, use dynamic
ports to configure URLs and other details, but that approach would most likely pose
maintenance issues as the number of trading partners grows.
Role links allow you separate the concerns of trading partner management and business
process design. Using this approach, an orchestration has placeholders known as role links,
that represent send and receive ports used to communicate with trading partners.
At runtime, the orchestration specifies which trading partner it wants to communicate with,
and the trading partner management system takes care of the rest. The orchestration
provides an identifier, known as an alias, in a message’s context, and the trading partner
management system performs a look-up to determine the trading partner, and the
corresponding physical send port.
With role links in place, business analysts can manage trading partners, and developers can
focus on developing a common implementation of the business process.
Parties. Parties are all the entities outside of BizTalk Server that interact with an
orchestration. All of the partners that your organization deals with are considered parties,
and your organization may have several thousand partners. The BizTalk Administration
Console has a user interface that can be used to manage parties.
Roles and party enlistment. Parties interact with orchestrations through roles. During
development, you do not need to specify the actual party that the orchestration may
interact with.
An example of a role that an orchestration might use would be a shipper. The shipper would
have one or two parties associated with it. When the orchestration needs to decide which
shipping company to use to ship an item, it can compare the prices of the parties in the
shipper role.
Party enlistment is the mechanism that ties a party to a role. In BizTalk Explorer, you can
enlist a party in a role, and that will enable the orchestration to interact with the party.
In the example shown on the slide above, “SpeedyExpress” is an enrolled party in the
ShipperRole of the Ordering orchestration. At runtime, the orchestration determines which
shipping party should handle this order, and the Trading Partner Management system looks-
up the role link to determine that the message should be sent via the Ship_SpeedyExpress
send port.
Service Link Type. A service link type characterizes the relationship between two services or
orchestrations by defining the part played by each of the services in the relationship and
specifying the port types provided by each role.
Aliases. Aliases refer to the same party by different names. An organization or unit may be
known by its name, by a telephone number, by an e-mail alias, by a signature certificate, or
by a DUNS Number (used in some protocols), depending on who is referring to it and what
protocol pis being used.
BizTalk Server provides the ability to store multiple aliases for a party. Every party is given a
single default alias with a name of Organization, with a qualifier as OrganizationName and
value of the name of the party. This alias is always treated as the default alias. Aliases are
provided as triads of name, qualifier, and value. No two parties in the same BizTalk
Configuration database can have the same qualifier value pair. The alias name is used merely
for convenience.
You define business relationships in the Orchestration Designer using role links that contain
two roles. Each of these roles represents a partner in the business relationship the
orchestration is implementing. For example, you might implement an automated purchasing
relationship in a purchasing role link that contains both a buyer and a seller role. You use the
role link to implement two different orchestrations for both sides of the transaction. For
example, the orchestration representing the buyer process implements the buyer role and
uses the seller role.
Conversely, the orchestration representing the seller process orchestration implements the
seller role and uses the buyer role. After you create these roles, an administrator can easily
package the partner orchestration and associated information in a BizTalk application for
quick deployment on a partner running BizTalk Server 2010.
Choosing Partners for Role Links
Orchestrations can depend on the Trading Partner Management system to handle the details of
communicating with a particular partner.
Overview
An orchestration needs a way to indicate with which trading partner that it needs to
communicate. It can indicate a given trading partner to the Trading Partner Management
runtime by setting a property on a role link. Since trading partners are identified by one or
more aliases, the orchestration simply specifies an alias value, and which type of alias it is
using.
The alias must correspond to a value that a business analysts has entered using the Trading
Partner Management user interface, which is provided by the BizTalk Administration
Console. BizTalk Server 2010 defines the new B2B Operator Windows group that a system
administrator can apply when granting access to users who need to maintain Trading
Partner Management information.
On the receive side, the party resolution pipeline component can use identifiers in an
inbound message to attempt to identify a trading partner that is sending the message to
BizTalk. The receive port accepting the message needs to have authentication enabled, and
therefore the needs host to be configured as “trusted”.
ConfirmOrder(Microsoft.XLANGs.BaseTypes.DestinationParty) = new
Microsoft.XLANGs.BaseTypes.Party("SpeedEx", "OrganizationName");
If the initiating role is a provider for receiving messages, the DestinationParty property is
initialized automatically by the receiver. The DestinationParty is set to the provider itself.
The SourceParty property is read-only, and is supplied by the party resolution pipeline
component based on the security identifier (SID) of the sender or on a certificate associated
with the party. The host running the pipeline component must be marked as Authentication
Trusted. You can get the value of the SourceParty in the Expression shape by using the
following sample code:
PartyName = Buyer_Supplier(Microsoft.XLANGs.BaseTypes.SourceParty);
Dynamic Binding Options
Dynamic binding offers benefits that Specify Now and Specify Later cannot provide.
Overview
To summarize the various dynamic binding options that BizTalk offers:
Dynamic addressing relies on a predetermined subscription, but leaves options open for
configuration of a physical send port.
Direct binding to the MessageBox addresses the creation of subscriptions at a more
abstract level. Binding directly to the MessageBox offers the most flexibility. An
orchestration can decide at runtime which message context properties it wants to set for
each message. This binding style is very powerful, but application designers need to think
carefully about how to ensure that messages are delivered correctly.
Self-correlating ports are more tightly coupled than binding directly to the MessageBox, but
an orchestration can still choose at runtime from amongst a number of different
orchestrations to start. It could starting more than one if necessary. This binding style
makes it easier to ensure that message is delivered correctly.
Shared ports are the least flexible of the direct binding options, but they are also the easiest
to set up. With this binding style, the correlation and subscription details are hidden by the
designer and runtime.
Role Links offer a form of dynamic binding that address the specific use case of managing
subscriptions on the behalf of individual trading partners.
Conclusion
Although a message appears to go directly from one orchestration to another with direct
binding, any message sent through any type of logical port always travels through the
MessageBox database. Moreover, direct bound ports are only logical ports and therefore
direct binding is only a design-time configuration feature. A direct bound port cannot be
bound to a physical port, and you can only change the direct binding configuration at design
time.
One thing to keep in mind with these direct messaging options, as well as using the Start
orchestration shape to asynchronously start an orchestration, is that they all use the
underlying publish and subscribe model. The difference between these options is in the
properties that are used for creating subscriptions and routing, and in the use cases they
help solve.
Demonstration: Configuring Dynamic Ports
Lesson objective:
Simple correlation will break down when BizTalk receives multiple related messages
simultaneously.
Lesson Overview
Correlation addresses the issue of handling subscriptions when an orchestration needs to
process messages that are related to one another. Correlation was introduced in Module 9,
Automating Business Processes.
Simple correlation, however, is not sufficient in all cases. It is possible to encounter
situations in which simple correlation breaks down, and the runtime needs to step in and
coordinate at a higher level. This lesson covers these special cases, which are known as
convoys.
How Correlation Works
The BizTalk runtime handles correlation by creating fine-grained subscriptions on the fly.
Overview
Correlation in orchestrations is the mechanism that enables an orchestration to receive
related messages in to the same running instance.
In the case of simple correlation, an orchestration sends out a message and waits for a
corresponding response. Under these circumstances, the BizTalk runtime needs to watch for
a specific message to return back to the orchestration. Here, the BizTalk runtime relies on
the orchestration to provide a set of message context values, known as a correlation set,
that it can use to create a fine-grained subscription to pick up the response message
intended for the orchestration.
When the matching response message arrives, the runtime delivers the message to the
orchestration to continue processing, and the runtime drops the subscription.
Overview
In BizTalk Server, there are two main types of subscriptions: activation and instance. An
activation subscription is one specifying that a message that fulfills the subscription should
activate, or create, a new instance of the subscriber when it is received. Examples of things
that create activation subscriptions include send ports with filters or send ports that are
bound to orchestrations, and orchestration receive shapes that have their "Activate"
property set to true.
An instance subscription indicates that messages that fulfill the subscription should be
routed to an already-running instance of the subscriber. Examples of things that create
instance subscriptions are orchestrations with correlated receives and request/response-
style receive ports waiting for a response from BizTalk Server.
Instance subscriptions are created for receive shapes that are following a correlation set,
and they include the specific values that are included in the correlation set when it is
initialized. The subscriber ID includes the orchestration instance ID.
Instance subscriptions come into play when a correlation set is initiated, as this is when
subscriptions are created for all of those ports that follow this correlation set to receive
messages. Because the correlation type defines the properties to be used for correlation, the
orchestration engine can extract these properties from the message being sent or received
by the initiating action. These values are then used to define subscriptions for all of the
remaining actions which follow this correlation set.
Convoy Messaging Patterns
An orchestration needs the BizTalk runtime to provide additional coordination in certain cases.
Overview
Under certain conditions, an orchestration instance might receive a group of correlated
messages all at the same time. In this situation, a race condition might occur, in which one of
the messages in the group must initialize a correlation set in the orchestration instance
before the other messages can be correlated to that orchestration instance. A convoy exists
any time in which the BizTalk runtime must handle multiple related messages that could
cause a race condition within an orchestration instance.
Convoy patterns are correlation use cases that require special handling. In these cases,
simple correlation would break down and route messages incorrectly. When dealing with
convoy patterns, the runtime needs to step in to coordinate at a higher level. The
Orchestration Designer recognizes convoy patterns, and it enforces constraints required by
the BizTalk runtime to handle the convoy messages correctly.
BizTalk handles convoy subscriptions differently than it handles other types of instance
subscriptions to determine if a message should be sent to a new instance, or to a running
instance.
To ensure that all of the correlated messages are received by the same orchestration
instance, BizTalk Server detects the potential for such a race condition and treats these
messages as a convoy. At enlistment, the runtime creates a general subscription and
identifies it as part of a convoy. After filling this subscription, the messaging engine creates a
temporary subscription based on the values in the predefined correlation properties. All
subsequent messages that match the general subscription are evaluated against the
temporary subscriptions, and those that match are routed to an existing orchestration.
There are two main types of convoys: sequential convoys and parallel convoys. The main
difference in the two types of convoys is the order of receipt of the items.
Sequential Convoys are sets of related items that have a predefined order. The items do not
have to be exactly the same, but they are all related to a specific instance of a business
process.
Parallel Convoys enable a business process to wait for a set of messages of different types to
arrive in any order before continuing to process.
“Zombie” Messages
The use of convoys can result in "lost" messages which are known as “zombie” messages.
When a non-activating receive subscription in a running orchestration matches a message in
the MessageBox database, then the BizTalk runtime is obligated to deliver the message to
the orchestration. Because the MessageBox does not know the business logic inside the
orchestration, it simply delivers all of the messages that match the subscription to the
orchestration. If any of these messages are delivered when the orchestration execution flow
has passed all of the corresponding receive shapes, then the messages are suspended,
becoming “zombie” messages.
An example of a situation that creates zombies is a receive inside a loop that iterates 17
times, but 18 messages are delivered that match the receive subscription in the loop. (The
MessageBox does not know that the orchestration logic only handles 17 messages.) The
18th message delivered is not consumed by the orchestration because execution flow has
already exited the loop. The orchestration is completed with discarded messages (zombies),
which are not resumable because the orchestration instance has already completed.
You can manage zombies by using a Windows Management Instrumentation (WMI) script to
query the instances with the "Suspended-NonResumable" state. In addition, the messaging
engine writes an error message, "Completed with discarded messages", to the event log.
Sequential Convoys
Overview
A sequential convoy occurs when multiple, related messages arrive in a series. In this case,
you will need to know at design time, which type of message will arrive first. Subsequent
messages do not need to be of the same time, but they will need to be correlated, and they
are required to arrive through the same receive port.
Since multiple messages could arrive simultaneously, the runtime needs to ensure that it
takes additional precautions to handle the instance subscriptions.
There are two sub-types of sequential convoys: uniform sequential convoys and non-
uniform sequential convoys.
Overview
Determining the correct loop condition is a key part of the design of a convoy. When is it
okay to break out of the receive cycle and move on with the processing?
Parallel convoys support allow an orchestration to receive a fixed number of messages in any
order.
Overview
A parallel convoy occurs any time on orchestration will wait for a known quantity of related
messages that may arrive in any order. The messages may be of different types, and may
arrive through one or more ports.
An example would be a hospital admissions process in which an admissions message, a
medical records message and a room assignment message must arrive before the business
process can proceed.
Implementing Parallel Convoys
Overview
In order to handle a parallel convoy inside an orchestration, you must use the Parallel Action
shape. Add a Receive shape to each parallel branch in the shape, one for each message that
you must receive. If the Parallel Action shape is the first shape in the orchestration, all of the
Receive shapes inside the Parallel Action shape must have their Activate property to "True.
The incoming messages may be received from different ports and be of different types.
Use a correlation set to relate all the incoming messages together. Each of the Receive
shapes inside the Parallel shape must initialize the correlation set.
Demonstration: Implementing Convoy Patterns
Overview
In this lab you will update the Northwind ordering process to make the orchestration
messaging more dynamic and add support for correlation. You will use role links to provide
partner specific sending and receiving and add dynamic links to support a publish and
subscribe messaging model for you orchestrations. In addition, you will use correlation to
route related messages to an orchestration instance.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-15 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose
Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click Ask Me Later, then click OK.
Property Value
Construct shape
Messages constructed ShipRequest
Name Construct ship request
Transform shape
Name MapOrderToShipRequest
Map Northwind.Maps.MapOrderToShipRequest
Note: This map exists in the Northwind.Maps assembly.
Send shape
Name SendShipRequest
Message ShipRequest
Receive shape
Name ReceiveShipAcknowledgement
Message ShipAcknowledgement
5. In the orchestration view window, expand the Types node and right click Correlation
Types, and then click New Correlation Type.
6. In the left pane, expand Northwind.Schemas, click OrderIdentifier then click Add,
and then click OK.
The Northwind.Schemas.OrderIdentifier property is now included in the
correlation type.
7. Set the Identifier property on the correlation type to ShippingCorrelationType.
You have defined a correlation type, which identifies which context properties
will be used to correlate. In the next step, you will define a correlation set which
is a container for specific data, based on this type.
8. Right click the Correlation Sets node to create a new correlation set.
9. Set the identifier property to ShippingCorrelation.
10. Set the correlation type to Northwind.Orchestrations.ShippingCorrelationType
11. On the SendShipRequest shape, set the Initializing Correlation Sets property to
ShippingCorrelation.
12. On the ReceiveShipAcknowledgement shape, set the Following Correlation Sets to
ShippingCorrelation.
You have configured the two ports to participate in correlation. When a message
is sent from the send port, it will initialize the correlation set with the values
currently in the context properties. The receive shape that follows the
correlation set will now have an instance subscription based on the correlation
set values.
13. Right-click on the right-hand port surface, and click New Configured Port.
14. In the wizard, name the port ShippingPort and create a new port type named
ShippingPortType.
15. In the next wizard pane, indicate that you will be sending messages and accept all
other defaults.
16. Right-click on the right-hand port surface, and click New Configured Port.
17. In the wizard, name the port ShippingAckPort and create a new port type named
ShippingAckPortType.
18. In the next wizard pane, indicate that you will be receiving messages and accept all
other defaults.
19. Drag the connection points from the send and receive shapes to these new ports as
appropriate.
OrderShipAck = Northwind.Utilities.MessageCreator.CreateShipAck(
OrderShipRequest(Northwind.Schemas.OrderIdentifier));
7. Configure the Shipping orchestration by binding the logical ports to the physical
ports with the following mappings, and choosing the BizTalk Server Application as
the host:
8. Both orchestrations should show green check marks when all of the configuration is
complete.
9. Apply the changes and exit the configuration dialog.
Note that in this scenario we hard code the shipper name. In a real scenario, you
would use business rules to dynamically determine the shipper. We use the
shipper name, but when defining parties, any custom identifier can be created as
an alias for that party and used to set the destination part. For example, your
internal customer id, or a DUNS number.
5. Your orchestration should look similar to the image below:
6. Build the solution and fix any problems that arise.
7. Right click the solution and choose Deploy Solution.
Exercise 3: Define Parties
Overview
In this part you will define the configuration related to the roles and send ports for the
orchestration. You will create physical send ports for each shipper and then enlist or link
them to the role link you defined in the business process.
Course Evaluation
Your evaluation of this workshop will help Microsoft understand the quality of your learning
experience.
Please work with your training provider to access the workshop evaluation form.
Microsoft will keep your answers to this survey private and confidential and will use your
responses to improve your future learning experience. Your open and honest feedback is
very valuable.
Module 16: Integrating with the WCF LOB
Adapter Framework (Optional)
Time estimated: 105 minutes
Module objective:
This module explains how take advantage of the WCF LOB Adapter SDK to expose Line of
Business (LOB) systems as WCF services.
Module Overview
Today’s applications require business data and logic that is distributed across several
applications or servers. Unfortunately, not all systems provide the same interface to their
data and business logic which ultimately forces developers to figure out how to talk to each
of those systems. Developers have to deal with network protocols, different message
formats, varying security mechanisms, and in many cases custom libraries that rely on
proprietary mechanisms. In the end, it’s common for developers to struggle with learning a
variety of different programming interfaces, communication protocols, and messaging
semantics.
By using the WCF Line of Business (LOB) Adapter SDK to build an adapter, any LOB system
can be exposed as a WCF service and consumed by any WCF client application as if it were a
traditional WCF service found on the network somewhere.
Lesson 1: Introduction to the WCF Line of Business (LOB)
Adapter Framework
Lesson objective:
This lesson explains what the WCF LOB Adapter Framework is, and why you might want to use it.
Lesson Overview
The goals addressed by WCF are very similar to the integration goals of Microsoft BizTalk
Server. Ultimately BizTalk Server is focused on providing an easy-to-manage model for
connecting disparate, heterogeneous systems using a variety of different protocols, message
formats and security mechanisms without requiring much, if any, code.
This lesson introduces the WCF LOB Adapter SDK, and it explains why you might want to use
it.
Why Use the WCF LOB Adapter Framework?
Explain the role that the WCF LOB Adapter Framework plays in enterprise integration scenarios.
Overview
With the WCF adapters in BizTalk Server, you can consume any LOB application that has
been service-enabled. This means that someone has already gone to the effort to expose the
LOB functionality through a service façade that provides WSDL and XSD metadata to simplify
client consumption. Assuming this is the case, you can easily use the built-in WCF adapters
to consume the service-enabled LOB application. If not, you’ll first need to service-enable
the LOB application before you’ll be able to consume it. The process of service-enabling is
becoming a more common task throughout enterprises today.
One of the challenges many organizations run into while service-enabling applications is
figuring out how to effectively expose metadata to the consumer. Some applications expose
such a vast underlying data source, it would be impossible to serve up a single WSDL
definition describing everything it can do (e.g., think about what it would be like to write a
WSDL definition for everything found in your SQL Server databases). In situations like this, it
probably makes more sense to ask the consumer “what data” they’re interested in up front
and generate specialized metadata files for that particular usage.
Because these service-enablement challenges are so common throughout enterprises,
Microsoft decided to introduce the WCF LOB Adapter SDK. The WCF LOB Adapter SDK
provides a simplified and unified model for creating custom BizTalk adapters that can be
used from any WCF client application including, but not limited to, BizTalk Server. The SDK
makes it much easier to provide metadata-driven adapters that can embrace native LOB
protocols and formats when necessary.
What Is the WCF LOB Adapter Framework?
Overview
The WCF LOB Adapter SDK is a set of tools and components for creating adapters based on
the WCF channel programming model. The SDK includes a set of runtime components as
well as design-time tools and interfaces that simplify the process of hosting or consuming
adapters built with the SDK. By using the SDK to build an adapter, any LOB system can be
exposed as a WCF service and consumed by any WCF client application as if it were a
traditional WCF service found on the network somewhere.
Much like the BizTalk adapter programming model that preceded it, the WCF LOB Adapter
SDK provides a programming model that allows developers to focus primarily on the issues
specific to communicating with a given application without having to worry about all the
details of writing WCF components. Instead of programming against the WCF channel
model, developers write their adapters against a simpler set of API’s that focus on
connecting to and interacting with the target system.
An adapter built with the SDK is packaged and exposed to WCF as a binding that can be
configured for a given client or service endpoint. This provides a very simple abstraction for
developers to use when using the adapter.
Outbound Adapter Architecture
Overview
When a WCF LOB outbound adapter is hosted in the client process, the client application
creates an instance of a WCF proxy configured to use the adapter binding. The act of
creating the proxy initiates the adapter in the client process. When the adapter is being used
for request/response communications, the client application triggers the adapter logic by
attempting to call an operation on the proxy, thus sending a message through the WCF
binding to the adapter, which then makes the corresponding API calls to the LOB system.
When the WCF LOB outbound adapter is hosted on a server, the adapter code is hosted in IIS
or Windows Process Activation Service (WAS) and is accessed by clients through WCF.
Essentially, the client channel for the adapter is taken and exposed as a WCF service using
standard bindings such as the BasicHttpBinding or WSHttpBinding to make it accessible to
more clients and tools. Using this hosting model, the LOB adapter truly becomes just
another WCF service that client applications can call and interact with. Hosting adapters in
IIS/WAS creates a WCF service endpoint that exposes a set of operations from the LOB
system.
Inbound Adapter Architecture
Overview
When an adapter will be used in an inbound capacity, that is, when it will be receiving
messages from an LOB system and delivering them to the client process, the adapter needs
to be hosted in a listening mode. The solution is for the client process to use the ServiceHost
class to create an instance of the generated proxy class and create an endpoint using the
appropriate binding for the LOB System. After the LOB system contacts the client process,
the implementation of the contract will execute in the client process.
Demonstration: Consuming a WCF LOB Adapter Service
Lesson objective:
To understand how to implement the classes that are required to create a WCF LOB Adapter.
Lesson Overview
For adapter developers the SDK simplifies the job of encapsulating the communication
semantics for a particular LOB system. The goal of the adapter model has always been to
write the adapter once and enable a broad range of processes to interact with the target
system. The main difference now is the use of WCF as the underlying implementation
framework. In addition, the SDK greatly simplifies the process of exposing metadata to client
applications so developers don’t have to understand WSDL very deeply.
When you build LOB adapters with the WCF LOB Adapter SDK, you are actually building a
custom transport channel for WCF. However, the WCF LOB Adapter SDK extends and
abstracts the WCF messaging layer and makes this much easier to accomplish. It provides a
simplified set of interfaces focused on creating connections and handling messages,
shielding you from most of the low-level channel details. This abstraction helps developers
focus primarily on the issues of connecting to the LOB system and translating between WCF
messages and LOB API calls.
You expose your custom adapter (transport channel) like you would any custom transport
channel – by creating custom binding and binding element implementations for others to
use. After the adapter is packaged, any WCF client can create a client proxy using the binding
you’ve provided and invoke operations on it without worrying about the underlying
communication details. However, in order to generate a client proxy that provides an
appropriate contract, the client needs a mechanism to retrieve metadata from the adapter
as well. This is where the WCF LOB Adapter SDK provides an extremely rich model for
exposing metadata from LOB systems without having to manipulate or work with WSDL.
There are three main areas you’ll need to focus on during the implementation process:
metadata support, connection management and message handling.
Adapters expose metadata so that client applications can choose the operations they
require to interact with the LOB system and can build a client proxy that reflects only those
operations. When building the adapter, it’s the responsibility of the developer to implement
the metadata retrieval process.
Adapters can support metadata browsing through a hierarchical representation of the
exposed operations as well as metadata search functionality. Search functionality is
especially important if your LOB system supports a larger number of operations and you
want to make it easier for someone to find the specific operation they need. Finally,
adapters must provide support for metadata resolution which involves handling requests to
resolve type names to metadata describing the types.
As for the runtime components, there are two primary functions developers must
implement in an adapter: connection management and message handling. Connection
management involves being able to create instances of an object that represents a
connection to your LOB system. The connection class is responsible for managing the
opening and closing of connections to the LOB system much like a SQLConnection instance is
responsible for opening and closing connections to a database. The framework provides
most of the supporting connection management infrastructure you’ll need (such as
connection pooling) but it relies on the adapter to manage the LOB-specific connection
object.
Message handlers provide the actual processing of runtime messages and how they
translate to calls in the LOB application. When creating an adapter, the developer chooses
the message exchange patterns that will be supported by the adapter and the appropriate
synchronous/asynchronous interfaces required to support them. Message handlers include
both inbound and outbound handlers
Visual Studio WCF LOB Adapter Project Template
Overview
The WCF LOB Adapter SDK includes a Visual Studio project template for creating new
adapters. The template uses a wizard to ask you for some basic information about the new
adapter and then it creates the project and classes based on that information.
The wizard starts by collecting information on namespaces and the protocol scheme that will
be used in endpoint addresses. The next step is to specify the message exchange patterns
(MEPs) and the type of metadata support that the adapter will provide.
For metadata you can choose to support browse and/or search and you will have to
implement the resolve. There are a few different message exchange pattern options
including inbound versus outbound and synchronous versus asynchronous.
In the final two steps, the wizard allows you to specify properties that will be available on
the adapter (the binding) and properties needed to implement the connection such as a
server name, port, etc.
After you’ve completed the wizard, the project template generates a number of classes to
support the choices you selected. Some the classes defined in the solution are complete and
ready to use straight-away while others are left to the developer to fill in the
implementation.
Defining a URI
Overview
The generated project contains three classes related to connection management: a
connection class, a connection factory class and a connection URI class. The connection URI
class requires you to implement Uri parsing logic to move between the typed properties for
your connections and the way those properties are formatted into the Uri string.
Managing Connections
Overview
The connection factory class has a default implementation that will create connections when
requested by the Adapter SDK runtime – you don’t have to do anything with this one. The
connection class itself is where most of the connection management takes place, and where
you’ll write the LOB-specific connection code.
In the connection class, you’re responsible for managing the opening and closing of
connections to the LOB system. In addition, the connection class has a ClearContext method
that can be implemented to prepare a connection object to be put back in the pool. Finally,
you can implement the IsValid method to return a status indicating whether the open
connection is in a valid state or not.
Reading Adapter Configuration Settings
Overview
The Adapter class and four binding-related classes are generated to provide the WCF
packaging that makes the adapter easy to use. It provides a binding class, a binding element,
and a binding element extension that make it easy to use the new custom adapter. These
binding classes are preconfigured to expose the adapter properties supplied in the new
project wizard all the way from the configuration up to the adapter class itself.
Creating an Outbound Adapter
Overview
Message handlers provide the actual processing of runtime messages and how they
translate to calls in the LOB application. When creating an adapter, the developer chooses
the message exchange patterns that will be supported by the adapter and the appropriate
synchronous/asynchronous interfaces required to support them. Message handlers include
both inbound and outbound handlers.
The outbound handler simply has an Execute method on it which receives a WCF message
object and is expected to return a WCF message object. The Execute method is where the
adapter runtime behavior is focused, and it is where the real communication with the LOB
system happens.
Creating an Outbound Adapter
Explain how a client calls an outbound adapter to interact with an LOB system..
Overview
After the outbound adapter is deployed, client applications can make calls to the adapter to
interact with the LOB system. On the client-side, the messages pass through the WCF client
side messaging layer to the adapter, which is loaded in the transport channel.
Instead of invoking a remote WCF service, however, the adapter code interacts directly with
the LOB system and the reply, if any, is returned back through the messaging layer to the
client code.
It is fairly straightforward to write the client-side code to call the OutboundHandler:
1. Create an instance of the adapter’s binding class.
2. Use the binding object to create a WCF channel factory.
3. Use the channel factory object to create a new WCF channel with an endpoint
address.
4. Create a WCF message object.
5. Issue the service call through the channel object
6. Process the response message
In practice, developers simply use the WCF proxy code that is generated by adding an
Adapter Service Reference in Visual Studio.
Creating an Inbound Adapter
Overview
When an adapter will be used in an inbound capacity, that is, when it will be receiving
messages and delivering them to the client process, the adapter needs to be hosted in a
listening mode. An inbound adapter is a WCF channel listener. The solution is for the client
process to use the ServiceHost class to create an instance of the generated proxy class and
create an endpoint using the appropriate binding for the LOB System. After the LOB system
contacts the client process, the implementation of the contract will execute in the client
process.
Creating an Inbound Adapter
Overview
For inbound adapters, you must implement four methods of the InboundHandler class,
which will be called by the adapter framework runtime. You must implement StartListener
and StopListener to start and stop whatever specific mechanism the adapter is using to
receive messages.
The other two operations that you must implmement on an inbound handler are
WaitForMessage and TryReceive. The WaitForMessage should listen or poll for an inbound
WCF message from the target LOB system, and it should return true when it detects that a
message is ready to be received. The TryReceive method should attempt to read the
message, which will be passed back to the adapter framework to complete the remainder of
the inbound processing.
Demonstration: Creating a Custom WCF LOB Adapter
If you wanted to change the WCF service namespace, you could check the
Overwrite default service namespace box, and type a value in the Service
namespace box.
10. Click Next.
11. On the Data flows page, check the All box, the Retrieval box, the Browse box and
the Search box, and then click Next.
With these options selected, the wizard will generate code to help you
implement synchronous and asynchronous methods for processing both inbound
and outbound messages. It will also generate code to help you implement
metadata browse and search features which will be covered later in this module.
12. On the Adapter Properties page, in the Property name box, type CacheDurationMin.
13. In the Default value box enter 20, then click Add, and then click Next.
Properties defined on this page apply to the basic capabilities of the adapter.
14. On the Connection Properties page, in the Property name box, enter DataDirectory.
15. In the Data type list, click System.String, and then click Add.
Properties defined on this page are used to configure the connection between
the custom adapter and the LOB system.
16. Click Next.
17. Review the information on the Summary page, and then click Finish.
Fortunately, if you answered everything correctly in the wizard, then you will
only need to edit a few of these files
2. Open the DemoAdapterBindingElement.cs file, and find the CacheDurationMin
property.
This is the property that you specified in the wizard. Notice that
CacheDurationMin will be read from an XML configuration file, as indicated by
the [ConfigurationProperty] attribute. Its value defaults to 20.
3. Open the DemoAdapterTrace.cs file.
You can use the static Trace property of this class to write diagnostic messages
out to trace listeners that are registered to pick them up.
4. Open the DemoAdapterAsyncOutboundHandler.cs file, and locate the Execute
method.
Notice that the Execute method accepts a WCF message, and it returns a WCF
message.
You can implement the BeginExecute and EndExecute methods to support
asynchronous processing against your LOB system.
5. Close the solution.
Notice that the constructor initializes the URI property, and notice that URI
Property extracts the DataDirectory from the URI value.
This class is responsible for handling the communicating with the adapter’s LOB
system via a connection object to query, insert, update or delete data.
2. Expand the Execute method.
The Execute method for this adapter uses a switch statement to determine which
operation should be executed, and then it makes the appropriate method call to
retrieve the requested data from the simulated LOB.
3. Expand the CreateDiscountListMessage method.
This method takes a connection from the adapter’s connection factory and uses
it to determine the data directory that is configured for this adapter.
It then opens the Discounts.xml file, and creates a response message containing
the list of discount codes.
Adapters must be deployed to the GAC in order to work the WCF LOB Adapter
Framework.
3. In Solution Explorer, double-click MachineConfigEntries.xml.
These entries have been added to the machine.config files in the following
folders
C:\Windows\Microsoft.NET\Framework\v4.0.30319\config
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config
These entries, however, would need to be inserted in the machine.config files of
any machine that would host this adapter.
Test the Adapter
1. Open NorthwindLOBAdapterAsynOutboundHandler.cs, locate the
CreateSurchargeListMessage method and set a breakpoint on it.
2. Locate the CreateDiscountListMessage method and set a breakpoint on it also.
3. Right-click on the NorthwindLOBAdapter project, and then click
NorthwindLOBAdapter.
4. Press F5 to start the client app in the debugger.
5. In the Northwind LOB Adapter Client App window, click the Get discounts button.
6. When execution stops on the breakpoint on the CreateDiscountListMessage, press
F10 to step through the code, or press F5 to continue execution.
7. In the Northwind LOB Adapter Client App window, click the Get surcharges button.
8. When execution stops on the breakpoint on the CreateSurchargesListMessage,
press F10 to step through the code, or press F5 to continue execution.
9. Close the Northwind LOB Adapter Client App window.
10. In Visual Studio, on the Debug menu, click Stop Debugging.
11. Close all open windows, and pause the bt10d-demos virtual machine.
Publishing Metadata
Explain the benefits of implementing metadata publication in a custom WCF LOB Adapter.
Overview
Adapters can expose metadata so that client applications can choose the operations they
require to interact with the LOB system and can build a client proxy that reflects only those
operations.
The WCF LOB Adapter SDK provides a programming model that makes it possible for adapter
developers to expose custom metadata from the adapter, so when the adapter is being
consumed, a developer can choose which operations are important and only receive
metadata for the chosen operations.
When building the adapter, it’s the responsibility of the developer to implement the
metadata retrieval process. Adapters can support browsing or searching through the
metadata in order to find the operations of interest.
Publishing Metadata
Explain the options available for publishing LOB system metadata with the WCF LOB Adapter
SDK.
Overview
Adapters can support metadata browsing through a hierarchical representation of the
exposed operations as well as metadata search functionality. Search functionality is
especially important if your LOB system supports a larger number of operations and you
want to make it easier for someone to find the specific operation they need. Finally,
adapters must provide support for metadata resolution which involves handling requests to
resolve type names to metadata describing the types.
Metadata support is found in three files including one for browsing support, one for search
support, and a final class for resolving metadata types. The browse and search classes each
have one method to implement returning an array of MetadataRetrievalNode objects
representing the operations that can be performed on the adapter. These nodes are simply
definitions of named items that can be shown to a developer using the adapter – this is
where you’ll need to do your mapping to the LOB system. The metadata resolver is
responsible for resolving metadata identifiers to operation descriptions.
In addition to resolving operation metadata, the resolver class is responsible for handling
generation of metadata for types that will be exposed from the system. For a given
operation, there may complex types that make up the parameters or the return types. These
types must also be resolved and described using the metadata classes so they can be used in
the generation of WSDL and consumed by users.
Demonstration: Implement Metadata Browse and Search
The first parameter, NodeId, indicates the node in the tree view that is being
populated (i.e. the node that the user clicked in the Select a category tree in the
Add Adapter Service Reference dialog box). The remaining parameters specify
constrains on the response message.
The Browse method returns an array of MetadataRetrievalNodes, which simply
hold names of LOB service operations and categories. The
MetadataRetrievalNodes are displayed in the Select a category tree, and in the
Available categories and operations list in the Add Adapter Service Reference
dialog box.
5. Open the NorthwindLOBAdapterMetadataResolverHandler.cs file.
6. Locate the ResolveOperationMetadata method, and notice the method signature.
The first parameter, operationId, contains the name of the operation that has
been selected by the client.
This method is responsible for returning an OperationMetadata object
containing the metadata that describes the operation’s parameters , return type
and other details.
Since LOB systems change over time, some adapters are implemented to connect
to their corresponding LOB system to find the latest metadata for an operation
before creating the OperationMetadata object.
The first parameter, nodeId, indicates the node in the tree view that is being
searched (i.e. the node that the user clicked in the Select a category tree in the
Add Adapter Service Reference dialog box). The second parameter contains the
search term, and the remaining parameters specify constrains on the response
message.
The Search method also returns an array of MetadataRetrievalNodes that
match the search criteria. The MetadataRetrievalNodes are used to populate
the Available categories and operations list in the adapter configuration UI.
Lesson objective:
Introduce the BizTalk Adapter Pack, and describe how it can be used.
Lesson Overview
Correlation addresses the issue of handling subscriptions when an orchestration needs to
process messages that are related to one another. Correlation was introduced in Module 9,
Automating Business Processes.
Simple correlation, however, is not sufficient in all cases. It is possible to encounter
situations in which simple correlation breaks down, and the runtime needs to step in and
coordinate at a higher level. This lesson covers these special cases, which are known as
convoys.
What is the BizTalk Adapter Pack?
Overview
Microsoft has built and shipped a suite of WCF LOB adapters using the WCF LOB Adapter
SDK. This suite of LOB adapters is referred to as the BizTalk Adapter Pack. The BizTalk
Adapter Pack contains several WCF LOB adapters for some popular LOB systems.
Because of the open architecture of the WCF LOB Adapter framework, these adapters make
it possible to integrate with these LOB systems from any .NET application.
Line of Business Adapters
Describe the WCF LOB adapters that are in the BizTalk Adapter Pack.
Overview
Version 1 of the BizTalk Adapter Pack contains three adapters: Oracle Database, mySAP
Business Suite and Siebel eBusiness Applications.
Version 2 of the BizTalk Adapter Pack added two additional adapters: Oracle E-Business Suite
and SQL Server.
Lab: Applying the WCF LOB Adapter Framework
Overview
In this lab you’ll be using the WCF LOB Adapter SDK to build an “Adapter” which could be
used via a WCF Channel (inside or outside of BizTalk). After completing this lab, you should
understand how to create a WCF LOB Adapter using the WCF LOB Adapter SDK, use a WCF
Adapter and how to create a listener with a WCF Adapter. Using the WCF-Custom adapter,
you could invoke operations on the services from BizTalk as well.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-16 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose
Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click Ask Me Later, then click OK.
Exercise 1: Create a WCF LOB Adapter Framework Project
Overview
In this part, you will use a project wizard in Visual Studio to generate adapter code that can
be customized to suit your needs. You will use the wizard to generate connection properties
that you can use in your adapter to customize the runtime behavior.
Property Value
Name ContosoCustomAdapter
Location C:\AllFiles\LabFiles\Lab16
Property Value
Scheme Contoso
Project Namespace Contoso.CustomAdapter
3. On the Data flows page, select the checkboxes only for the synchronous data flows
and Metadata features so your dialog looks like this, and click Next:
This will create a project which allows all the different channel shapes as well as
enabling all metadata functionality.
4. On the Adapter Properties page, add the properties from the following table by
entering the information and clicking the Add button. Click the Next button when
you have completed.
Property Data Type Default Value
Transactional System.Boolean False
ListenerInterval System.Int32 5000
public ContosoCustomAdapterConnectionFactory(
ConnectionUri connectionUri,
ClientCredentials clientCredentials,
ContosoCustomAdapter adapter)
{
this.clientCredentials = clientCredentials;
this.adapter = adapter;
this.uri = (ContosoCustomAdapterConnectionUri)connectionUri;
}
uri = this.ConnectionFactory.ConnectionUri;
Console.WriteLine(
"Connection object opened - ServerName = {0}, UserName = {1}",
uri.Uri.Host,
uri.UserName);
You typically would open the phyiscal connection to your LOB or database in the
Open method of the IConnection object. .
9. In the Close method, call Console.WriteLine and print out a string that indicates that
the connection object has been closed.
uri = this.ConnectionFactory.ConnectionUri as
ContosoCustomAdapterConnectionUri;
Console.WriteLine(
"Connection object closed - ServerName = {0}, UserName = {1}",
uri.Uri.Host,
uri.UserName);
14. Provide the implementation for the Uri property so that you parse the URI to find
the value for the username field:
4. After that code, add code that creates a new Message, with a MessageVersion of
MessageVersion.None, an action with a blank string, and a body of “A message from
a WCF Adapter”.
Message rm = Message.CreateMessage(
MessageVersion.None,
"",
"A message from a WCF Adapter");
return rm;
In a real implementation, this is where you would process the incoming message,
connect to your LOB application or database, and generate a proper return
message.
5. Build the project and verify that it compiles before moving on to the next Exercise.
Exercise 3: Create an Outbound Client
Overview
In this part, you will create a simple WCF client application to test the adapter that you
created in Exercise 1.
Assembly Name
System.ServiceModel
System.Runtime.Serialization
Microsoft.ServiceModel.Channels
7. Right-click on the OutBoundClient project in the Solution explorer and select “Add
Reference”.
8. Add a reference to the ContosoCustomAdapter project (found under the Projects
tab). Click OK to close the dialog.
Namespace
Contoso.CustomAdapter
System.ServiceModel
System.ServiceModel.Channels
3. Inside of the Main method, create an instance of the
ContosoCustomAdapterBinding and set its Transaction property to true.
IChannelFactory<IRequestChannel> rcf =
b.BuildChannelFactory<IRequestChannel>();
rcf.Open();
EndpointAddress epa =
new EndpointAddress("contoso://alice@contososervername");
IRequestChannel rc = rcf.CreateChannel(epa);
rc.Open();
8. Call IRequestChannel.Request, passing in the Message you just created, use the
return value to initialize a new Message reference, and print out to the console the
string value of this message.
Message rmsg = rc.Request(msg);
Console.WriteLine("Adapter response message: {0}",
rmsg.GetReaderAtBodyContents().ReadInnerXml());
9. Build, and compile. Run once using Ctrl-F5 to verify the output to the console is
correct. Then set breakpoints in the methods you just implemented and run again –
this time using F5, so you can step through the interaction of the client to the
adapter.
Exercise 4: Building an Inbound Handler
Overview
In this part, you will implement the inbound capabilities of the adapter that you created in
Exercise 1.
6. Inside of the StartListener method, add code that starts a Timer and adds a new
Message to _messages field every time the Timer hits.
int interval =
this.Connection.ConnectionFactory.Adapter.ListenerInterval;
Console.WriteLine("Listening");
7. Inside of the WaitForMessage method, add the code below. This is the first method
that will be called by the listening infrastructure. Return true here when there are
messages to process.
lock (_messages)
{
if (_messages.Count > 0)
{
return true;
}
return Monitor.Wait(this._messages,
timeout.TotalMilliseconds >= Int32.MaxValue ?
Int32.MaxValue : (int)timeout.TotalMilliseconds);
}
The purpose of this code is to see if there any messages in the queue (locking the
queue first). It returns true if there are messages to receive. Then it waits the
appropriate Timeout value. It will return true if the Monitor gets the lock on the
_message field within the timeout. The call to Monitor.PulseAll in the timer
delegate will cause this to happen if a message is received (which in this
implementation is a certainty).
8. TryReceive is what will be called repeatedly by the WCF infrastructure over and over
once WaitForMessage returns true.
Console.WriteLine("TryReceive....");
lock (_messages)
{
if (!this.WaitForMessage(timeout))
{
message = null;
return false;
}
message = _messages.Dequeue();
}
return true;
The InboundReply object is built to be able to encapsulate the creation of the
outgoing WCF message. In this implementation we are using a one-way
contract, so that isn’t necessary. In a real implementation, you’d need to fill out
the InboundReply class’ methods.
Assembly Name
System.ServiceModel
System.Runtime.Serialization
Microsoft.ServiceModel.Channels
3. Right-click on the InboundClient project in the Solution explorer and select “Add
Reference”.
4. Add a reference to the ContosoCustomAdapter project (found under the Projects
tab). Click OK.
5. Add a using statement for each of the following namespaces:
Namespace
Contoso.CustomAdapter
System.ServiceModel
System.ServiceModel.Channels
Create a Service Contract
Procedure List
1. Inside of Program.cs (but outside of the Program class) create an interface. Name it
IOneWay. Add the ServiceContract attribute to this interface.
2. Add a method to this interface and name it OneWayMethod. Have it take a single
parameter of type Message and return void. Add the OperationContract attribute
to the OneWayMethod, with Action as a wildcard value (“*”) and IsOneWay equal
to true.
[ServiceContract]
public interface IOneWay
{
[OperationContract(Action="*",IsOneWay=true)]
void OneWayMethod(Message inmsg);
}
3. Inside of Program.cs (but outside of the Program class) create a class. Name it
OneWay. Have the OneWay class implement the IOneWay interface. Inside of the
OneWayMethod write the string value of the Message out to the console.
5. Create a ServiceHost, pass the OneWay type as the parameter to the ServiceHost
constructor.
sh.AddServiceEndpoint(
typeof(IOneWay),
b,
"contoso:// alice@contososervername");
sh.Open();
2. Run once using Ctrl-F5 to verify the output to the console is correct. Then set
breakpoints in the methods you just implemented and run again – this time using F5,
so you can step through the interaction of the client to the adapter. Stop the
command windows when you are satisfied your service is receiving messages.
Module 17: WF and WCF Interceptors for
BAM (Optional)
Time estimated: 105 minutes
Module objective:
In this module, you will learn how to configure BAM interceptors for WF and WCF
applications to enable BAM tracking without recompiling your WF or WCF solution.
Module Overview
In BizTalk Server 2010, BAM is a collection of tools, APIs, and services that allow you to
manage aggregations, alerts, and profiles. With BAM you can also instrument automated
processes to send events to monitor relevant business metrics. Together, these provide end-
to-end visibility into a business process.
The WF and WCF BAM interceptors extend the BAM functionality of BizTalk Server into the
Windows Workflow Foundation (WF) the Windows Communication Framework (WCF)
runtimes.
Lesson 1: BAM Interceptor Architecture
Lesson objective:
This lesson will introduce the WF and WCF Interceptors for BAM.
Lesson Overview
This lesson introduces the WF and WCF Interceptors for BAM, and it explains how to
configure the interceptors to perform BAM tracking in WF and WCF applications.
BAM Interceptors for WF and WCF
Overview
The WF and WCF BAM interceptors extend the BAM features of BizTalk Server 2010 to the
Windows Workflow Foundation (WF), Windows Communication Framework (WCF) runtimes.
By using the BAM interceptors, you can track your business processes without recompiling
your WF or WCF solution — integration is done through a configuration file.
The BAM Interceptor plumbing automatically detects configuration file changes and it will
apply new configurations to new workflow instances while applying the old configuration to
old (existing) messages. This is completely automatic.
The WCF interceptor can intercept messages to a WCF service before the service call or right
before the return value is sent back. Parameter and message values can be grabbed and
flushed to BAM.
Deployment is performed the BAM management tool (bm.exe). Adding, updating, removing,
and interrogating BAM Interceptor configuration files can all be done with the enhanced
bm.exe tool.
Interceptor Integration
Describe how the WF and WCF Interceptors integrate with the BizTalk BAM Interceptor.
Overview
By using BAM interceptors, the various components that make up a business process can
work together to collect tracking data for an instance of BAM Activity that spans application
boundaries. As an example, a single business process might include a WCF service, a BizTalk
orchestration and a WF workflow.
Using the WCF interceptor, the WCF service can initialize a new instance of the BAM activity
and report the time that it received a message. The WCF service could enable a
continuation to allow other components to report tracking data for the activity instance.
Later in the process, a BizTalk orchestration could report data to BAM, such as an Amount
value, to for the same activity instance. The orchestration could also enable a continuation
to allow other components to report tracking data for the activity instance.
Finally, a WF workflow could complete the business process and use the WF interceptor to
report the end time of the activity instance.
Interceptor Configuration (IC)
Describe how developers can create Interceptor Configurations (ICs) for the WF and WCF
Interceptors.
Overview
The BAM interceptors for Windows Workflow Foundation and Windows Communication
Foundation rely on an interceptor configuration (IC) file to determine what events and data
elements to intercept. The IC file is XML and the structure is defined by a set of interceptor
configuration schemas.
A common configuration schema is reused across the WCF and WF BAM interceptors.
However, given the differences between the WCF and WF programming models, the
common schema needs to be extended to incorporate the specific interception mechanisms
for collecting the BAM data. For instance, developers using the BAM WCF interceptor will,
most likely, extract the data from a SOAP or XML message intercepted at different stages of
the client or dispatcher runtimes. On the other hand, developers using the WF interceptor
will extract the activity data from WF-specific components such as workflow properties or
user data types. Essentially, in order to provide a complete declarative mechanism for
populating a BAM activity model, the WCF and WF interceptors need to extend the common
configuration schema with specific elements of their programming model.
The XML Schemas that describe the structure of an IC file can be found in the <BizTalk Server
2010 Install Folder>\SDK\Samples\BAM\InterceptorXSDs folder. You can leverage these
schemas to get XML IntelliSense® when authoring IC files in Visual Studio 2010 (simply copy
them into <Microsoft Visual Studio 2010 Install Folder>\Xml\Schemas). Unfortunately
Microsoft hasn’t yet provided any additional tooling for working with IC files.
Interceptor Configuration (IC)
Overview
The structure of an IC file maps to the structure of the .NET BAM object model. The
BamActivity element in the IC file maps to the BAM Activity that interceptor will write to.
The IC describes the events that should trigger the interceptor to send tracking data to BAM.
The interceptor uses an event’s filter to determine whether or not it should send the data.
When sending data to BAM, the interceptor will include any correlations, continuations and
updated data, including references, that the IC specifies for the event.
Creating an Interceptor Configuration (IC)
Overview
The EventSource element provides information about the source of one or more of the
events appearing in the interceptor configuration file. In addition to an event source name,
you need to indicate the technology and a manifest for the source.
The EventSource element has three attributes and may or may not have child elements
depending upon which schemas are included. For example, the WCF schema
WcfInterceptorConfiguration.xsd provides for a child NamespaceMapping element.
Creating an Interceptor Configuration (IC)
Overview
This example contains two EventSource elements, one targeting WF and one targeting WCF.
Creating an Interceptor Configuration (IC)
Overview
A BamActivity element in an IC maps to an Activity of the same name in a BAM definition
file. A BamActivity element contains one or more OnEvent elements. Any event data that
the interceptor sends to BAM will be written to the BAM Activity specified by the event’s
enclosing BamActivity element.
Creating an Interceptor Configuration (IC)
Overview
The OnEvent element describes one real event that is mapped to the enclosing BAM activity.
The OnEvent element contains settings that define how the interceptor should handle a
particular event that may occur in a WF or WCF application’s runtime. The Name will be
used to reference this OnEvent definition elsewhere in the IC. The Source refers to an
EventSource that was previously defined in the IC file. The IsBegin and IsEnd attributes
indicate if this event is starting or ending the BAM Activity.
The OnEvent element contains child elements that specify an event filter: CorrelationID,
ContinuationToken, Reference, and Update.
Creating an Interceptor Configuration (IC)
Overview
Expression elements are used throughout an IC file. Expressions can serve as OnEvent filter
conditions, or they can be used to extract tracking data from the WF or WCF application.
The extracted data can be used as a correlation ID, as a continuation token or for an update.
Creating an Interceptor Configuration (IC)
Overview
Expressions are made up of Operation elements . The interceptor will evaluate an
operation, and place the result on a stack. It’s possible to use an IC Operation element to
call methods on the WF runtime or the WCF runtime.
The And operation removes the top two items from the stack, performs a Boolean AND of
the two items, and then pushes the result onto the stack.
The Concatenate operation removes the top two items from the stack, concatenates them,
and then pushes the result onto the stack.
The Constant operation pushes a single constant value onto the stack.
The Equals operation removes the top two items from the stack, compares the two items,
and then pushes the result onto the stack.
The IC schemas for WF and WCF define additional operations for interacting with their
respective runtimes.
Creating an Interceptor Configuration (IC)
Overview
Individual expressions are identified in an IC file by the Expression element which contain
one or more Operations arranged as Reverse Polish Notation (RPN), also known as postfix
notation.
In RPN, operands precede the operator, removing the need to use parentheses as
precedence operators. A stack is used to hold values, and all operations either push values
onto the stack, pop (remove) values from the stack, or perform a combination of pushes and
pops to complete an operation.
For example, if you wanted to evaluate the expression
2 * (3 + 4)
Converting this to the equivalent RPN results in
234+*
This would be evaluated as follows:
2 Push 2
3 Push 3, 2
4 Push 4, 3, 2
+ Subtract 7, 2
* Add 14
Overview
This example concatenates three strings using an Expression that consists of five Operations
expressed in RPN.
Creating an Interceptor Configuration (IC)
Overview
The Filter element contains an Expression that evaluates to true or false and determines if an
event should be processed or ignored. If the expression evaluates to true, the event will be
processed, otherwise it will be skipped.
Creating an Interceptor Configuration (IC)
Overview
The CorrelationID element is used to specify a BAM correlation ID for a message. The
CorrelationID element consists of an Expression element that uses one or more Operation
elements to specify the string to use as the correlation ID. CorrelationID expressions may
not use the And or Equals operations.
Creating an Interceptor Configuration (IC)
Overview
The Update element is used to extract data from an event and import it into the related
BAM activity. To use the Update element, you must provide both a column name and type
and an Expression element containing one or more Operation elements that evaluate to a
single string value. Update expressions may not use the And or Equals operations.
Creating an Interceptor Configuration (IC)
Overview
The Reference element can be used to add one or more relationships to a BAM activity. This
is useful when you want to attach a pointer like a primary key, ID, or URL to a related
message. For example, you might store a reference to a Shipment Batch in a Purchase Order
activity.
Reference expressions may not use the And or Equals operations.
Valid Reference Types include BizTalkService, MessageID, Activity, DocumentUrl and
InstanceID.
The Reference element supports both the Data and LongData child elements that contain an
Expression specifying the data to attach to the BAM activity. You can use any combination of
Data and LongData elementsto meet your tracking requirements.
Creating an Interceptor Configuration (IC)
Overview
A ContinuationToken element contains an Expression that evaluates to produce a BAM
continuation ID. ContinuationToken expressions may not use the And or Equals operations.
A continuation ID is used to correlate information across different applications that report
tracking data to the BAM infrastructure. Consider a business process that constructs the
following types of messages:
Purchase order identified by a purchase order number
Sales order identified by a sales order number
Shipping order identified by a shipping order number
In this process, there are three important identifiers: purchase order ID, sales order ID and
shipping order ID. Each of these identifiers signals an important event in the lifetime of the
original order, but they cannot be directly correlated. To track events related to a purchase
order, the information that is common between the messages must be identified to help the
BAM tracking infrastructure accurately correlate the events.
Deploying an Interceptor Configuration
Overview
Every IC must be deployed to the BAM runtime, just like you would deploy a BAM tracking
profile. The BAM management tool, bm.exe, includes commands for managing IC files.
The WF and WCF interceptor components know how to connect to the BAM database to
load the deployed configurations and use the instructions from the IC to perform the BAM
tracking.
Demonstration: Applying an Interceptor Configuration
Notice that Visual Studio Intellisense does not display a list of valid XML element
names.
4. In Windows Explorer, copy the all of the BAM Interceptor XML schema files from
The BAM interceptors will perform a SQL query for the Manifest string, so you
need to be careful to follow the exact format that the BAM runtime will send in
the query. There must be exactly one space after each comma. And, even if the
assembly is not signed, the Manifest must include a value for PublicKeyToken.
Unsigned assemblies simply have a PublicKeyToken value of null.
This EventSource has child elements that pertain only to the WCF interceptor.
These will elements be covered later in this module.
The value of this Name attribute matches the name of the OrderProcessing BAM
activity that originates in the BAM definition that can be found in
c:\AllFiles\DemoCode\Module17\bam_definition.xslx.
6. Locate the OnEvent element with the Name=”OrderProcessing”, and select the
Source attribute.
The value of this Source attribute matches the Name of the first EventSource
element defined in this IC. The OnEvent element contains instructions for events
raised by the component specified in the EventSource.
7. The first child of this OnEvent element is a Filter element. Select the Filter element,
and its enclosed Expression element.
This is the Expression that determines which events will be handled, and which
ones will be ignored. We will examine it in further detail later in this module.
8. Locate the CorrelationID element that immediately follows the Filter element, and
select the Expression within it.
9. Locate the Update element that immediately follows the CorrelationID element,
and select the Expression within it.
This Update Expression instructs the interceptor to update the BAM data item
named OrderTotal, which was assigned a data type of “FLOAT” in the BAM
definition.
cd %BTSInstallPath%\Tracking
bm.exe
The BAM Management tool offers a set of commands for managing interceptor
configuration files: deploy-interceptor, get-interceptor, get-interceptorlist and
remove-interceptor.
2. Enter the following command to display a help screen for the deploy-interceptor
command.
3. Enter the following command (all on one line) to deploy the interceptor
configuration file to the BAMPrimaryImport database.
bm.exe deploy-interceptor
–
filename:C:\AllFiles\DemoCode\Module17\InterceptorConfiguration.xml
Now, when the WF and WCF BAM interceptors are configured and loaded in
their respective runtime environments, they can contact the BAMPrimaryImport
database to find their configuration information.
Most of the data collected for this BAM activity will come from the orchestration
or from the BizTalk send and receive ports. The OrderReceived and OrderTotal
data items are the exceptions. Those two fields will come from the WCF
interceptor and the WF interceptor respectively.
The WCF interceptor will enable this continuation when it receives a new
message. The value of the continuation ID will follow the format
WCF_<OrderNumber>. The BizTalk receive port will follow that continuation.
6. On the Tools menu, click Apply Tracking Profile to deploy the TrackingProfile.btt file
to the BAM runtime environment. In the Tracking Profile Editor warning message
box, click Yes.
The ContinuationID that is mentioned in the warning will be set by a WCF
application that the Tracking Profile Editor is not aware of.
7. In the Tracking Profile Editor confirmation message box, click OK, and then close the
Tracking Profile Editor window.
8. Close all open windows, and pause the bt10d-demos virtual machine.
Lesson 2: Using the WF Interceptor
Lesson objective:
Lesson Overview
The Windows Workflow Foundation interceptor enables you to transparently add BAM
tracking functionality to new and existing WF applications. After the interceptor
configuration has been deployed to the BAM Primary Import database and each instance of
the WF application has been configured to load the BAM WF Interceptor, workflow data will
be written to BAM with no additional code. The WF interceptor provides the following
functionality:
Plugs into existing WF applications without requiring code changes or recompilation.
Enables run-time detection and support for changed configuration files. If a new
version of an interceptor configuration file is detected, new workflow instances will
use the new configuration while old workflow instances will complete using the old
configuration.
Supports transactions. The WF interceptor persists tracked items in a transactionally
consistent way with WF transactions. Tracked items are only persisted when the WF
transaction and the interceptor trasaction complete successfully.
Every time an instance of a WF workflow executes, the BAM WF interceptor will populate
the BAM activity model based on the instructions declared in the IC file.
Introduction to the WF Interceptor
Overview
The BAM WF interceptor is based on the WF tracking services framework. This framework is
designed to enable hosts to observe workflow instances during execution by capturing
events that are raised during workflow execution. The framework is based on a pluggable
design pattern that enables hosts to facilitate complex tracking scenarios by including
different tracking services.
At a high level, a tracking service uses two fundamental components: tracking profiles and
tracking channels. Tracking profiles are used by the tracking service as a mechanism to
communicate the events it would like to receive from the runtime. This guarantees that the
tracking service will only be called for specific events instead of the entire event set
produced by a workflow during its execution. The second component used by the tracking
service is the tracking channel. These components are responsible for receiving the tracking
events and data about the execution of a workflow instance.
Introduction to the WF Interceptor
Describe the additional IC operations that are available for the WF interceptor.
Overview
WF activities are the fundamental building blocks of workflows. A workflow is a set of WF
activities that are organized hierarchically in a tree structure. A WF activity represents an
action in a workflow. It can be a simple action such as a delay, or it can be a composite
activity that consists of several child activities.
The BAM WF interceptor captures different events at the workflow, activity, and user levels.
On each one of those tracking points, we can extract the data from the workflow by using
some of the custom operations provided by the interceptor. For instance, in this case, we
are interested in the Closed event of the TransactionApproved WF activity. When that event
occurs, the interceptor will extract the TransactionID field of the Transaction activity and
map it to the TransactionID activity field. It is important to notice that there are many other
events and functions that can be combined to address diverse BAM WF monitoring
scenarios.
The GetActivityEvent operation pushes the name of the current activity event onto
the stack.
The GetActivityName operation pushes the name of the current activity onto the
stack.
The GetActivityProperty operation pushes the extracted property from the activity
related to the tracking event onto the stack.
The GetActivityType operation pushes the name of the current activity type onto the
stack.
The GetContextProperty operation pushes the requested context property onto the
stack.
The GetUserData operation pushes the current user data onto the stack.
The GetUserDataType operation pushes the name of the current user data type onto
the stack.
The GetUserKey operation pushes the current user key onto the stack.
The GetWorkflowEvent operation pushes the name of the current workflow event
onto the stack.
The GetWorkflowProperty operation pushes the extracted property from the root
activity of the workflow onto the stack.
Introduction to the WF Interceptor
Explain the properties that are available through the WF IC GetContextProperty operation.
Overview
The GetContextProperty operation pushes the requested context property onto the stack.
The InstanceId property is often used for continuation or activity definition. The EventTime
property is useful for reporting a milestone value.
Creating a WF Interceptor Configuration
Overview
The custom operations provided by the BAM WF interceptor can be categorized by the
associated Windows Workflow Foundation track point type:
Activity
Workflow
User
The BAM WF interceptor uses the categories to assign a track point type to each OnEvent. It
bases this assignment on the types of operations it sees in the OnEvent filter and the data
extraction and manipulation sections. For example, if the OnEvent contains an Update
element that uses the GetUserData operation, it is a user track point type because the
activity and workflow events do not support this operation.
Creating a WF Interceptor Configuration
Overview
This simple example shows a Filter expression that checks to see if the current workflow
event is equal to “Started”. Notice that the Operation element for GetWorkflowEvent has an
XML namespace prefix of bamwf. The bamwf prefix maps to the XML namespace defined in
the XML IC schema for the WF interceptor.
Creating a WF Interceptor Configuration
Overview
This example shows a Filter Expression that checks if the event has been raised by a custom
WF activity of type “MyActivities.MyActivity”, and if the WF activity’s name is
“trackableAmount”, and if the WF activity’s status is “Closed”.
Creating a WF Interceptor Configuration
Overview
Developers often use the WF Workflow.InstanceId property for correlation since it is unique,
and it is easy to access and track. You can also use other properties of the WF Activity or
Workflow such as a unique order ID or customer number that would uniquely identify the
instance.
Creating a WF Interceptor Configuration
Overview
These examples show Update Expressions that extract data to update a BAM data item. The
first example shows an Expression that extracts the value of the WF Activity’s Amount
property, and it uses the value to update the BAM data item named “Amount”.
The second example shows an Update Expression that extracts the timestamp of the event,
which is used to update the BAM data item named “Start”.
Deploying a WF Interceptor Configuration
Overview
In order to begin collecting BAM activity data from a WF application, you must install the
BAM interceptor software, and you must configure your application to use the Windows
Workflow Foundation (WF) interceptor tracking service. When configuring the tracking
service, you must provide a polling interval and a connection string for the
BAMPrimaryImport database. The polling interval specifies how frequently the tracking
service should check the BAM database for changes to interceptor configurations.
There are three options for loading the BAM tracking service in your WF application:
If your WF application already uses WorkflowRuntime to load a WF configuration
section, you can added BAM tracking service information to the existing section.
If your WF application does not use WorkflowRuntime to load a WF configuration
section, you will have to add code to load a custom section from your application
configuration file. You will have to create the section and add the BAM tracking
service information to it.
If you prefer to hard-code the configuration, you can use the WF API to
programmatically load the tracking service without a configuration file, or to load
the configuration from a custom source.
Deploying a WF Interceptor Configuration
Show examples of the code required to load the WF interceptor in to the WF runtime.
Overview
These two examples show different ways to enable the BAM tracking service in a WF
application. The first example shows how to start the BAM tracking service
programmatically. The second example shows how to accomplish the same thing by adding
entries to the WF WF application’s configuration file.
Demonstration: Applying the WF BAM Interceptor
Demonstrate how a WF workflow application reports BAM data using the WF interceptor.
The WF interceptor needs to extract and report the value of this property to BAM
when the ProcessBilling WF activity closes.
4. Locate the Filter element, and select the Expression within it.
This Filter Expression conforms to RPN and it checks to see if the WF activity that
raises this event is named “ProcessBilling”, and if the WF activity’s status is
“Closed”.
This expression uses the WF IC Operations GetActivityName and GetActivityEvent
to extract data from the WF runtime. The Operations prefixed with “wf” are
defined in the IC schema extensions for WF. Notice the mapping of the prefix to
the WF IC XML namespace in the root element.
5. Locate the CorrelationID element that immediately follows the Filter element, and
select the Expression within it.
This code loads the billing.xml file that was sent from BizTalk, and it extracts the
values for orderNumber and orderTotal.
runtime.AddService(new BamTrackingService(
“server=.;database=BamPrimaryImport;Integrated Security=SSPI”,
60000);
This line of code initializes the WF BAM tracking service and adds it to the WF
runtime. It is initialized with a connection string to the BAMPrimaryImport
database, and a polling interval. The polling interval specifies how frequently the
BAM tracking service should query the BAMPrimaryImport database for changes
to the ICs.
To use the BamTrackingService you need to add a reference to the
Microsoft.BizTalk.Bam.Interceptors assembly. You can find it in the
%BTSInstallPath%\Tracking folder.
waitHandle.waitOne();
This code starts the BillingProcess workflow, initializing it with the OrderID and
OrderAmount values. The waitHandle.waitOne() line waits for the workflow to
complete.
The BillingApplication watches the file system for billing messages produced by
the BizTalk orchestration. When a file arrives, the BillingApplication will pick up
the file, run the BillingProcess workflow, and the WF interceptor will update
BAM.
This launches a WCF client application that sends an order message to BizTalk.
4. After the order message has been submitted, switch back to the BillingApplication
console window and verify that the workflow completed.
5. In Windows Explorer, in C:\AllFiles\DemoCode\Module17, double-click
SubmitShippingAck.cmd to send a shipping acknowledgement message to the
BizTalk orchestration.
6. In Windows Explorer, in C:\AllFiles\DemoCode\Module17, double-click
OrderProcessingReportsViewer.exe to view the BAM tracking data for this order.
The Order Received timestamp was reported by the WCF client, all of the other
timestamps were reported by the orchestration, and the Order Total was
reported by the WF application.
7. Close all open windows, and pause the bt10d-demo virtual machine.
Lesson 3: Using the WCF Interceptor
Lesson objective:
This lesson will explain how to configure the WCF BAM Interceptor.
Lesson Overview
The Windows Communication Foundation interceptor provides BAM tracking functionality
to your WCF applications. After the interceptor configuration has been deployed to the BAM
Primary Import database and the WCF application has been configured to load the BAM
WCF Interceptor, tracking data will be written to BAM with no additional code. The WCF
interceptor provides the following functionality:
Plugs into existing WCF applications without requiring code changes or
recompilation.
Tracks messages contained in WCF service calls.
Tracks information from messages in WCF service calls.
Participates in transactions flowed from the client or initiated internally for
transacted service calls.
Every time an instance of the configured WCF client or service executes, the BAM WCF
interceptor will populate the BAM activity model based on the instructions declared in the IC
file.
Introduction to the WCF Interceptor
Overview
The BAM WCF interceptor is a flexible technology that allows developers to populate BAM
activity models based on the information exchanged by WCF services and clients. In order to
model the interactions with the BAM model, the BAM WCF interceptor schema extends the
basic interceptor configuration model with WCF-specific elements. Essentially, the
interceptor configuration file models how WCF messages are mapped to BAM activities
throughout the different stages of the client or dispatcher runtimes
The BAM WCF interceptor leverages endpoint behaviors as the extensibility point used to
insert the BAM interception mechanisms into the WCF client and dispatcher runtimes. When
the endpoint behavior is loaded by the client or service host, it plugs in message and
parameter inspector components that interpret the interception configuration file in order
to log the data to the BAMPrimaryImport database.
Introduction to the WCF Interceptor
Describe the additional IC operations that are available for the WCF interceptor.
Overview
The WCF interceptor configuration schema defines a set of operations that can be used to
extract BAM tracking information from a WCF message at runtime.
The AutoGenerateCorrelationToken operation automatically generates a correlation
token and places it onto the stack. This operation can be used when there is no
correlation token present in the message but you still want to correlate the
information from a request and a reply. It can be used to correlate a particular
request/reply on either the client or the service side.
The GetContextProperty operation pushes the requested context property onto the
stack.
The GetEndpointName operation pushes the name of the current interception
endpoint onto the stack. It is important to note that the client and server
applications will return different names for the same endpoint name specified in the
app.config files. For client applications, the endpoint name retrieved by the
GetEndPointName operation is the binding name followed by an underscore and the
contract name. For example, if the Name property on ServiceEndpoint is not set but
the binding is set, the name will be set to <binding>_<contract>. If the name and
binding are not set, the Name property will be set to <contract>. For the service, the
name retrieved is the endpoint name specified in the app.config file.
The GetOperationName operation pushes the name of the current operation onto
the stack. When using GetOperationName, make sure you compare the operation
name as it is invoked by your application. For example, if you use the name attribute
on a service contract to assign a custom name, the client will have its default proxy
generated with the custom name for the method. However, the server application
will use the actual method names for the corresponding operations and not the one
specified in the name attribute.
The GetServiceContractCallPoint operation pushes the name of the current service
contract call point onto the stack. A Windows Communication Framework service
can be intercepted at different points in the lifetime of the service contract.
The XPath operation pushes the value indicated by an XPath statement. In the case
of multiple matches, only the first match is used.
Creating a WCF Interceptor Configuration
Explain the properties that are available through the WCF IC GetContextProperty operation.
Overview
The GetContextProperty operation pushes the requested context property onto the stack.
The SessionId property is often used for continuation or activity definition. The EventTime
property is useful for reporting a milestone value.
The SessionId will be available only when using a session-based WCF binding such as
wsHttpBinding.
Creating a WCF Interceptor Configuration
Explain the options that are available for the WF IC GetServiceContractCallPoint operation.
Overview
GetServiceContractCallPoint pushes the name of the current service contract call point onto
the stack. An IC Filter expression for the WCF interceptor must always include a condition
that checks the GetServiceContracCallPoint property. The WCF interceptor needs to know
the point in the lifetime of the service contract at which it should collect BAM tracking data.
Creating a WCF Interceptor Configuration
Overview
This example shows an IC Filter Expression that checks if the WCF service contract call point
is “ServiceRequest”, and if the operation name is “ProcessOrder”. If both conditions are
true, then the WCF interceptor will follow the subsequent IC instructions to extract the
tracking data and set it to BAM.
Deploying a WCF Interceptor Configuration
Explain what is required to configure the WCF runtime to load the WCF interceptor.
Overview
You must install the BAM interceptor software and configure your application to use the
BAM Windows Communication Foundation (WCF) interceptor service before you can begin
collecting BAM activity data.
To enable BAM tracking in your WCF server or client application, you will need to modify the
app.config configuration file to include an additional endpoint behavior and behavior
extension and add a behavior configuration attribute. The formats of the service and client
templates are similar. The behavior implementation injects message and parameter
inspector components into the call execution path so it can track data before and after each
call.
Since the WCF BAM interceptor is an endpoint behavior, you can also enable it within the
WCF adapters when using WCF-Custom or WCF-CustomIsolated. One advantage to using the
WCF interceptor (over the built-in pipeline interceptor) is that it can capture fault messages.
Another potential advantage is consistency throughout your BizTalk Server and WCF
applications.
Deploying a WCF Interceptor Configuration
Show an example of the configuration required to load the WCF interceptor in to the WCF
runtime.
Overview
The WCF BAM interceptor is implemented as a custom endpoint behavior that you configure
on client or service endpoints. In order to configure this behavior, you need to register it
within the <behaviorExtensions> section of <system.serviceModel>.
Demonstration: Applying the WCF BAM Interceptor
Examine a WCF client application that is configured to use the WCF interceptor.
This is a very simple WCF client that submits an order message to a BizTalk
receive location that has been exposed as a web service.
Orders.OrderServiceClient proxy =
new OrderClient.Orders.OrderServiceClient();
proxy.Open();
This is code creates and opens a WCF proxy object, which will be used to call the
web service.
5. Locate and select the following lines of code.
This code reads an XML file that is specified in a command-line argument. The
contents of the XML file are deserialized to initialize an Order object.
try
{
proxy.SubmitOrder(order);
}
finally
{
if (proxy.State ==
System.ServiceModel.CommunicationState.Opened)
proxy.Close();
else
proxy.Abort();
}
This code issues the call to the web service to submit the order. If the call returns
successfully, it closes the proxy, allowing any remaining processing to complete.
If not, it aborts the operation, forcing the proxy to close immediately.
4. Locate the Filter element, and select the Expression within it.
This Filter Expression checks to see if the WCF service contract call point is
“ClientRequest”, and if the client is calling the web service’s “SubmitOrder”
operation. This expression uses the WCF IC Operations
GetServiceContractCallPoint and GetOperationName to call the WCF runtime.
The Operations prefixed with “wcf” are defined in the IC schema extensions for
WCF. The prefix is mapped to the WCF IC XML namespace in the root element.
Every WCF interceptor Filter Expression must include a condition that checks the
GetServiceContractCallPoint operation. If it is omitted, none of the events fired
by the WCF runtime will ever pass the Filter Expression.
5. Locate the CorrelationID element that immediately follows the Filter element, and
select the Expression within it.
This CorrelationID Expression creates a new BAM Activity ID for the order that
the OrderClient application is sending to BizTalk.
6. Locate the Update element that immediately follows the CorrelationID element,
and select the Expression within it.
This Update Expression instructs the WCF interceptor to use the WCF
GetContextProperty operation to get the current date and time from the WCF
runtime. The Update Expression then updates the BAM milestone named
OrderReceived.
8. Notice the “ns0” prefix in the XPath expression, then locate EventSource element
described in step 2, and select its child wcf:NamespaceMappings element.
The prefix “ns0” in the XPath expression is mapped to an XML namespace by
using a Namespace element. The Namespace element is defined in the XML
schema for WCF IC extensions.
When the XPath expression is evaluated, this mapping will be passed to the
XPath processor, allowing the processor to correctly interpret the “ns0” prefix.
<client>
<endpoint
address="http://localhost:8080/BAMInterceptorDemo/OrderService.svc"
binding="basicHttpBinding"
behaviorConfiguration="bamEndpointBehavior"
contract="Orders.OrderService"
name="BasicHttpBinding_ITwoWayAsyncVoid" />
</client>
This configuration setting is adding new functionality to the base WCF client
proxy used for calls to the web service named OrderService.
<behaviors>
<endpointBehaviors>
<behavior name="bamEndpointBehavior">
<BamEndpointBehaviorExtension
ConnectionString="server=.;database=BAMPrimaryImport;…"
PollingIntervalSec="5000" />
</behavior>
</endpointBehaviors>
</behaviors>
type="Microsoft.BizTalk.Bam.Interceptors.Wcf.BamEndpointBehavior,
Microsoft.BizTalk.Bam.Interceptors, Version=3.0.1.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</behaviorExtensions>
</extensions>
This launches the OrderClient application, which loads the WCF interceptor, and
sends an order message to BizTalk. The WCF interceptor will generate a BAM
activity ID, generate a continuation token, and it will update the OrderReceived
milestone, sending all of this tracking data to the BAMPrimaryImport database.
3. Switch to the BillingApplication console window and verify that the workflow has
processed the order.
4. In Windows Explorer, in C:\AllFiles\DemoCode\Module17, double-click
OrderProcessingReportsViewer.exe to view the BAM tracking data for this order.
At this point, the BAMPrimaryImport database holds only part of the data for
this instance of the OrderProcessing BAM activity. Only the WCF interceptor and
the WF interceptor have reported tracking data so far.
5. In Windows Explorer, in C:\AllFiles\DemoCode\Module17, double-click
SubmitShippingAck.cmd to send a shipping acknowledgement message to the
BizTalk orchestration.
6. Switch back to the OrderProcessingReportsViewer window, and click Refresh to
view the BAM tracking data for this order.
Now that the orchestration has reported its milestone dates, the
BAMPrimaryImport database contains all of the tracking data that will be
reported for this BAM activity.
7. Close all open windows, and shut down the bt10d-demos virtual machine.
Configuring BAM Tracing for WF and WCF Interceptors
Overview
If you encounter problems or would like to see diagnostic information while developing a
WF or WCF IC file, you can enable BAM API tracing for the interceptors. To enable end-to-
end tracing of the BAM interceptors, you modify the application’s configuration file—either
web.config for web-hosted applications, or app.config for self-hosted applications.
The WF and WCF Interceptor trace messages are written to the source named "Microsoft
BizTalk Bam Interceptors"
This example shows the .config file entries required to send the WF and WCF IC trace output
to a console window.
Lab: Creating a BAM Interceptor Configuration
Overview
In this lab you will be configuring your applications to push KPIs into BAM using the BizTalk
BAM interceptors. In this lab the application is already created for you, you will only create
and configure the WF, WCF, and Orchestration’s interceptors to track data across a logical
process (spanning more than one physical processes). After completing this lab, you should
understand how to: author an interceptor configuration file; deploy an interceptor
configuration file; configure the BAM interceptor for WF; configure the BAM interceptor for
WCF and use continuations to instrument multiple processes with BAM.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-17 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose
Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click Ask Me Later, then click OK.
Milestone Description
Start When the process starts; this will be when the WF
Workflow begins processing.
OrchProcessing When the BizTalk Orchestration starts processing.
Processing When the WCF Service begins processing.
Done When the BizTalk Orchestration receives the
response from the WCF Service and ends.
cd %BTSInstallPath%\Tracking
8. From the command prompt, deploy the BAM Activity by typing the following
command (replacing the lab directory) and hitting enter:
You will have to type this command line in by hand. Copying the command from
this document will not work correctly
Exercise 2: Creating the Interceptor Configuration File
Overview
In this part, you will create a single interceptor configuration file for both WF and WCF
components. The WinForms application begins a workflow and sends data to an
orchestration. The orchestration then calls a WCF service.
If you encounter any problems, there is a copy of a the completed IC file in the
C:\AllFiles\LabFiles\Lab17\ContosoActivity.xml folder for reference.
<bam:BamActivity Name="ContosoOrderingSystem">
</bam:BamActivity>
3. Inside of the OnEvent element for the ConstosoWorkflow source which you just
created, create a filter for the Workflow Started event.
<bam:Filter>
<bam:Expression>
<bamwf:Operation Name="GetWorkflowEvent"/>
<bam:Operation Name="Constant">
<bam:Argument>Started</bam:Argument>
</bam:Operation>
<bam:Operation Name="Equals"/>
</bam:Expression>
</bam:Filter>
4. After the filter you just added, still inside of the OnEvent element, create a
CorrelationId element that uses the Workflow.InstanceId as its context property
(use the GetContextProperty operation for InstanceId).
<bam:CorrelationID>
<bam:Expression>
<bamwf:Operation Name="GetContextProperty">
<bamwf:Argument>InstanceId</bamwf:Argument>
</bamwf:Operation>
</bam:Expression>
</bam:CorrelationID>
5. Next you’ll add the Update element, which uses the GetContextProperty to cause a
timestamp to be written to the BAM Activity for the Start milestone.
6. Next, create two Continuation Token elements – one for BizTalk to continue, one
for WCF to continue.
<bam:ContinuationToken>
<bam:Expression>
<bam:Operation Name="Constant">
<bam:Argument>CorrelationId_</bam:Argument>
</bam:Operation>
<bamwf:Operation Name="GetContextProperty">
<bamwf:Argument>InstanceId</bamwf:Argument>
</bamwf:Operation>
<bam:Operation Name="Concatenate"/>
</bam:Expression>
</bam:ContinuationToken>
<bam:ContinuationToken>
<bam:Expression>
<bam:Operation Name="Constant">
<bam:Argument>WCF_</bam:Argument>
</bam:Operation>
<bamwf:Operation Name="GetContextProperty">
<bamwf:Argument>InstanceId</bamwf:Argument>
</bamwf:Operation>
<bam:Operation Name="Concatenate"/>
</bam:Expression>
</bam:ContinuationToken>
2. Inside of the OnEvent element for the ContosoServices source which you just
created (WCF source), create a filter for when messages are received by the Service
for the ProcessOrder operation.
<bam:Filter>
<bam:Expression>
<bamwcf:Operation Name="GetServiceContractCallPoint"/>
<bam:Operation Name="Constant">
<bam:Argument>ServiceRequest</bam:Argument>
</bam:Operation>
<bam:Operation Name="Equals" />
<bamwcf:Operation Name="GetOperationName"/>
<bam:Operation Name="Constant">
<bam:Argument>ProcessOrder</bam:Argument>
</bam:Operation>
<bam:Operation Name="Equals" />
<bam:Operation Name="And" />
</bam:Expression>
</bam:Filter>
3. Next specify the CorrelationId as a concatenation between the string WCF_ and
XPath operation on the message for the OrderId element's value. This will match
what the WF OnEvent has set up for the Correlation. After adding this code, Save
the file.
<bam:CorrelationID>
<bam:Expression>
<bam:Operation Name="Constant">
<bam:Argument>WCF_</bam:Argument>
</bam:Operation>
<bamwcf:Operation Name="XPath">
<bamwcf:Argument>//test:OrderId</bamwcf:Argument>
</bamwcf:Operation>
<bam:Operation Name="Concatenate"/>
</bam:Expression>
</bam:CorrelationID>
4. Next, create the Update for the WCF OnEvent - pulling the EventTime from the
GetContextProperty Operation.
You will need to type this command in manually. Copying the command from this
document to a command line will not work because of formatting issues.
Exercise 4: Configure the Interceptor Runtimes
Overview
In this part, you will add the interceptors into their respective runtimes.
BamTrackingService ts = new
BamTrackingService(
"server=.;database=BAMPrimaryImport;trusted_connection=yes",
5000);
_wr.AddService(ts);
BamCodeExtension b = new
BamCodeExtension(
"server=.;database=BAMPrimaryImport;trusted_connection=yes",
5000);
se.Behaviors.Add(b.Create());
Module objective:
Introduce the EDI capabilities provided by Microsoft BizTalk Server 2010, and demonstrate
how they can be used to receive and process EDI messages from trading partners.
Module Overview
Electronic Data Interchange (EDI) is one of the most prevalent means by which business
entities exchange data electronically. EDI usage entails message syntax and standards
(including ANSI X12 and UN/EDIFACT), messaging protocol, and transports.
BizTalk Server 2010 processes EDI messages using a combination of core BizTalk Server
features and EDI-specific BizTalk Server features. This enables BizTalk Server to perform the
processing that is unique to EDI messaging, while leveraging its core messaging functionality.
This module describes how basic receive-side EDI messaging works and how BizTalk Server
implements it. It also describes how a trading partner agreement definition in BizTalk Server
can be configured to enable receive-side EDI processing.
Lesson 1: Receive Side EDI Architecture
Lesson objective:
To understand how the EDI receive components fit in to the BizTalk Server messaging
architecture.
Lesson Overview
Microsoft BizTalk Server 2010 includes receive and send pipelines that are designed
specifically to parse and serialize EDI messages. This lesson describes the receive-side
architecture of EDI solutions on BizTalk Server.
EDI Solution Highlights
Lesson objective:
Understand how BizTalk Server 2010 organizes and applies EDI configuration settings required to
process messages sent from trading partners.
Lesson Overview
One of the core value propositions of BizTalk Server 2010 is to empower BizTalk Server
customers to enable business-to-business (B2B) communication with their business
partners. To fulfill such business needs, enterprises need to model, store, and manage
information about:
Partners and their businesses
Rules of engagement with the partners – These include details such as which
message encoding protocol to use (EDI standards), which transport protocol to use
(AS2), etc.
While BizTalk Server 2010 continues to provide support for EDI and AS2, it rebuilds the
fundamental concepts around how to manage and store information about partners and
their business. EDI standards, AS2 messaging, and the new concepts put together form the
building blocks of a B2B communication or a Trading Partner Management (TPM) solution.
The Role of Party
Party Profiles
A trading partner has at least one business profile, also called a party profile, which
represents is the business face of an organization. Each business division in an organization
that trades with another business division in another organization is represented as a
business profile in a TPM solution. All the properties that define the B2B messaging
parameters specific to the business division, business unit, or a business system are captured
in its business profile.
Managing Parties
Parties represent all of the organizations involved in a business trade. For example, if there
are two business organizations involved in a business trade, you must create a trading
partner for each of them.
Each business division identified within an organization requires a profile within the partner
representing the business division. For example, if an organization has “Purchase” and
“Supplies” business divisions, each of these divisions must be represented as a business
profile in BizTalk Server. Also, you must create the business profiles not just for the partner
representing your organization but also the partner with which you trade.
Each business profile defines the B2B protocol settings that include the message encoding
setting and the message protocol settings. These settings define how the B2B messages are
encoded and transported between two business profiles.
Trading Partner Agreements (TPA) between the business profiles define the encoding
and/or messaging protocols the two business profiles agree to use while exchanging
messages.
Agreements
Example
For example, there could be an agreement between the “Shipping” and “Invoice” profiles of
Fabrikam and Contoso respectively to use the X12 encoding for business messages (encoding
agreement) and AS2 transport for exchanging messages (transport agreement). There can be
many such agreements between various business profiles. For example, there can be an
agreement between the “Payments” and “Invoice” profiles to use the EDIFACT message
encoding standard. All such agreements for all the profiles for a pair of trading partners
constitute a Partnership between the two trading partners.
EDI Fallback Settings
Agreement Resolution
The EDI receive pipeline performs a trading partner agreement resolution by performing a
series of steps to determine whether there is a match between header fields in the message
and properties in the agreement definition. Once BizTalk Server has determined the
agreement, it determines the document schema that applies to the interchange (see below).
It uses the properties associated with the matching agreement and the relevant schema to
validate and process the received message.
To perform agreement resolution, BizTalk Server proceeds as follows:
1. Resolve the agreement by matching the sender qualifier and identifier, and the
receiver qualifier and identifier, in the interchange header with those in the
properties of an agreement.
These four receive-side and send-side properties uniquely identify the trading
partner agreement. Using the four properties gives you more flexibility in receive-
side processing. For example, this method of agreement resolution may enable you
to send acknowledgments to multiple parties without creating multiple send ports.
2. If step 1 does not succeed, resolve the agreement by matching just the sender
qualifier and identifier in the interchange header with those in the properties of an
agreement. Also, because the first step did not succeed, it is safe to assume that
BizTalk Server will be receiving the message.
For X12, these fields are ISA05 and ISA06; for EDIFACT, these fields are UNB2.1 and
UNB2.2.
3. If step 2 does not succeed, use the Fallback Agreement properties.
EDI/X12 Configuration
Profile Settings
By defining the protocol settings, the business profiles declare the message format and the
transport protocol to be used for sending B2B messages between trading partners.
Example
Drawing on an earlier example, Fabrikam’s “Shipping” business profile can send and receive
messages with X12 encoding format sent over AS2 transport protocol. Similarly, Contoso’s
“Invoice” shipping profile can send and receive messages of both X12 and EDIFACT encoding
format over the AS2 transport protocol.
In this case, the “Shipping” business profile can only send and receive X12 messages. So, any
business profile communicating with “Shipping” business profile will have to adhere to the
properties setting for the “Shipping” business profile. However, in future, if the “Shipping”
business profile starts accepting messages with EDIFACT encoding, it only needs to set the
relevant properties to include EDIFACT support. The partner organization does not need to
create a new business profile for the same shipping division.
Profile Settings vs. Agreement Settings
Defining the protocol settings as part of a business profile is optional. If you don’t specify the
protocol settings as part of the business profile, you can always specify those in an
agreement. If you do not define the protocol settings as part of the business profile,
however, you will need to enter the values as part of each agreement for that business
profile, thereby defeating the scalability model of the new TPM solution. Hence, Microsoft
recommends that you define the protocol settings for each business profile. You can always
override those settings, if required, while creating a trading partner agreement.
Agreement Settings
Agreements are built upon the protocol settings defined for each business profile. You
implement a trading partner agreement between two business profiles by defining
properties for each business profile that will be exchanging messages. You set properties for
each business profile as an interchange receiver and as an interchange sender. To process an
incoming message or generate an outgoing message, BizTalk Server needs to know the
agreement that it resolves to, and the schema that applies to the message. If BizTalk Server
cannot determine the agreement, it will use the properties defined in the TPM interface for
the fallback trading partner agreement.
Inbound Configuration
Configure an Agreement
1. Right-click the Northwind_Profile, point to New, and then click Agreement.
2. In the Name box, enter Contoso-Northwind PO.
3. In the Protocol list click X12.
4. Within the Second Party section, in the Party list click Contoso.
5. In the Protocol Set list for the Second Party, click X12_Settings_1.
The options in this list are filtered by the protocol and party specified in the
previous two steps.
6. In the left pane, click Contact Information and Additional Properties to provide a
brief overview of additional options for describing the Agreement.
Lesson objective:
Understand how to apply schemas and pipelines to process inbound EDI messages.
Lesson Overview
When BizTalk Server receives an EDI message, it performs trading partner agreement lookup and
schema discovery, validates the message, sends an acknowledgment (if appropriate), and parses the
EDI batch. BizTalk relies on EDI schemas and pipelines to carry out the processing required to receive
an EDI message.
Schema Resolution for EDI Messages
Schema Contents
A document schema starts with the ST transaction set header and ends with the SE
transaction set trailer for an X12-encoded document. It starts with the UNH message header
and ends with the UNT message trailer for an EDIFACT-encoded document. The schema
defines each data element of these headers and trailers.
A document schema then defines each segment within the transaction set/message and the
data elements within those segments. For example, the X12_00401_864.xsd schema defines
the BMG01, BMG02, and BMG03 elements of the BMG segments. The schema specifies the
characteristics of the segment's complex data type, such as the field order, delimiter type,
and namespace. If there are cross-field validation rules for the segment, the schema defines
the rules.
The schema specifies the characteristics of each data element within the segment, such as
the simple data type, minimum occurrences, minimum length, and maximum length.
If there is a loop in the message type, the schema defines the data elements within each
loop, the minimum and maximum occurrences of the loop, and whether the loop is bounded
or unbounded. The schema also defines nesting of a segment, and whether the loop is
explicit or implicit.
EDI Schemas
It is not uncommon for a company to deploy in the same BizTalk Group a different
version of the same schema for two or more different trading partners. In this case, the
two schemas would have the same version and the same document type. To deploy
these two schemas, you would have to have different namespaces for each schema.
Common Scenarios
Some examples of the types of changes that you can make to an EDI in Visual Studio include:
To do this Do this
Validate Instance
This operation validates a single transaction set (without interchange and group headers) or
a complete batched interchange with multiple transaction sets (with interchange and group
headers). To validate an un-batched interchange, you need to remove the interchange and
group headers from the instance.
Generate an Instance
This operation generates either a complete batched interchange or a transaction set without
interchange and group headers. You must specify the separators, identifiers, and other
formatting used to generate the instance.
EDI Pipelines
X12 EDIFACT
Demonstrate how to add an EDI schema to a BizTalk project, and then customize it and deploy it
to the BizTalk runtime.
C:\AllFiles\DemoCode\Module18\EDIReceiving.sln
2. Right-click the EDIReceiving project, and then click Add, and then click Existing Item,
and add the following schema file.
C:\AllFiles\DemoCode\Module18\X12_00401_850.xsd
This schema defines the structure of an EDI 850 purchase order message.
Notice the size of this schema, it is over 3 MB, and it is only one of many EDI
schemas that are included with BizTalk.
The EDI Schema Editor adds new properties to particular nodes throughout the
schema.
4. With the <Schema> node selected, in the Properties window, click the CodeList
Database property.
This is one of the properties added by the EDI Schema Editor extensions. You can
provide an .mdb file that contains data for populating lists of codes.
This presents a more EDI-friendly view of the schema. It is much easier than
using the conventional XSD view and editing values in the Properties window.
6. Scroll to the right, and show the Min Occurs, Max Occurs, Minimum Length,
Maximum Length and Loop fields.
7. Scroll down to find an EDI field that is within a Loop, and then click it.
C:\AllFiles\DemoCode\Module18\SamplePO.txt
Notice the second line. It is a GS segment that identifies the sender as Contoso,
and the receiver as Northwind.
Notice the third line. It is an ST segment that identifies this message as an EDI
850 (purchase order) message.
The EDI disassembler component will parse this file to extract the values of these
fields, and use the values to determine the agreement between Contoso and
Northwind that is associated with this message. It will discover that this
message is associated with a custom XML namespace, so it will load the schema
that we just deployed to process this message.
2. In the BizTalk Administration Console, right click the Applications node, and then
click Refresh.
3. Expand the EDIReceiving application.
4. Right-click Receive Ports, point to New, and then click One-way Receive Port, and
name it EDIContosoReceive.
5. In the left pane, click Receive Locations, and in the right pane click New.
6. Name the receive location EDIFILE, then in the Type list, click FILE, and then click
Configure.
7. In the Receive folder box, enter
C:\AllFiles\DemoCode\Northwind\Ports\EDIReceive, and in the File mask box,
enter *.txt.
8. Click Advanced settings, then check the Rename files while reading check box, and
then in the Polling interval box, enter 5000, then click OK twice.
9. In the Receive Location Properties window, click the Receive pipeline list, and
notice that there are no EDI pipelines shown.
All of the build-in EDI components are deployed to the BizTalk EDI Application, so
we need to add a reference to that application in order to use those components
in our EDIReceiving application.
These are the built-in EDI pipelines that are deployed when the EDI option is
selected during BizTalk Configuration.
Notice that you have the option of starting the application that is referenced by
EDIReceiving. If the EDIReceiving application were using any of the built-in EDI
orchestrations, then the BizTalk EDI Application would need to be started. In this
case, the EDIReceiving application is simply using a pipeline, so the BizTalk EDI
Application does not need to be started.
10. Uncheck the BizTalk EDI Application check box, and then click Start.
This is the EDI message converted to its XML format. Notice the custom XML
namespace.
Notice the ST node indicating that this is an 850 message. Scroll through the
message content to see the purchase order contact information, and the items
that are included in the order.
Notice also, that the EDI party information has been extracted from the
message, and that it is no longer contained in the message body. The party
identifiers are stored in message context properties.
3. Pause the bt10d-demos virtual machine.
Lesson 4: Acknowledgements, Debatching and Reporting
Lesson objective:
Lesson Overview
BizTalk Server 2010 also supports EDI Acknowledgements, De-batching and Status Reporting.
Acknowledgements
Acknowledgments indicate the status of EDI message transmission. After BizTalk Server
receives an EDI interchange, it will return one or more acknowledgments to the sender of an
EDI interchange, depending upon which acknowledgments have been enabled.
De-batching
When BizTalk Server receives a batched EDI interchange, it can either split the interchange
into its transaction sets, processing each one separately, or it can preserve the interchange,
processing all transaction sets as a group.
Reporting
EDI status reporting enables operations personnel to track the status of EDI and AS2
transmissions. If enabled, status reports provide comprehensive status of a document
exchange transaction, including an interchange and any acknowledgments correlated to the
interchange.
Acknowledgements
The EDI receive pipeline will generate an acknowledgment if any of the following conditions
are met:
A data element in the received interchange prompts the acknowledgment. For X12-
encoded messages, the receive pipeline will generate a technical TA1 ACK if the
ISA14 data element is set to 1. For EDIFACT-encoded messages, the receive pipeline
will generate a technical CONTRL ACK if the UNB9 data element is set to 2, and it will
generate a functional CONTRL ACK if the UNB9 data element is set to 1.
An agreement property prompts the acknowledgment. For X12 interchanges, these
properties are the TA1 Expected and 997 Expected properties in the
Acknowledgements page of the bi-directional agreement tabs of the Agreement
Properties dialog box. For EDIFACT interchanges, these properties are the Receipt of
message (CONTRL) expected and Acknowledgement (CONTRL) expected in the
Acknowledgements page of the bi-directional agreement tabs of the Agreement
Properties dialog box. When you enable a type of acknowledgment, you can also
indicate whether to batch that type of acknowledgment.
A global property prompts the acknowledgment when no agreement is determined
for the interchange. These properties are the:
Debatching
When BizTalk Server receives a batched EDI interchange, it can either split the interchange
into its transaction sets, processing each one separately, or it can preserve the interchange,
processing all transaction sets as a group.
You determine batch processing in the Local Host Settings page of the one-way agreement
tabs in the Agreement Properties dialog box for both X12 and EDIFACT agreements. When
you preserve the interchange, you have the choice to suspend either the interchange or the
transaction sets if an error occurs.
EDI Reporting
EDI status reporting enables operations personnel to track the status of EDI and AS2
transmissions. If enabled, status reports provide comprehensive status of a document
exchange transaction, including an interchange and any acknowledgments correlated to the
interchange. These reports provide data on receipt, validation, batching, and
acknowledgment processing of EDI and AS2 messages.
You can use these reports to get the status of pending and unacknowledged interchanges,
complete interchanges, error scenarios, or business scenarios. With these reports, you can
do the following:
Confirm the receipt of interchanges
List outgoing interchanges awaiting acknowledgment
List all rejected interchanges received
List outgoing interchanges that are reported as rejected or partially accepted.
Data included in the status reports is obtained from interchange control segments, such as
ISA, TA1, GS, UNB, and UNG (with the exception of the Functional ACK status).
Status Reporting UI
EDI and AS2 status reports are available from the BizTalk Server Administration Console.
From the Group Hub page of the BizTalk Group node, you have links to EDI interchange and
correlated acknowledgment status, batch status, and AS2 message and correlated MDN
status. Each of these reports provides a range of status parameters that you can include or
exclude from a query expression, enabling you to build the status report that they need.
In addition to seeing the status of an EDI interchange, you can also view the transaction sets
in an interchange. You do so by enabling the storage of message payloads in the EDI tables
of the tracking (BizTalkDTADb) database. You can view the transaction sets by using the view
details command in the status reporting UI.
You can also store inbound or outbound AS2 messages or MDNs in the non-repudiation
database. You can view the transaction sets or AS2 messages by right-clicking the message in
the status report and selecting the appropriate command.
Demonstration: EDI Reporting and Acknowledgments
Notice that the ACK_Port is listed as a send port belonging to the Contoso party.
This will ensure that the BizTalk host instance to picks up the EDI reporting
configuration changes.
This 997 message is formatted as XML, but in the next module, we will use a
send pipeline to convert XML messages to EDI format.
Notice that there are no results reported, even though the Interchange Date
Time is set to one day ago.
Notice in the second line, that the date is set to 20101002. The value of the
Interchange Date Time value is extracted from the EDI message. It does not
necessarily match the date that BizTalk received the message.
6. In the BizTalk Administration Console, in the center pane, in the Interchange Date
Time Value, enter 10/1/2010, and then click Run Query.
Notice that one interchange was found. The report summary includes the Sender
party and the Receiver party, the Direction of the interchange, and the
Interchange Status is Accepted.
Notice that you can see additional information about the interchange.
8. Click Close.
9. Click the Group Hub tab, and under EDI Status Reports, click Interchange
Aggregation Report.
10. Change the Interchange Date Time to 10/1/2010, and then click Run Query.
Notice that the result now reports two interchanges of this type.
13. Close all windows, and shut down the bt10d-demos virtual machine.
Lab: Receiving EDI Messages
Overview
In this lab you will be configuring a BizTalk Application to be able to successfully process
incoming EDI documents. By deploying an EDI Schema and configuring a party, you’ll be able
to use the EDI components to translate EDI messages to XML. After completing this lab, you
should understand how to: deploy EDI Schemas, create Parties, configure Party specific EDI
properties and configure BizTalk Server to process EDI message.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-18 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose
Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click Ask Me Later, then click OK.
C:\AllFiles\LabFiles\Lab18\Contoso.EDI.Artifacts\Contoso.EDI.Artifacts.sln
Name Value
Name EDISend
Transport FILE
Destination Folder C:\AllFiles\LabFiles\Ports\EDISend
(Under Transport – click
the Configure Button)
3. In the BizTalk Administration tree view, right-click the ContosoEDI application, and
then click Start twice.
Exercise 2: Creating the Parties
Overview
In this part, you will create a party to represent the sender of a message that will be received
into BizTalk Server.
Name Value
Mutually Defined (X12) SENDERISA
Duns Plus Suffix 0073268795005
7. In the Profile Properties dialog box, in the menu bar click Add protocol settings,
point to Encoding settings, and then click X12.
8. In the X12_Settings_1 panel, navigate to Inbound Settings, then Interchange
Settings, and then Validation.
9. Ensure that the check box next to Interchange control number is cleared.
These settings allow you to control how the EDI messages are processed
including validation, namespaces to use, etc.
10. Click OK to close the Profile Properties dialog box.
11. Find the Contoso850.txt file in the C:\AllFiles\LabFiles\Lab18 directory for this lab.
Open and examine the EDI message (pay special attention to the ISA line).
Notice that the ISA number is the same as that defined in the party properties,
thus providing BizTalk the information it needs to resolve the party
12. Place a copy of that file in C:\AllFiles\LabFiles\Ports\EDIReceive
13. In the C:\AllFiles\LabFiles\Ports\EDISend directory you should find an XML file.
Open it and examine it – it should be the XML representation of the 850.
Whenever you plan on using the EDI capabilities in BizTalk Server for receiving
EDI messages you’ll need to follow the steps of this activity at a minimum.
Module 19: Sending EDI Messages
(Optional)
Time estimated: 75 minutes
Module objective:
Introduce the EDI capabilities provided by Microsoft BizTalk Server 2010, and demonstrate
how they can be used to receive and process EDI messages from trading partners.
Module Overview
This module describes how basic send-side EDI messaging works and how BizTalk Server
implements it. It also describes how a trading partner agreement definition in BizTalk Server
can be configured to enable send-side EDI processing.
Lesson 1: Introduction to EDI Sending
Lesson objective:
Understand how to apply the EDI capabilities of BizTalk Server 2010 to send messages to trading
partners.
Lesson Overview
Microsoft BizTalk Server 2010 includes receive and send pipelines that are designed
specifically to parse and serialize EDI messages. This lesson describes the send-side
architecture of EDI solutions on BizTalk Server.
Sending EDI Messages
EDI Sending
When BizTalk Server sends an EDI message, it performs a number of operations, including
agreement lookup and schema discovery; it validates the message, sends an
acknowledgment (if appropriate), and serializes the EDI batch.
As with receiving EDI messages, Microsoft BizTalk Server 2010 provides components for
implementing EDI sending solutions, include the following:
The BizTalk EDI Send Pipeline (EdiSend pipeline) converts XML documents into X12
or EDIFACT encoding, serializes EDI-encoded documents, and performs EDI and XSD
validation.
The Trading Partner Management (TPM) user interface enables you to set
processing properties for trading partners engaging in EDI document exchange and
AS2 document transport.
The batching orchestration batches EDI interchanges and sets context properties for
sending of the batched interchange. The routing orchestration handles the instances
in which messages match multiple batches, creating as many copies of the message
as required.
Send Side Architecture
Schema Resolution
The EDI send pipeline determines which schema that applies to the message from the
schema name and schema namespace contained in the intermediate XML file for each
transaction set (either as doc type information or in the root node).
For an interchange that has been preserved, the send pipeline uses the doc type information
in the individual transaction sets of the intermediate XML file for the complete interchange.
It uses the control segment schemas for processing the envelope segments.
Determining the Party
Interchange Properties
When the EDI send pipeline builds an outgoing EDI message from an intermediate XML file,
it applies an envelope containing interchange and group headers to the message based upon
the EDI properties established for the receive-side agreement. If the send pipeline was not
able to determine the receiving agreement from the send port, it will use the fallback
agreement to apply the envelope.
If the EdiOverride.OverrideEdiHeader context property is set to true, the EDI send pipeline
will use values specified in the EdiOverride property collection to construct the envelope. If a
value is not present in the collection, the corresponding EDI value in agreement properties
will be used. If a value does not exist in either the EdiOverride collection or the agreement
properties, the properties in the fallback EDI agreement will be used.
If the intermediate XML file has a reserved tag or the ReuseEnvelope context property, the
message is a preserved batch and the envelope application logic will not apply..
Extended Validation
Message Validation
When the EDI send pipeline processes a message to be sent, it performs a series of
validations on the envelope and message data. Some of these processes are always
performed; some are performed only if you enable them. These validations include the
following:
Schema validation of the transaction-set data elements against the message
schema. This is always performed.
Cross-field validation on transaction set data elements (X12-encoded messages
only). This is performed if it is enabled in the message schema.
EDI validation performed on transaction-set data elements. This is performed if
enabled in agreement properties.
Extended validation performed on transaction-set data elements. This is performed
if enabled in agreement properties.
Validation of the transaction sets within a single group based on the transaction set
– group mapping, according to X12 standards. This must be enabled.
Demonstration: Create and Send an EDI Message
Demonstrate sending an EDIFACT message using fallback settings and then demonstrate sending
the message using settings configured in an agreement.
C:\AllFiles\DemoCode\Module19\Contoso.EDI.EDIFACT\Contoso.EDI.EDIFACT.sln
This schema defines an EDIFACT invoice message. BizTalk needs to map the
internal invoice to an EDIFACT invoice, and then send it out.
This map will be configured in a receive port to map the internal invoice to the
EDIFACT format.
Notice that this receive port has been configured to process messages with the
InternalInvoiceToD96A_INVOIC map.
3. In the left pane, click Receive Locations, and in the right pane, double-click
InternalInvoice_FILE.
This receive location is simply using the XMLReceive pipeline, since the LOB
system that produces the invoice is not passing an EDI message to BizTalk.
3. Click Cancel.
4. Click Send Ports, and then double-click the Contoso_EDIFACT_FILE send port.
Notice that the Send pipeline is EdiSend. This Send Port will write messages out
to the C:\AllFiles\DemoCode\Northwind\Ports\EdifactSend folder.
6. Click Cancel.
7. In the BizTalk Server Administration tree view, click Parties.
Notice that there are no agreements defined. Consequently, BizTalk will use the
fallback settings to process all messages.
Notice that some of the Identifier settings are pre-configured with information
taken from the party profiles.
Notice that the EDIFACT message is now populated with sender and receiver
information taken from the agreement between Northwind and Contoso.
Lesson objective:
Lesson Overview
EDI mechanisms usually specify data aggregation schemes (batching). BizTalk Server 2010
provides an orchestration that batches EDI interchanges and sets context properties for
routing the batched interchange, once it is released.
Introduction to EDI Batching
EDI Batching
Microsoft BizTalk Server will batch EDI transaction sets if batching has been enabled for the
agreement associated with the business partner that will be receiving it. The EDI properties
for an agreement enable you to do the following:
Define multiple outgoing batches
Define the interchange
Define the groups in the interchange
Set the batch release criteria
Set the batch activation criteria.
EDI Batch Orchestration
Batch Configuration
To define the way that BizTalk Server batches transaction sets into an EDI interchange, you
must create one or more batch configurations for an agreement. All interchanges that
BizTalk Server associates with that agreement, and that meet the filter criteria for a batch,
will be batched and released according to the same release criteria for that batch
configuration.
The document standard for the batch is determined by the agreement properties. For
example, if the agreement is for X12 messages, the document standard for the batches will
be X12.
EDI Batching Configuration
Notice that the Name element, a child of the Them element, has been promoted.
This is the property that will hold the Name from the InternalInvoice message.
This property provides an identifier that can be used for a batch subscription.
Since this is an XML document, the Batch Marker component does not need to be
concerned with EDI encoding.
In spite of that, the Batch Marker component will still find the Agreement and
the Batch information that correspond to this message, and it will mark
messages that should be batched.
This is the custom receive pipeline that includes the Batch Marker component.
This filter will determine which messages will be sent to the batching
orchestration.
BizTalk will send a batch of invoice messages once it has collected a batch of
three invoices.
10. Click Apply.
11. At the top of the Invoice Batch tab, click Start.
Notice that the status message below the button changes from “Batch is not
activated” to “A control message is waiting to be processed.”
Notice that the status message changes to “Batching is activated”, and the
Orchestration instance ID displays a value.
This condition will prevent the send port from sending out messages that are still
queued for batching.
This message contains the data from all three messages that were batched.
11. Close all windows, and shut down the bt10d-demos virtual machine.
Lab: Sending EDI Messages
Overview
In this lab you work for Contoso Winery. Your ERP system outputs invoice messages using a
custom XML Schema. You need to turn these custom XML messages into EDI messages to
send to a trading partner. The trading partner is located in Ireland, so the EDI messages
must be EDIFACT. Also the trading partner requests that the invoices be sent in batches of
three (3). In this lab, you will be deploying the artifacts necessary to turn the XML messages
into EDI, and you will configure EDI batching for the trading partner. After completing this
lab, you should understand how to: configure BizTalk Server EDI to send EDI messages, and
configure BizTalk Server EDI to batch outgoing EDI message.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-19 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose
Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click Ask Me Later, then click OK.
File Purpose
EFACT_D96A_INVOIC.xsd The BizTalk Server Schema for EDIFACT
D96A INVOIC. Necessary for converting EDI
messages to XML or XML messages of this
type to EDI.
InternalEDIReceive.btp A custom Pipeline which will allow
processing of incoming XML messages but
also have the EDI component necessary to
support batching.
InternalInvoiceToD96A_INVOIC.btm The map (XSLT) which will transform the
custom invoice schema into the INVOIC XML
message.
InternalInvoice.xsd The internal XML schema for Invoices from
the ERP system.
PropertySchema.xsd A BizTalk property schema definition for the
name of the party sent from the ERP
system. The value is promoted from
InternalInvoice.xsd.
Property Value
Name EDIFileLocation
Transport FILE
Receive Folder C:\AllFiles\LabFiles\Ports\EDIReceive\
(Under Transport – click the
Configure Button)
File Mask (Under Transport – click *.xml
the Configure Button)
Receive Pipeline (Under General) InternalEDIReceive
Scenario
Adventure Works is a retail sporting goods chain with 10 stores in the Pacific Northwest. The
company headquarters receives daily batches of orders from each retail store. These
batches are processed by a Microsoft BizTalk Server 2010 application.
In this lab, you will examine and test the BizTalk Server application that you will be building
throughout the remainder of this course. This application receives and processes sales
orders. If the application receives an order for a non-cash transaction, the loan application is
automatically approved or denied, based on predetermined business rules. If the credit
application is denied, the loan application is sent to a Microsoft Windows SharePoint
Services site for manual review. If the loan application is denied during the manual review
process, the order is canceled, and the store is notified. If the loan application is approved,
the total loan amount is evaluated to determine who the lender will be. Loans for less than
$1000 are carried by the Adventure Works finance department. Larger loans are managed
by one of two banks, based the customer’s credit rating. For all completed cash or credit
transactions, the inventory system is updated, and a sales order acknowledgement is
generated.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-01 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose
Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click Ask Me Later, and then click OK.
Scenario
Each type of message processed by a BizTalk server application requires an XML schema that
defines the structure of the message. In this lab, you will create a BizTalk Server project that
will contain your schemas. Adventure Works has defined an internal sales order message
format for which you will create a schema. Next you will use the Flat File Schema Wizard to
create a schema that represents the format of the sales orders submitted by the Adventure
Works stores. Finally, you will generate a schema from a sample loan application message.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-01 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose
Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click Ask Me Later, and then click OK.
Exercise 1: Creating a New BizTalk Project
Overview
A BizTalk Server project contains BizTalk Server artifacts. In this exercise, you will create a
new Microsoft Visual Studio® 2010 solution and a new project that uses the BizTalk Server
Project template. This project will contain the schemas that you will create in the following
exercises.
Create a Blank Solution
Procedure List
1. On the Start menu, click All Programs, click Microsoft Visual Studio 2010, and then click
Microsoft Visual Studio 2010.
2. On the File menu, point to New, and then click Project.
3. In the New Project dialog box, in the Installed Templates pane, click BizTalk Projects,
click the Empty BizTalk Server Project icon, and then create a new project using the
information in the following table.
Property Value
Name Messaging
Location C:\AllFiles\LabFiles\Lab2
Create directory for <checked>
solution
Solution Name AdvWorks
6. Click Next.
6. Click Next.
6. Click Next.
7. Click Finish.
8. On the File menu, click Save All.
Validate the Sample Instance Message
Procedure List
1. In Solution Explorer, click SalesOrder_FF.xsd, then select the Input Instance Filename
field in the Properties window. Notice that the file is the same as the sample instance
used to generate the schema with the Flat File Schema Wizard.
2. Right-click SalesOrder_FF.xsd, and then click Validate Instance.
The results of the instance validation are displayed in the output window. This step
validates the schema against sample a flat file.
3. In the Output window, hold CTRL and click the link to the right of Validation generated
XML output to view the XML representation of the flat file instance.
Exercise 4: Generating a Schema from an XML Message Instance
Overview
BizTalk can generate a schema based on an existing XML message instance. In this exercise, you
will generate a schema based on a sample loan application message.
Scenario
Maps are typically used to convert messages from one format to another. In this lab, you will
create a map that is used to transform data from the flat file format generated by the Adventure
Works stores to the internal sales order format used by the sales order application. You will
configure the map with several functoids to manipulate and modify the message data. You will
also configure the map to retrieve information from a Microsoft® SQL Server™ database and
insert it into the destination message.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-01 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click Ask Me Later, and then click OK.
Exercise 1: Creating a Map
Overview
A BizTalk map is used to convert message data between XML formats. In this exercise, you will
use the BizTalk Mapper to create a map that transforms data from the SalesOrder_FF schema to
the SalesOrder schema format. This map will contain links that associate the data fields between
these two schemas.
Multiply Two Fields from the Source Schema to a Single Field in the
Destination Schema
Procedure List
1. From the Mathematical Functoids section of the Toolbox, drag the Multiplication
functoid on to the Map grid.
2. From the Cumulative Functoids section of the Toolbox, drag the Cumulative Sum
functoid on to the Map grid.
Because functoids must link left to right, you must drag the Cumulative Sum functoid
to the right of the Multiplication functoid.
3. In the Source Schema, click the Quantity field, and then drag a link to the Multiplication
functoid in the Map grid.
4. In the Source Schema, click the PriceEach field, and then drag a link to the
Multiplication functoid in the Map grid.
5. In the Map grid, click the Multiplication functoid, and then drag a link to the
ExtendedPrice node in the Destination Schema.
6. In the Map grid, click the Multiplication functoid, and then drag a link to the
Cumulative Sum functoid.
7. In the Map grid, click the Cumulative Sum functoid, and then drag a link to the Order
Total node in the Destination Schema.
The first parameter is the SQL connection string to access the AdvWorks database.
The Second parameter specifies the database table you’re looking up. The third
parameter specifies the column in the table you’re looking up.
3. Click OK.
4. Double-click each Value Extractor functoid, notice that Input[0] is the link from the
Database Lookup functoid, then set the appropriate value for Input[1], as shown in the
table below:
Functoid Value for Input[0]
First Value Extractor Functoid ADDRESS
Second Value Extractor Functoid CITY
Third Value Extractor Functoid REGION
Fourth Value Extractor Functoid ZIP
Each one of these parameters specifies the column from the database from which
the data will be mapped. These functoids will look up the CUSTID field in the source
schema in the AdvWorks database. If the CUSTID exists, the associated values in the
ADDRESS, CITY, REGION, and ZIP columns will be mapped to the Street, City, State,
and PostalCode fields in the destination schema.
Scenario
All assemblies used by BizTalk Server applications (including non-BizTalk .NET assemblies) must
be in the Global Assembly Cache (GAC) of the computer(s) running BizTalk Server. Additionally,
all BizTalk assemblies must be registered in the BizTalk configuration database. In this lab, you
will prepare a BizTalk assembly to be deployed by assigning a strong name key an application’s
projects. You will then deploy the assembly, and use the BizTalk Server Administration Console
to import a binding file to complete the configuration. You will then export the new, configured
application to an MSI file. You will move all of the application’s resources to a new application,
export it with BTSTask.exe, and then delete the application from the BizTalk Server
Configuration database.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-04 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click Ask Me Later, and then click OK.
Delete an Application
Procedure List
1. In the command prompt window, type the following command, and then press ENTER.
2. In the command prompt window, type BTSTask ListApps, and then press ENTER.
Notice that the ExtremeAdventureWorks application has been removed.
3. Close all open windows.
Lab 5 : Routing BizTalk Messages
Scenario
The BizTalk messaging engine allows you to route messages based on message context. In this
lab, you will add existing BizTalk artifacts the messaging project. Next, you will promote
properties in an XML schema to be used to selectively route messages. You will then configure
BizTalk messaging ports to receive and route sales order messages, based on message context.
Finally, you will test the port configuration by submitting test messages.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-05 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click Ask Me Later, and then click OK.
Promote Properties
Procedure List
1. In Solution Explorer, double-click SalesOrder.xsd.
2. In the Schema Editor, right-click <Schema>, and then click Expand Schema Node.
3. Under the Detail node, right-click OrderType, point to Promote, and then click Quick
Promotion.
4. In the Microsoft Visual Studio message box, read the message, and then click OK. If a
message box appears asking if you want to reload PropertySchema.xsd, click Yes.
Notice in Solution Explorer that the PropertySchema.xsd artifact has been created.
This is the default schema created to hold promoted properties. Also notice that the
OrderType node now has an icon to indicate that the node has been promoted.
5. Ensure that PropertySchema.xsd is open in the schema editor. If it is not, double-click
PropertySchema.xsd in Solution Explorer.
Notice that the OrderType node is listed in the PropertySchema schema. The
Property1 node is created by default and can be safely deleted.
6. Right-click Property1, and then click Delete.
7. In the BizTalk Editor dialog box, click Yes to confirm the deletion.
8. In Solution Explorer, right-click the Messaging project, and then click Deploy.
Verify in the status bar that the deployment succeeded.
Exercise 3: Creating a Receive Port and a Receive Location
Overview
You can use the BizTalk Server Administration Console to manage the BizTalk configuration
database. BizTalk Server uses receive ports and receive locations to process inbound messages.
In this exercise, you will create a receive port and receive location by using BizTalk Explorer.
Procedure List
1. Under BizTalk Application 1, right-click Send Ports, point to New, and then click Static
One-Way Send Port.
2. In the Send Port Properties dialog box, in the Name box type CashOrdersFILE.
3. In the Type list, click FILE, and then click Configure.
4. In the FILE Transport Properties dialog box, click Browse, browse to
C:\AllFiles\LabFiles\Lab5, create a new folder named CashOrders, and then click OK.
5. In the File name box, type Cash%MessageID%.xml, and then click OK.
6. In the Send pipeline list, click PassThruTransmit.
7. In the left pane of the Send Port Properties dialog box, click Filters.
8. In the right pane, click the top box in the Property column, and choose
BTS.ReceivePortName from the drop-down list.
9. In the Value box, type SalesOrder.
10. On the second line, click AdvWorks.Messaging.PropertySchema.OrderType in the
Property list.
11. In the Value box, type CASH, and then click OK.
Exercise 6: Creating a Send Port for Credit Orders
Overview
You want all credit orders to be sent to a different port than the cash orders. In this exercise,
you will create a send port and configure its filter to subscribe to all messages that contain the
word CRED in the OrderType promoted property field, and are received by the SalesOrder port.
Scenario
Pipelines allow you to customize the processing of messages within send or receive ports. In this
lab, you will create and test a custom send pipeline that encrypts communications between
Adventure Works and Woodgrove Bank. Next, you will configure a receive pipeline that splits a
batch of messages (an interchange) to be processed as individual messages. Finally, you will
enable recoverable interchange processing to address issues that arise from malformed
messages within the batch.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-06 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click Ask Me Later, then click OK.
Scenario
BizTalk Server uses adapters to communicate with external systems and processes. Adventure
Works needs to integrate with several systems. Sales orders can now be sent from stores as
HTTP messages in addition to the file receive process already in place. Loan applications that
require approval are sent to a Microsoft Windows SharePoint Services form library for manual
review. All completed sales orders will be sent to an FTP site. In this lab, you will configure the
HTTP adapter, the FTP adapter, and the Windows SharePoint Services adapter.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-07 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click Ask Me Later, then click OK
This is the form library that you created in the first exercise of this lab. All credit
orders received will be sent to this form library for manual approval of the loan.
5. In the Send pipeline list, click XMLTransmit, and then click the ellipsis (…) button.
6. In the Configure Pipeline dialog box, in the ProcessingInstructionsOptions box,
type 1.
Setting the ProcessingInstructionsOptions to ”1” will remove all existing InfoPath
processing instructions and then insert the processing instructions you specify in the
XmlAsmProcessingInstructions box.
7. In Windows Explorer, navigate to and open
C:\AllFiles\LabFiles\Lab7\ProcessingInstructions.txt.
8. Copy all of the text that appears in ProcessingInstructions.txt, and then close Notepad.
These are the processing instructions for the form that you published in the first
exercise.
9. In the Configure Pipeline dialog box, in the XmlAsmProcessingInstructions box, paste
the text you just copied, and then click OK.
This message will no longer open using the processing instructions for the SalesOrder
form. When opened, it will use the InfoPath form that you published to the
SharePoint library.
10. Click OK to close the Send Port Properties dialog box.
11. Right click the CreditOrdersSharePoint send port, and click Start.
The SharePoint adapter will process all messages displayed by the view specified.
This receive location will process messages displayed by the Evaluated view.
7. Click OK three times.
8. In the BizTalk Server Administration Console, click Send Ports, right-click
CashOrdersFTP, and then click Properties.
9. In the Send Port Properties dialog box, click Filters.
10. On the second line of the existing filter expressions, in the Group by list, click Or.
11. Add two filter expressions and configure according to the information in the following
table, and then click OK.
Property Operator Value Group by
BTS.ReceivePortName == LoanApplications And
Messaging.PropertySchema.LoanStatus == Approved And
12. In the BizTalk Server Administration Console, click Receive Locations, right-click
LoanApplicationsSharePoint, and then click Enable.
13. In Internet Explorer, browse to http://BIZTALKDEMO/LoanApplications.
14. Click CreditOrder{GUID}, and then, in the File Download dialog box, click Open.
15. In the CreditOrder{GUID}.xml window, in the Loan Status list, click Approved.
16. Close CreditOrder{GUID}.xml, and then click Yes to save your changes.
17. In Internet Explorer, browse to ftp://localhost/CashOrders.
It may take up to a minute for the message to be processed.
18. Click the new Cash{GUID}.
19. Examine and then close the message
Lab 8 : Creating a BizTalk Orchestration
Scenario
BizTalk messaging can be used for basic message transformation and routing. Processing that
requires decisions or multiple actions generally requires the use of orchestrations. The IT
manager of Adventure Works has asked you to create orchestrations for processing both cash
and credit sales orders. In this lab, you will create the orchestration for processing cash sales
orders. In subsequent labs, you will create the orchestration responsible for processing credit
sales orders.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-08 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click Ask Me Later, then click OK.
Create an Orchestration
Procedure List
1. In Solution Explorer, right-click Processes, point to Add, and then click New Item.
2. In the Add New Item dialog box, click Orchestration Files, click BizTalk Orchestration, in
the Name box, type ProcessOrder_Cash.odx, and then click Add.
The ProcessOrder_Cash orchestration opens automatically.
Create Messages
Procedure List
1. In Orchestration View, right-click Messages, and then click New Message.
2. In the Message_1 Properties window, in the Identifier box, type msgSalesOrder.
3. In the Message Type list, under Schemas, click <Select from referenced assembly>.
4. In the Select Artifact Type dialog box, in the left pane, click AdvWorks.Messaging, in the
right pane, click SalesOrder, and then click OK.
This is the message variable for the incoming sales order.
5. In Orchestration View, right-click Messages, and then click New Message.
6. In the Message_1 Properties window, in the Identifier box, type
msgSalesOrder_Complete.
7. In the Message Type list, under Schemas, click <Select from referenced assembly>.
8. In the Select Artifact Type dialog box, click in the left pane, AdvWorks.Messaging, in the
right pane, click SalesOrder, and then click OK.
This is the message variable for the completed processing acknowledgement
message.
9. In Orchestration View, right-click Messages, and then click New Message.
10. In the Message_1 Properties window, in the Identifier box, type msgRestock.
11. In the Message Type list, under Schemas, click <Select from referenced assembly>.
12. In the Select Artifact Type dialog box, in the left pane, click AdvWorks.Messaging, in the
right pane, click Restock, and then click OK.
This is the message variable for the restock message sent to the inventory system.
19. Right-click the arrow immediately below the Construct msgRestock shape, point to
Insert Shape, and then click Send.
20. Configure the Send_1 shape with the properties shown in the following table.
Property Setting
Name Restock
Message msgRestock
21. Right-click the arrow immediately below the Construct msgSalesOrder_Complete
shape, point to Insert Shape, and then click Send.
22. Configure Send_1 with the properties shown in the following table.
Property Setting
Name Complete Sales Order
Message msgSalesOrder_Complete
Exercise 3: Create Orchestration Ports
Overview
Orchestration ports (logical ports) provide the connections between an orchestration’s send and
receive shapes and the BizTalk MessageBox database. In this exercise, you will create a receive
port and two send ports. These ports will be connected to send and receive shapes in the
orchestration.
Scenario
BizTalk orchestrations can be used to automate business decisions and other processes. In this
lab, you will create a new BizTalk orchestration that will process credit sales orders.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-09 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click Ask Me Later, then click OK.
You will make the necessary changes to the Else branch in a later lab.
Exercise 4: Create Orchestration Ports
Overview
The ports in this orchestration ports are configured as late bound (Specify Later), so they must
be bound to a physical port after the assembly is deployed. Using late binding separates the
design of an orchestration and its implementation. In this exercise, you will add a new late
bound orchestration port and reconfigure the existing ports to use late binding.
In the previous lab, this orchestration was configured with “early binding,” meaning
that the physical ports were automatically created and bound to the logical ports
when the assembly was deployed. In this lab, you are using late binding, so the
logical ports must be bound to the physical ports manually.
10. In the Configure Application dialog box, click ProcessOrder_Credit, configure the
settings using the information in the following table, and then click OK.
Property Setting
Host BizTalkServerApplication
SalesOrder SalesOrder
Restock RestockFILE
SO_Complete CompleteFILE
BankNotification BankNotifyFILE
Both orchestrations use the SalesOrder receive port. The filter expressions you
configured on the receive shapes in each orchestration will prevent an orchestration
from getting any message it shouldn’t.
11. In the BizTalk Server Administration Console, right-click AdventureWorks, click Start,
and then in the Start ‘AdventureWorks’ Application dialog box, click Start.
12. In Windows Explorer, navigate to C:\AllFiles\LabFiles\Lab9, and then copy all four XML
files to the SalesOrderIN folder.
It may take a moment for the messages to be processed and moved from the
SalesOrderIN folder.
13. Open the OUT folder, and then examine each of the messages.
Notice that the Cash and Restock orders have been processed and that the Credit
order over $1000 has a BankNotify message.
14. Close all open windows.
Lab 10 : Creating Transactional Business Processes
Scenario
Exception handling can be added to scope shapes within orchestrations to specify actions to be
executed in the event that an exception occurs. BizTalk orchestrations can include both long-
running and atomic transactions. Compensation, a feature of transactions, allows for the
reversal of previously completed processes. In this lab, you will configure exception handling
and compensation for the ProcessOrder_Credit orchestration.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-10 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click Ask Me Later, then click OK.
6. In Orchestration Designer, drag the Determine Lender Decide shape to a location inside
the Send Loan to Lender scope shape.
3. Drag the Construct msgSOComplete and Complete Sales Order shapes to locations
inside the Completed Sales Order scope shape.
Configure the Orchestration and the Send Loan to Lender Scope Shape as a
Long-Running Transaction
Procedure List
1. Click any white space on the ProcessOrder_Credit orchestration, in the Properties
window, in the Transaction Type list, click Long Running, and then in the Transaction
Identifier box, type LR_ProcessOrder_Cred.
2. In the ProcessOrder_Credit orchestration, click the Send Loan to Lender scope shape,
and then configure its properties as shown in the following table.
Property Value
Transaction Type Long Running
Transaction Identifier LR_LoanToLender
3. Drag the Construct msgRestock and Restock send shapes to a location inside the
Restock Inventory scope shape.
2. Right-click the Completed Sales Orders scope shape, and then click New Compensation
Block.
3. In the Compensation_1 Properties window, change the Name to Complete Sales Order
Comp.
4. In the Complete Sales Orders Comp compensation block, right-click Drop a shape from
the toolbox here, point to Insert Shape, and then click Send.
5. In the Send_1 Properties window, change the Name to Rescind Complete Sales Order,
and then in the Message list, click msgSalesOrderComplete.
6. Connect the Rescind Complete Sales Order send shape to the CompletedSalesOrder
operation on the Rescind port.
Exercise 3: Calling Compensation
Overview
Transactions can be nested to provide a parent/child hierarchy. Parent transactions can call the
compensation for each child transaction from the parent’s exception handler, or as part of the
parent’s compensation. In this exercise, you will first add a long-running transaction to the
orchestration. Next, you will move all the existing shapes, including the transactional scope
shapes, into the parent transaction. Finally, you will add an exception handler to the parent
transaction that will call the compensation of some of the child transactions.
3. Double-click the icon at the top of the Send Loan to Lender scope shape to collapse it.
4. Repeat step 3 to collapse the Restock Inventory scope shape and the Completed Sales
Order scope shape.
5. Drag the Completed Sales Order scope shape inside the Credit Process scope shape.
6. Drag the Restock Inventory inside the Credit Process scope shape, and above the
Completed Sales Order scope shape.
7. Drag the Send Loan to Lender scope shape inside the Credit Process scope shape, and
above the Restock Inventory scope shape.
Scenario
The Microsoft Business Rule Engine (BRE) enables you to apply declarative rules based on
messages from BizTalk orchestrations. Using the BRE enables you to separate the
implementation of the business process (orchestration) from business decisions that are likely to
change over time. Vocabularies are a collection of easy-to-read definitions for the facts used by
the BRE. When vocabularies are used to create rules, the rules can easily be updated and
maintained by business analysts who have little or no understanding of the BizTalk
implementation. In this lab, you will create a vocabulary with several definitions. You will then
create a rule policy by using the vocabulary you created. Finally, you will integrate the Business
Rule Engine policy into an orchestration.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-11 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click Ask Me Later, then click OK.
Create Messages
Procedure List
1. In Orchestration View, right-click Messages, and then click New Message.
2. In the Message_1 Properties window, in the Identifier box, type msgInterimLoan, in the
Message Type list, expand Schemas, and then click
AdvWorks.LoanApproval.FinalLoanDocument.
3. In Orchestration View, right-click Messages, and then click New Message.
4. In the Message_1 Properties window, in the Identifier box, type msgLoanApp, in the
Message Type list, expand Schemas, and then click
AdvWorks.LoanApproval.LoanApplication.
msgLoanApp.LoanConditions.LoanStatus==“Approved”
4. In the message assignment shape Properties window, in the Expression box, click the
click the ellipsis (…) button, type the following expression (four separate lines) in the
BizTalk Expression Editor window, and then click OK.
parFinalLoan.Loan.Amount = msgLoanApp.LoanConditions.LoanAmount;
parFinalLoan.Loan.LoanToIncomeRatio =
msgLoanApp.LoanConditions.LoanToIncome;
parFinalLoan.Loan.Status = msgLoanApp.LoanConditions.LoanStatus;
parFinalLoan.Loan.Term = msgLoanApp.LoanConditions.Term;
msgInterimLoan.Loan.Amount=msgLoanApp.LoanConditions.LoanAmount;
msgInterimLoan.Loan.LoanToIncomeRatio =
msgLoanApp.LoanConditions.LoanToIncome;
msgInterimLoan.Loan.Status=msgLoanApp.LoanConditions.LoanStatus;
msgInterimLoan.Loan.Term=msgLoanApp.LoanConditions.Term;
5. Right-click below the construct message shape in the Else branch, point to Insert Shape,
and then click Send.
6. Right-click below the send shape in the Else branch, point to Insert Shape, and then click
Receive.
7. Configure the Send and Receive shapes as shown in the following table.
Send Shape
Property Value
Initializing Correlation ManualApprovalCorrSet
Set
Message msgInterimLoan
Name SharePoint Processing
Receive Shape
Property Value
Following Correlation Set ManualApprovalCorrSet
Message parFinalLoan
Name SharePoint Processing
3. Right-click the right Port Surface, and then click New Configured Port.
4. Configure the port as shown in the following table.
Property Value
Name SharePointResp
Port Type Name (existing Port Type) SharePointType
Direction Receive
Binding Specify later
5. Connect the Send shape to the SharePointReq port, and then connect the Receive
shape to the SharePointResp port.
6. In Solution Explorer, right-click the AdvWorks solution, and then click Build Solution.
msgFinalLoan.Loan.Status=="Approved"
5. Drag a Send shape from the Toolbox to the Else branch of the Is Loan Approved? decide
shape.
6. In the Properties window, in the Name box, type Loan Denial, and then in the Message
list, click msgSalesOrder.
7. Drag the Loan approved so several things need to be done group shape to the
Approved branch of the Is Loan Approved? decide shape.
3. Connect the Loan Denial send shape to the LoanDenial send port.
4. In Windows Explorer, navigate to C:\AllFiles\LabFiles\Lab11, and then open
ProcessOrder_Credit.png.
Your ProcessOrder_Credit orchestration should look similar to the one shown in this
picture.
5. Close ProcessOrder_Credit.png.
Scenario
Business Activity Monitoring (BAM) is a tool designed to be used by business analysts for
gathering business data from both archived and running business processes. In this lab, you will
see how to use several new tools, including the Microsoft Excel Business Activity Monitoring
Add-In and the BAM Portal, for analyzing business data that was processed by BizTalk Server.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-12 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click Ask Me Later, then click OK.
Define Milestones
Procedure List
1. On the Start menu, click All Programs, click Microsoft Office, and then click Microsoft
Excel 2010. In the Microsoft Office Activation Wizard window, click Cancel.
2. On the File menu, click Options
3. In the Excel Options window, in the left pane, click Add-Ins.
4. In the right pane, at the bottom, in the Manage list, click Excel Add-ins, then click Go.
5. In the Add-Ins dialog box, click Browse, and navigate to C:\Program Files
(x86)\Microsoft BizTalk Server 2010\ExcelDir, then click Bam.xla and click OK.
6. In the Add-Ins dialog box, in the Add-Ins available list, ensure that the Business Activity
Monitoring box is checked, and then click OK.
7. In the Excel menu ribbon, on the Add-Ins tab, click BAM, and then click BAM Activity.
8. In the Business Activity Monitoring Activity Definition dialog box, click New Activity.
9. In the Activity name box, enter OrderMgmt.
10. Click New Item, and in the New Activity Item dialog box, in the Item name box, enter
received, in the Item type list, click Business Milestones then click OK.
This milestone allows a timestamp value to be gathered from the message after the
message is received by the business process.
11. Repeat step 9, substituting in the following values to create the remaining Activity Items
needed to monitor the OrderMgmt business process.
Item Name Item type
denied Business Milestones
approved Business Milestones
acknowledged Business Milestones
City Business Data - Text
State Business Data - Text
Product Business Data - Text
Amount Business Data - Decimal
Later in this lab, you will specify the points in the business process at which each of
these data values will be collected by the BAM infrastructure.
12. Click OK twice.
Exercise 2: Define an Observation Model
The BAM definition that you initialized in the preceding exercise specifies the information to be
collected by BAM. In this exercise, you will create a BAM view. You will design this view by
adding progress dimensions and measures that categorize the data gathered by the BAM
activity. The data in the view is displayed as a Microsoft Office Excel PivotTable.
Select the Target BAM Activity for Which to Create a Tracking Profile
Procedure List
1. On the Start menu, click All Programs, click Microsoft BizTalk Server 2010, and then
click Tracking Profile Editor.
2. In the left pane, click Click here to import a BAM Activity Definition.
3. In the Import BAM Activity Definition dialog box, in the bottom pane, click OrderMgmt,
verify that Retrieve the current tracking settings for this activity definition check box is
cleared, and then click OK.
Create a Continuation
A BAM continuation is analogous to a correlation set in an orchestration. Continuations are sets
of unique values that allow the BAM infrastructure to identify all messages that belong to the
same instance of a BAM activity. In this lab, you must define a continuation to indicate that the
messages accepted by the receive port belong to the same activity as those that are processed
by the orchestration.
Procedure List
1. In the left pane of the Tracking Profile Editor, right-click OrderMgmt, and then click
New Continuation.
2. Set the name of the new continuation to OrderMgmtContinuation.
3. In the Tracking Profile Editor, in the top-right corner, click Select Event Source, and then
click Select Messaging Property.
4. In the right pane, expand Schema and MessageProperties.
5. From the right pane, drag the InterchangeID node to the new OrderMgmtContinuation
node in the left pane.
6. In the left pane, right-click InterchangeID, and then click Set Port Mappings.
7. In the Select Ports dialog box, click OrderMgmt_RcvPO, click the > button to map the
port, and then click OK.
This step instructs the BAM infrastructure to initialize the continuation with the
value of the message’s interchange ID. The interchange ID is a GUID that identifies
this message and any of its descendants.
8. In the left pane of the Tracking Profile Editor, right-click OrderMgmt, and then click New
ContinuationID.
9. Set the name of the new continuation ID to OrderMgmtContinuation.
The name of the continuation ID must match the name of the original continuation.
10. Click Select Event Source, and then click Select Orchestration Schedule.
11. In the Select Event Source Parent Assembly dialog box, under Assembly name, click
TheImplementationOfOrderMgmt, and then click Next.
12. In the Select Orchestration dialog box, under Orchestration Name, click
OrderMgmt.OrderMgmtProcess, and then click OK.
13. Right-click the ReceivePO shape, and then click Message Property Schema.
14. In the right pane, expand MessageProperties, and then drag the InterchangeID node to
the new continuation ID node that you just created.
The ReceivePO shape will report the message’s interchange ID to the BAM
infrastructure, allowing BAM to associate this message with the correct BAM
activity.
Launch the BAM Portal and View Order Progress Data Aggregation
Procedure List
1. In Internet Explorer, navigate to http://localhost:8080/BAM.
2. In the My Views navigation pane, expand the Sales Manager view.
3. Click the plus sign (+) to expand the function named Aggregations, and then click Order
Progress.
4. In the Microsoft Office 2003 Web Components message box, click OK.
If you do not see any data in the Pivot Table View, click the button with the red
exclamation point (!) icon in the PivotTable tool bar to refresh the view. Because of
SQL Server / OLAP caching, it might take up to one minute for the data to appear.
5. Click the plus signs (+) to expand cells in the PivotTable until Evaluation is shown with a
corresponding Total amount.
Overview
This lab will introduce you to the integration between the BizTalk Server messaging components
and Web services. You will use a built-in WCF adapter, which provides integration with Web
services using Windows Communication Foundation.
First, you will generate a Web service from an existing schema definition using the BizTalk WCF
Service Publishing Wizard. Then you will learn how to properly configure a receive port and the
virtual directory containing the generated service endpoint.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-13 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click “Ask Me Later”, then click “OK”
3. Verify that a dialog box appears confirming that the order was submitted successfully.
If you get an error, try running the application in debug mode with a breakpoint on
the catch block to get more detail on the error. Make sure your receive location is
enabled and the host instance are running.
4. In Windows Explorer, navigate to C:\AllFiles\LabFiles\Ports\BillingDept and verify that
a new message has been created.
Lab 14 : Calling a Web Service from an Orchestration
Overview
The purpose of this lab is to introduce you to the integration between the BizTalk Server
messaging components and Web services. You’ll use a built-in WCF adapter, which provides
integration with Web services using Windows Communication Foundation
First, you will add a service reference to generate the necessary artifacts for consuming a web
service using the WCF adapters. Next you’ll walk through the process of consuming a web
service from within an orchestration.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-14 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click “Ask Me Later”, then click “OK”
Overview
In this lab you will update the Northwind ordering process to make the orchestration messaging
more dynamic and add support for correlation. You will use role links to provide partner specific
sending and receiving and add dynamic links to support a publish and subscribe messaging
model for you orchestrations. In addition, you will use correlation to route related messages to
an orchestration instance.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-15 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click Ask Me Later, then click OK.
Property Value
Construct shape
Messages constructed ShipRequest
Name Construct ship request
Transform shape
Name MapOrderToShipRequest
Map Northwind.Maps.MapOrderToShipRequest
Note: This map exists in the Northwind.Maps assembly.
Send shape
Name SendShipRequest
Message ShipRequest
Receive shape
Name ReceiveShipAcknowledgement
Message ShipAcknowledgement
5. In the orchestration view window, expand the Types node and right click Correlation
Types, and then click New Correlation Type.
6. In the left pane, expand Northwind.Schemas, click OrderIdentifier then click Add, and
then click OK.
The Northwind.Schemas.OrderIdentifier property is now included in the correlation
type.
7. Set the Identifier property on the correlation type to ShippingCorrelationType.
You have defined a correlation type, which identifies which context properties will be
used to correlate. In the next step, you will define a correlation set which is a
container for specific data, based on this type.
8. Right click the Correlation Sets node to create a new correlation set.
9. Set the identifier property to ShippingCorrelation.
10. Set the correlation type to Northwind.Orchestrations.ShippingCorrelationType
11. On the SendShipRequest shape, set the Initializing Correlation Sets property to
ShippingCorrelation.
12. On the ReceiveShipAcknowledgement shape, set the Following Correlation Sets to
ShippingCorrelation.
You have configured the two ports to participate in correlation. When a message is
sent from the send port, it will initialize the correlation set with the values currently
in the context properties. The receive shape that follows the correlation set will now
have an instance subscription based on the correlation set values.
13. Right-click on the right-hand port surface, and click New Configured Port.
14. In the wizard, name the port ShippingPort and create a new port type named
ShippingPortType.
15. In the next wizard pane, indicate that you will be sending messages and accept all other
defaults.
16. Right-click on the right-hand port surface, and click New Configured Port.
17. In the wizard, name the port ShippingAckPort and create a new port type named
ShippingAckPortType.
18. In the next wizard pane, indicate that you will be receiving messages and accept all
other defaults.
19. Drag the connection points from the send and receive shapes to these new ports as
appropriate.
OrderShipAck = Northwind.Utilities.MessageCreator.CreateShipAck(
OrderShipRequest(Northwind.Schemas.OrderIdentifier));
7. Configure the Shipping orchestration by binding the logical ports to the physical ports
with the following mappings, and choosing the BizTalk Server Application as the host:
8. Both orchestrations should show green check marks when all of the configuration is
complete.
9. Apply the changes and exit the configuration dialog.
ShipperRoleLink(Microsoft.XLANGs.BaseTypes.DestinationParty
) =
new Microsoft.XLANGs.BaseTypes.Party(
shipperIdentifier, "OrganizationName");
Note that in this scenario we hard code the shipper name. In a real scenario, you
would use business rules to dynamically determine the shipper. We use the shipper
name, but when defining parties, any custom identifier can be created as an alias for
that party and used to set the destination part. For example, your internal customer
id, or a DUNS number.
5. Your orchestration should look similar to the image below:
Overview
In this lab you’ll be using the WCF LOB Adapter SDK to build an “Adapter” which could be used
via a WCF Channel (inside or outside of BizTalk). After completing this lab, you should
understand how to create a WCF LOB Adapter using the WCF LOB Adapter SDK, use a WCF
Adapter and how to create a listener with a WCF Adapter. Using the WCF-Custom adapter, you
could invoke operations on the services from BizTalk as well.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-16 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click Ask Me Later, then click OK.
Exercise 1: Create a WCF LOB Adapter Framework Project
Overview
In this part, you will use a project wizard in Visual Studio to generate adapter code that can be
customized to suit your needs. You will use the wizard to generate connection properties that
you can use in your adapter to customize the runtime behavior.
Property Value
Name ContosoCustomAdapter
Location C:\AllFiles\LabFiles\Lab16
Complete the Wizard
Procedure List
1. The WCF LOB Adapter Wizard will appear, read the introduction and press the Next
button.
2. On the next page, enter the Scheme and Project Namespace as follows and click Next:
Property Value
Scheme Contoso
Project Namespace Contoso.CustomAdapter
3. On the Data flows page, select the checkboxes only for the synchronous data flows and
Metadata features so your dialog looks like this, and click Next:
This will create a project which allows all the different channel shapes as well as
enabling all metadata functionality.
4. On the Adapter Properties page, add the properties from the following table by
entering the information and clicking the Add button. Click the Next button when you
have completed.
public ContosoCustomAdapterConnectionFactory(
ConnectionUri connectionUri,
ClientCredentials clientCredentials,
ContosoCustomAdapter adapter)
{
this.clientCredentials = clientCredentials;
this.adapter = adapter;
this.uri =
(ContosoCustomAdapterConnectionUri)connectionUri;
}
uri = this.ConnectionFactory.ConnectionUri;
Console.WriteLine(
"Connection object opened - ServerName = {0}, UserName = {1}",
uri.Uri.Host,
uri.UserName);
You typically would open the phyiscal connection to your LOB or database in the
Open method of the IConnection object. .
9. In the Close method, call Console.WriteLine and print out a string that indicates that the
connection object has been closed.
uri = this.ConnectionFactory.ConnectionUri as
ContosoCustomAdapterConnectionUri;
Console.WriteLine(
"Connection object closed - ServerName = {0}, UserName = {1}",
uri.Uri.Host,
uri.UserName);
set
{
this.uriBuilder = new UriBuilder(value);
this.userName = this.uriBuilder.UserName;
}
}
4. After that code, add code that creates a new Message, with a MessageVersion of
MessageVersion.None, an action with a blank string, and a body of “A message from a
WCF Adapter”.
Message rm = Message.CreateMessage(
MessageVersion.None,
"",
"A message from a WCF Adapter");
return rm;
In a real implementation, this is where you would process the incoming message,
connect to your LOB application or database, and generate a proper return message.
5. Build the project and verify that it compiles before moving on to the next Exercise.
Exercise 3: Create an Outbound Client
Overview
In this part, you will create a simple WCF client application to test the adapter that you created
in Exercise 1.
Assembly Name
System.ServiceModel
System.Runtime.Serialization
Microsoft.ServiceModel.Channels
7. Right-click on the OutBoundClient project in the Solution explorer and select “Add
Reference”.
8. Add a reference to the ContosoCustomAdapter project (found under the Projects tab).
Click OK to close the dialog.
Namespace
Contoso.CustomAdapter
System.ServiceModel
System.ServiceModel.Channels
ContosoCustomAdapterBinding b = new
ContosoCustomAdapterBinding();
b.Transactional = true;
IChannelFactory<IRequestChannel> rcf =
b.BuildChannelFactory<IRequestChannel>();
rcf.Open();
EndpointAddress epa =
new EndpointAddress("contoso://alice@contososervername");
rc.Open();
8. Call IRequestChannel.Request, passing in the Message you just created, use the return
value to initialize a new Message reference, and print out to the console the string value
of this message.
9. Build, and compile. Run once using Ctrl-F5 to verify the output to the console is correct.
Then set breakpoints in the methods you just implemented and run again – this time
using F5, so you can step through the interaction of the client to the adapter.
Exercise 4: Building an Inbound Handler
Overview
In this part, you will implement the inbound capabilities of the adapter that you created in
Exercise 1.
6. Inside of the StartListener method, add code that starts a Timer and adds a new
Message to _messages field every time the Timer hits.
int interval =
this.Connection.ConnectionFactory.Adapter.ListenerInterval;
Console.WriteLine("Listening");
In a real implementation, this is where you would be connecting to your
LOB/database and looking for new messages to consume. This is your “listening”
functionality. A common implementation would be to use a timer, but depending on
your listening functionality your InboundHandler will be different depending on
what your Adapter is connecting to. In this case there isn’t any implementation,
however in a real implementation this is where you would stop the listening
functionality you started in StartListener. In this case, the anonymous delegate will
stop when the class is disposed.
7. Inside of the WaitForMessage method, add the code below. This is the first method that
will be called by the listening infrastructure. Return true here when there are messages
to process.
lock (_messages)
{
if (_messages.Count > 0)
{
return true;
}
return Monitor.Wait(this._messages,
timeout.TotalMilliseconds >= Int32.MaxValue ?
Int32.MaxValue :
(int)timeout.TotalMilliseconds);
}
The purpose of this code is to see if there any messages in the queue (locking the
queue first). It returns true if there are messages to receive. Then it waits the
appropriate Timeout value. It will return true if the Monitor gets the lock on the
_message field within the timeout. The call to Monitor.PulseAll in the timer delegate
will cause this to happen if a message is received (which in this implementation is a
certainty).
8. TryReceive is what will be called repeatedly by the WCF infrastructure over and over
once WaitForMessage returns true.
Console.WriteLine("TryReceive....");
lock (_messages)
{
if (!this.WaitForMessage(timeout))
{
message = null;
return false;
}
message = _messages.Dequeue();
}
return true;
Assembly Name
System.ServiceModel
System.Runtime.Serialization
Microsoft.ServiceModel.Channels
7. Right-click on the InboundClient project in the Solution explorer and select “Add
Reference”.
8. Add a reference to the ContosoCustomAdapter project (found under the Projects tab).
Click OK.
9. Add a using statement for each of the following namespaces:
Namespace
Contoso.CustomAdapter
System.ServiceModel
System.ServiceModel.Channels
Create a Service Contract
Procedure List
1. Inside of Program.cs (but outside of the Program class) create an interface. Name it
IOneWay. Add the ServiceContract attribute to this interface.
2. Add a method to this interface and name it OneWayMethod. Have it take a single
parameter of type Message and return void. Add the OperationContract attribute to
the OneWayMethod, with Action as a wildcard value (“*”) and IsOneWay equal to true.
[ServiceContract]
public interface IOneWay
{
[OperationContract(Action="*",IsOneWay=true)]
void OneWayMethod(Message inmsg);
}
3. Inside of Program.cs (but outside of the Program class) create a class. Name it OneWay.
Have the OneWay class implement the IOneWay interface. Inside of the
OneWayMethod write the string value of the Message out to the console.
4. Inside of the Main method in the Program class, create a ConstosoAdapterBinding and
set the Transactional property to true, and the ListenerInterval to 5000.
ContosoCustomAdapterBinding b = new
ContosoCustomAdapterBinding();
b.Transactional = true;
b.ListenerInterval = 5000;
5. Create a ServiceHost, pass the OneWay type as the parameter to the ServiceHost
constructor.
ServiceHost sh = new ServiceHost(typeof(OneWay));
sh.AddServiceEndpoint(
typeof(IOneWay),
b,
"contoso:// alice@contososervername");
sh.Open();
2. Run once using Ctrl-F5 to verify the output to the console is correct. Then set
breakpoints in the methods you just implemented and run again – this time using F5, so
you can step through the interaction of the client to the adapter. Stop the command
windows when you are satisfied your service is receiving messages.
Lab 17 : Creating a BAM Interceptor Configuration
Overview
In this lab you will be configuring your applications to push KPIs into BAM using the BizTalk BAM
interceptors. In this lab the application is already created for you, you will only create and
configure the WF, WCF, and Orchestration’s interceptors to track data across a logical process
(spanning more than one physical processes). After completing this lab, you should understand
how to: author an interceptor configuration file; deploy an interceptor configuration file;
configure the BAM interceptor for WF; configure the BAM interceptor for WCF and use
continuations to instrument multiple processes with BAM.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-17 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click Ask Me Later, then click OK.
Milestone Description
Start When the process starts; this will be when the WF
Workflow begins processing.
OrchProcessing When the BizTalk Orchestration starts processing.
Processing When the WCF Service begins processing.
Done When the BizTalk Orchestration receives the
response from the WCF Service and ends.
cd %BTSInstallPath%\Tracking
8. From the command prompt, deploy the BAM Activity by typing the following command
(replacing the lab directory) and hitting enter:
You will have to type this command line in by hand. Copying the command from this
document will not work correctly
Exercise 2: Creating the Interceptor Configuration File
Overview
In this part, you will create a single interceptor configuration file for both WF and WCF
components. The WinForms application begins a workflow and sends data to an orchestration.
The orchestration then calls a WCF service.
If you encounter any problems, there is a copy of a the completed IC file in the
C:\AllFiles\LabFiles\Lab17\ContosoActivity.xml folder for reference.
<bam:BamActivity Name="ContosoOrderingSystem">
</bam:BamActivity>
2. Inside of the BamActivity element for the interceptor configuration create an OnEvent
element for the WF source
3. Inside of the OnEvent element for the ConstosoWorkflow source which you just
created, create a filter for the Workflow Started event.
<bam:Filter>
<bam:Expression>
<bamwf:Operation Name="GetWorkflowEvent"/>
<bam:Operation Name="Constant">
<bam:Argument>Started</bam:Argument>
</bam:Operation>
<bam:Operation Name="Equals"/>
</bam:Expression>
</bam:Filter>
4. After the filter you just added, still inside of the OnEvent element, create a
CorrelationId element that uses the Workflow.InstanceId as its context property (use
the GetContextProperty operation for InstanceId).
<bam:CorrelationID>
<bam:Expression>
<bamwf:Operation Name="GetContextProperty">
<bamwf:Argument>InstanceId</bamwf:Argument>
</bamwf:Operation>
</bam:Expression>
</bam:CorrelationID>
5. Next you’ll add the Update element, which uses the GetContextProperty to cause a
timestamp to be written to the BAM Activity for the Start milestone.
<bam:Update Type="DATETIME" DataItemName="Start">
<bam:Expression>
<bamwf:Operation Name="GetContextProperty">
<bamwf:Argument>EventTime</bamwf:Argument>
</bamwf:Operation>
</bam:Expression>
</bam:Update>
6. Next, create two Continuation Token elements – one for BizTalk to continue, one for
WCF to continue.
<bam:ContinuationToken>
<bam:Expression>
<bam:Operation Name="Constant">
<bam:Argument>CorrelationId_</bam:Argument>
</bam:Operation>
<bamwf:Operation Name="GetContextProperty">
<bamwf:Argument>InstanceId</bamwf:Argument>
</bamwf:Operation>
<bam:Operation Name="Concatenate"/>
</bam:Expression>
</bam:ContinuationToken>
<bam:ContinuationToken>
<bam:Expression>
<bam:Operation Name="Constant">
<bam:Argument>WCF_</bam:Argument>
</bam:Operation>
<bamwf:Operation Name="GetContextProperty">
<bamwf:Argument>InstanceId</bamwf:Argument>
</bamwf:Operation>
<bam:Operation Name="Concatenate"/>
</bam:Expression>
</bam:ContinuationToken>
<bam:Filter>
<bam:Expression>
<bamwcf:Operation Name="GetServiceContractCallPoint"/>
<bam:Operation Name="Constant">
<bam:Argument>ServiceRequest</bam:Argument>
</bam:Operation>
<bam:Operation Name="Equals" />
<bamwcf:Operation Name="GetOperationName"/>
<bam:Operation Name="Constant">
<bam:Argument>ProcessOrder</bam:Argument>
</bam:Operation>
<bam:Operation Name="Equals" />
<bam:Operation Name="And" />
</bam:Expression>
</bam:Filter>
3. Next specify the CorrelationId as a concatenation between the string WCF_ and XPath
operation on the message for the OrderId element's value. This will match what the WF
OnEvent has set up for the Correlation. After adding this code, Save the file.
<bam:CorrelationID>
<bam:Expression>
<bam:Operation Name="Constant">
<bam:Argument>WCF_</bam:Argument>
</bam:Operation>
<bamwcf:Operation Name="XPath">
<bamwcf:Argument>//test:OrderId</bamwcf:Argument>
</bamwcf:Operation>
<bam:Operation Name="Concatenate"/>
</bam:Expression>
</bam:CorrelationID>
4. Next, create the Update for the WCF OnEvent - pulling the EventTime from the
GetContextProperty Operation.
<bam:Update DataItemName="Processing" Type="DATETIME">
<bam:Expression>
<bamwcf:Operation Name="GetContextProperty">
<bamwcf:Argument>EventTime</bamwcf:Argument>
</bamwcf:Operation>
</bam:Expression>
</bam:Update>
Exercise 3: Deploy the Interceptor File
Overview
In this part, you will deploy the interceptor file that you created in Exercise 3.
You will need to type this command in manually. Copying the command from this
document to a command line will not work because of formatting issues.
Exercise 4: Configure the Interceptor Runtimes
Overview
In this part, you will add the interceptors into their respective runtimes.
BamTrackingService ts = new
BamTrackingService(
"server=.;database=BAMPrimaryImport;trusted_connection=yes",
5000);
_wr.AddService(ts);
BamCodeExtension b = new
BamCodeExtension(
"server=.;database=BAMPrimaryImport;trusted_connection=yes",
5000);
se.Behaviors.Add(b.Create());
Overview
In this lab you will be configuring a BizTalk Application to be able to successfully process
incoming EDI documents. By deploying an EDI Schema and configuring a party, you’ll be able to
use the EDI components to translate EDI messages to XML. After completing this lab, you
should understand how to: deploy EDI Schemas, create Parties, configure Party specific EDI
properties and configure BizTalk Server to process EDI message.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-18 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click Ask Me Later, then click OK.
C:\AllFiles\LabFiles\Lab18\Contoso.EDI.Artifacts\ Contoso.EDI.Artifacts.sln
2. Right-click on the Contoso.EDI.Artifacts project, point to Add, then click Existing Item,
and then browse to the C:\AllFiles\LabFiles\Lab18 directory. Click X12_00401_850.xsd,
and then click OK.
Normally you would expand the files in %BTSInstallPath%XSD_Schema\EDI
\MicrosoftEdiXSDTemplates.exe to get the EDI schemas you want to use. For
purposes of this lab, we’ve pre-extracted the specific schema file for you (since
extracting the schemas can take quite a while depending on the speed of your
computer).
3. Right-click on the Contoso.EDI.Artifacts project and click “Deploy”.
3. In the BizTalk Administration tree view, right-click the ContosoEDI application, and then
click Start twice.
Exercise 2: Creating the Parties
Overview
In this part, you will create a party to represent the sender of a message that will be received
into BizTalk Server.
Name Value
Mutually Defined (X12) SENDERISA
Duns Plus Suffix 0073268795005
7. In the Profile Properties dialog box, in the menu bar click Add protocol settings, point to
Encoding settings, and then click X12.
8. In the X12_Settings_1 panel, navigate to Inbound Settings, then Interchange Settings,
and then Validation.
9. Ensure that the check box next to Interchange control number is cleared.
These settings allow you to control how the EDI messages are processed including
validation, namespaces to use, etc.
10. Click OK to close the Profile Properties dialog box.
11. Find the Contoso850.txt file in the C:\AllFiles\LabFiles\Lab18 directory for this lab.
Open and examine the EDI message (pay special attention to the ISA line).
Notice that the ISA number is the same as that defined in the party properties, thus
providing BizTalk the information it needs to resolve the party
12. Place a copy of that file in C:\AllFiles\LabFiles\Ports\EDIReceive
13. In the C:\AllFiles\LabFiles\Ports\EDISend directory you should find an XML file. Open it
and examine it – it should be the XML representation of the 850.
Whenever you plan on using the EDI capabilities in BizTalk Server for receiving EDI
messages you’ll need to follow the steps of this activity at a minimum.
Lab 19 : Sending EDI Messages
Overview
In this lab you work for Contoso Winery. Your ERP system outputs invoice messages using a
custom XML Schema. You need to turn these custom XML messages into EDI messages to send
to a trading partner. The trading partner is located in Ireland, so the EDI messages must be
EDIFACT. Also the trading partner requests that the invoices be sent in batches of three (3). In
this lab, you will be deploying the artifacts necessary to turn the XML messages into EDI, and
you will configure EDI batching for the trading partner. After completing this lab, you should
understand how to: configure BizTalk Server EDI to send EDI messages, and configure BizTalk
Server EDI to batch outgoing EDI message.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-19 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click Ask Me Later, then click OK.
File Purpose
EFACT_D96A_INVOIC.xsd The BizTalk Server Schema for EDIFACT
D96A INVOIC. Necessary for converting EDI
messages to XML or XML messages of this
type to EDI.
InternalEDIReceive.btp A custom Pipeline which will allow
processing of incoming XML messages but
also have the EDI component necessary to
support batching.
InternalInvoiceToD96A_INVOIC.btm The map (XSLT) which will transform the
custom invoice schema into the INVOIC XML
message.
InternalInvoice.xsd The internal XML schema for Invoices from
the ERP system.
PropertySchema.xsd A BizTalk property schema definition for the
name of the party sent from the ERP
system. The value is promoted from
InternalInvoice.xsd.
Property Value
Name EDIFileLocation
Transport FILE
Receive Folder C:\AllFiles\LabFiles\Ports\EDIReceive\
(Under Transport – click the
Configure Button)
File Mask (Under Transport – click *.xml
the Configure Button)
Receive Pipeline (Under General) InternalEDIReceive
5. Click OK to close the Receive Port Properties dialog box.
6. Under the EDISending application, right-click the Send Port node, point to New, then
click Static One-way Send Port. After setting the properties as shown below, click OK to
close the dialog.
Property Value
Name EDISend
Transport FILE
Destination Folder (Under C:\AllFiles\LabFiles\Ports\EDIFACTSend
Transport – click the Configure
Button)
File Name (Under Transport – click %MessageID%.txt
the Configure Button)
Send Pipeline EdiSend
Filter (under Filters tab) EDI.ReceiverPartyName == Contoso Buyer
And
EDI.ToBeBatched == False