Simple BizTalk Orchestration & Port Tutorial
- by bosuch
(This is a reference for a lunch & learn I'm giving at my company)
This demo will create a BizTalk process that monitors a directory for an XML file, loads it into an orchestration, and drops it into a different directory. There’s no real processing going on (other than moving the file from one location to another), but this will introduce you to Messages, Orchestrations and Ports.
To begin, create a new BizTalk Project names OrchestrationPortDemo:
When the solution has been created, right-click the OrchestrationPortDemo solution name and select Add -> New Item. Add a BizTalk Orchestration named DemoOrchestration:
Click Add and the orchestration will be created and displayed in the BizTalk Orchestration Designer. The designer allows you to visually create your business processes:
Next, you will add a message (the basic unit of communication) to the orchestration. In the Orchestration View, right-click Messages and select New Message. In the message properties window, enter DemoMessage as the Identifier (the name), and select .NET Classes -> System.Xml.XmlDocument for Message Type. This indicates that we’ll be passing a standard Xml document in and out of the orchestration.
Next, you will add Send and Receive shapes to the orchestration. From the toolbox, drag a Receive shape onto the orchestration (where it says “Drop a shape from the toolbox here”). Next, drag a Send shape directly below the Receive shape.
For the properties of both shapes, select DemoMessage for Message – this indicates we’ll be passing around the message we created earlier.
The Operation box will have a red exclamation mark next to it because no port has been specified. We will do this in a minute.
On the Receive shape properties, you must be sure to select True for Activate. This indicates that the orchestration will be started upon receipt of a message, rather than being called by another orchestration. If you leave it set to false, when you try to build the application you’ll receive the error “You must specify at least one already-initialized correlation set for a non-activation receive that is on a non self-correlating port.”
Now you’ll add ports to the orchestration. Ports specify how your orchestration will send and receive messages. Drag a port from the toolbox to the left-hand Port Surface, and the Port Configuration Wizard launches. For the first port (the receive port), enter the following information:
Name: ReceivePort
Select the port type to be used for this port: Create a new Port Type
Port Type Name: ReceivePortType
Port direction of communication: I’ll always be receiving <…>
Port binding: Specify later
By choosing “Specify later” you are choosing to bind the port (choose where and how it will send or receive its messages) at deployment time via the BizTalk Server Administration console. This allows you to change locations later without building and re-deploying the application.
Next, drag a port to the right-hand Port Surface; this will be your send port. Configure it as follows:
Name: SendPort
Select the port type to be used for this port: Create a new Port Type
Port Type Name: SendPortType
Port direction of communication: I’ll always be sending <…>
Port binding: Specify later
Finally, drag the green arrow on the ReceivePort to the Receive_1 shape, and the green arrow on the SendPort to the Send_1 shape. Your orchestration should look like this:
Now you have a couple final steps before building and deploying the application. In the Solution Explorer, right-click on OrchestrationPortDemo and select Properties. On the Signing tab, click “Sign the assembly”, and choose <New…> from the drop-down. Enter DemoKey as the Key file name, and deselect “Protect my key file with a password”. This will create the file DemoKey.snk in your solution.
Signing the assembly gives it a strong name so that it can be deployed into the global assembly cache (GAC).
Next, click the Deployment tab, and enter OrchestrationPortDemo as the Application Name. Save your solution.
Click “Build OrchestrationPortDemo”. Your solution should (hopefully!) build with no errors.
Click “Deploy OrchestrationPortDemo”. (Note – If you’re running Server 2008, Vista or Win7, you may get an error message. If so, close Visual Studio and run it as an administrator)
That’s it! Your application is ready to be configured and fired up in the BizTalk Server Administration console, so stay tuned!