devxlogo

BizTalk Server 2006: Orchestrating Web Services

BizTalk Server 2006: Orchestrating Web Services

izTalk Server is the cornerstone product in Microsoft’s business process and integration strategy. It is through BizTalk that Microsoft is providing the tools to enable developers to integrate applications, businesses, and EDI, and also orchestrate and coordinate information systems with the business users who drive those systems and their processes. In addition, BizTalk provides a developer experience integrated with Visual Studio, making BizTalk applications easier and more intuitive to develop, and integrating easily with existing Microsoft systems and tools that a business may already use. BizTalk currently has the distinction of being the only server product at Microsoft built primarily on the .NET Framework. The upcoming release of BizTalk Server 2006 extends BizTalk Server 2004 to provide new features for developers building orchestrations and integrating applications and simplifies creating orchestrations that consume or create Web services.

BizTalk Server 2006 has several key enhancements related to Web services. These include the BAM Query Web service, the ability to use Web services outside of orchestrations for messaging scenarios, and support for SOAP arrays. This article explores what you need to do to set up a basic orchestration scenario in BizTalk Server 2006 that consumes a Web service. Then you’ll look at how you might process the Web service results and extend the orchestration for other uses.

What You Need
To view the sample code you need Visual Studio 2005 and BizTalk Server 2006 Beta 1 or the BizTalk Server 2006 November CTP. For more information, see the BizTalk Server 2006 beta installation guide available from Microsoft Downloads.

Setting Up a Web Service
To get started, you’ll need to set up a .NET Web service that returns an array of results to a BizTalk orchestration. To do that, you’ll start with Visual Studio 2005 and create a new ASP.NET Web service project. I’ll show you how to add a Web service method to support the orchestration, but that will be sufficient for you to visualize how you could extend the service as needed.

In Visual Studio 2005, selecting the default Web service project type from the New Project wizard creates a .cs file with a class derived from System.Web.Services.WebService. Attributes that assign a Web service namespace and establish bindings are included, but you’ll need to add your own method (or replace the default HelloWorld method) with your code.

A Sample Method to Return a SOAP Array
Creating a method to return a SOAP array is pretty straightforward. You can use the sample code below, which creates an array of integers, populates the array in a for loop, and returns the array.

   using System;   using System.Web;   using System.Web.Services;   using System.Web.Services.Protocols;      [WebService(Namespace = "http://tempuri.org/")]      [WebServiceBinding(ConformsTo =       WsiProfiles.BasicProfile1_1)]   public class Service : System.Web.Services.WebService   {       public Service () {          }          [WebMethod]       public int[] GetArray()       {           int[] a = new int[10];           for (int i = 0; i 

Testing the Sample Service
After creating the method, you should test and deploy the service for use in the BizTalk application later. When you use HTTP POST to invoke the service from Internet Explorer, you should get the following XML output in your browser:

        0      5      10      15      20      25      30      35      40      45    

When you have the Web service up and running, the next task is to incorporate it into your BizTalk application.

Understanding Orchestrations
Like its predecessor, BizTalk Server 2006 supports several features that make it easier to build and deploy applications that involve complex workflows or process orchestration. To take advantage of these features, you'll first want to understand the basics of orchestrations in BizTalk. Orchestrations in BizTalk are representations of an executable business processes. You create visual representations of your business processes using the BizTalk Orchestration Designer tool, which lets you design workflows, transform data, invoke custom code, and organize all these actions. These visual representations are then compiled into an executable module?automatically reflecting your visual representation in underlying code. The designer provides a variety of shapes that correspond to different actions that you might want to perform with your business process or systems integration workflow.

There are some important components of orchestration that you need to know about. Messages, the send and receive actions that perform message operations, and the ports through which messages are transported are all elements of an orchestration. The message is the medium through which orchestrations communicate. Receive and Send shapes encapsulate the functionality you need to receive messages in your orchestration and send messages from it. You need to become familiar with the various shapes that the Orchestration Designer provides to represent the logical flow of your orchestration. By defining message types, ports, port types, and operations in a standard way, based on Web services, disparate systems can communicate with each other.

Other important orchestration concepts include correlations and transactions. Correlation is a mechanism that associates messages with specific running instances of an orchestration, so that your business processes gets the appropriate information when many instances are running and many messages are being transmitted. Transactions let you maintain the state of an orchestration appropriately if any unexpected issues arise. BizTalk's orchestration designer includes exception-handling support, letting you deal with errors in a controlled manner.

With the basics of orchestrations defined, you can now proceed with creating one in BizTalk and implementing your Web service.

Creating an Orchestration
Getting started with orchestrations in BizTalk is simple. First, you create a project in Visual Studio 2005. You select one of the BizTalk project types, and start with an empty BizTalk project. From there, you right click on the project and select the option to add new items to the project. You can add Orchestration Files to the project from the BizTalk Project Items menu. At this point, you should see an Orchestration design surface similar to that in Figure 1.

?
Figure 1. Orchestration Design Surface: The figure shows the orchestration design surface in Biztalk 2006 where you can drag and drop orchestration shapes.
?
Figure 2: Port Configuration Wizard: Right-clicking on a port object launches this configuration wizard.

With this surface in place, you can view shapes in the toolbox from within the Visual Studio environment and start building the orchestration. To get started, add a Receive shape, a Send shape, and a port to receive a request and send a response. You'll also want a port to receive a message for file mapping. To configure the port for Web service binding, right-click on the port. That will start a wizard as shown in Figure 2. In this wizard, you'll be asked to create a new port type (or specify an existing type) and create a binding for that port. In this case, you'll bind the receive port to the SOAP service provided by the Web service you created earlier by entering the URI for the Web service and specifying the transport type. Because invoking the Web service requires a request-and-response communication pattern, select that communication pattern when configuring the port.

With the Web service wired up to the orchestration, your design surface should be similar to that shown in Figure 3. Now you can build the solution to ensure that your messages are correctly configured and that your Web services bindings are correct. With the Web service configured in the orchestration, you can use the results in a variety of ways. For example, you might pass the message results on to another port. The sample project serializes the message and stores it as an XML file on the file system using a file as the transport type and a file location. Figure 4 shows a message transform added to the orchestration.

?
Figure 3. Orchestration Designer: The figure shows how the orchestration design surface should look after wiring up the Web service to your orchestration.
?
Figure 4. Message Transform: The figure shows the orchestration after adding a message transform.

You'd use a message transform to configure a transformation of the message based on a pre-defined or custom mapping. For example, you can use one to map an XML file to a flat-file format or to modify data in the file based on rules or custom logic (e.g. currency conversion).

Leveraging Web Services in BizTalk Orchestrations
The BizTalk Server 2006 upgrade includes a variety of capabilities, but the Web services support for SOAP arrays and easy integration into BizTalk orchestrations is one of the more useful features. When you consider the fact that there are a host of new BizTalk adapters, including the POP3 adapter, an officially supported SharePoint adapter, and a number of adapters for third-party applications including Oracle Application Suite, Siebel and PeopleSoft the benefits of using Web services in orchestrations are obvious.

BizTalk Server 2006 also supports pipeline adapters with the next version of Commerce Server, slated for release next year. This will include adapters to support integration with Commerce Server orders, profiles, and inventory data with bi-directional functionality to enable integration with trading partner sites or with ERP systems integrated with BizTalk. Combined with BizTalk Server's Web services publishing wizard, which lets you expose orchestrations as Web services that can be invoked externally, the power of Web services in BizTalk is growing.

While BizTalk isn't as commonly used as .NET by Windows developers, it provides a powerful set of features to support common scenarios for application integration, workflow and process management. Although it can be simpler and more straightforward to publish a Web service using Visual Studio, implementing Web services in BizTalk lets you change the processes where Web services are employed dynamically. Simply put, BizTalk makes complex software for integration more agile than custom code.

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist