Browse DevX
Sign up for e-mail newsletters from DevX


Codelessly Orchestrate your Business Processes with Microsoft BizTalk 2004 : Page 2

When business process and rules can be described to a runtime engine instead of programmed in code, a lot of problems get solved. Take this hands-on introductory lesson to Microsoft's BizTalk and learn how to abstract your apps with enterprise class.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

The Application
Figure 1. Workflow for the System: The application executes the trade automatically only if there are 5,000 or fewer shares involved in the transaction.
The sample application for this article will automatically execute low-dollar stock trades for a financial services firm or a brokerage. The premise is that traders and analysts do not need to process and verify every trade, just the major ones. How a small trade executes is a flow, and how the trade is evaluated for execution is based on a rule. In this case the rule is that if the trade involves more than 5,000 shares it is passed to the broker's terminal for approval; otherwise the system executes it automatically.

The process flow for the sample application logic is diagrammed in Figure 1.

As an enterprise-class server product, BizTalk enforces strong security policies. So the first step is to create a strong name assembly key file. To do this, open the Microsoft Visual Studio.NET command prompt, and changing to the directory in which you are going to build the project. For this example, I created a directory named DevXBT.

When you are in the directory, issue the following command at the prompt:

sn --k DevXBT.snk

Figure 2. Visual Studio.NET Containing the Schema: Put the two schemas for the sample app in your project folder in Visual Studio.
You should receive a message stating that the key pair was written to DevXBT.snk.

Create three new folders in the DevXBT directory, called In, OutSystem, and OutBroker. These will be used later.

In the next step you will create the data schema associated with the solution. For the purpose of simplicity, the order entry and allow trade will be one schema, and the order denied will be another, so there will only be two schema in the system.

Create a new 'Empty BizTalk Server' project in the DevXBT directory, and call it ShareTraderSchema. Add two new schema to the project and call them MakeRequest and DenyRequest. The download with this article contains the schema, which have very simple structures (see Figure 2).

Setting Up the Pipelines
BizTalk uses the concept of a pipeline for a method of transferring data from one point to another. A pipeline prepares messages for processing after being received or before sending. In this case, we will simulate notifying the broker by converting the XML of the trade request into a flat file that would get written to his terminal. The terminal would process this flat file adding a user interface that allows the broker to accept or reject the trade. Systems such as this one would then have an Order Execution System to carry out the actual trade. Generally this would accept the same file format, so this conversion serves a dual purpose.

To create a send pipeline, simply right-click the ShareTraderSchema project in Solution Explorer, select Add New Item, and select Send Pipeline. Call it SendTradeRequest.btp.

You will see the pipeline designer on the screen. It has three stages: Pre-Assemble, Assemble, and Encode. You can add logic to each of these steps to take some action on the data in these three steps. For now, you just want to convert the output to a flat file, so you drag the item 'Flat File Assembler' from the toolbar onto the Assemble drop target.

Connecting the Schema
Figure 3. Link the Schema: The BizTalk Mapper is used to translate and link the source schema with the destination schema.
You inform BizTalk of the relationship between the documents by connecting their schema. You will notice that the two schema we defined earlier both have a tradeID field, so we will use this to connect them logically. You do this using the BizTalk Mapper.

Add a new Map item to your project and call it MapDenyRequest.btm. When you have done this, you will see Visual Studio open the file with an area for the Source Schema on the left, the Destination Schema on the right, and the Mapper Grid in the center. Add MakeRequest.xsd as the source schema, and DenyRequest.xsd as the Destination schema. Expand both schema and drag the TradeID field from the Source Schema to the Destination Schema. You have now linked the two (see Figure 3). Now drag CustomerID from the Source to CustomerID on the destination to connect the data between them.

You are now ready to build your project into a DLL resource file that the final system will use for the schemas, the pipeline, and the file mapping. Before building, you have to associate your DLL with the Assembly Key file that you created earlier. To this, select the project, right click, and select Properties. On the Property pages for the project, select Assembly, find the property called Assembly Key File, and set it to the DevXBT.snk file that you created earlier. You can now build your solution.

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date