| BizTalk Training 1 - basic send/receive xml message |
Overview
This tutorial shows how to create simple orchestration to send/receive xml messages using FILE Adapter.
There are 9 tutorials in this training.
- BizTalk Training 1 - basic send/receive xml message
- BizTalk Training 2 - receive/send plain text
- BizTalk Training 3 - customize filename dynamically
- BizTalk Training 4 – using Functiods in Map
- BizTalk Training 5 - using FTP Adapter
- Working on…
Objectives
- Learn how to create schema from sample xml file.
- Learn how to send/receive xml message using FILE adapter.
- Learn how to deploy BizTalk project to BizTalk Administration.
Topics
- Add new orchestration.
- Create schema.
- Create new Message.
- Create logical ports.
- Deploy the project.
- Configure BizTalk Administration.
Step-by-step
Suppose that I want BizTalk to process xml message from folder A (C:\FILE1\IN\*.xml) to folder B (C:\FILE1\OUT\%SourceFileName%). The sample data of xml message is in C:\FILE1\person1.xml.
<Person> <Name>Mr. A</Name> <Position>Sales Manager</Position> <Salary>10000</Salary> </Person>
- Add new orchestration.
- Create schema
- Now I need to create schema for receive and send component. If you don’t have schema file (.xsd file) that corresponds with xml message, you need either to create schema by using wizard to generate from xml message or create by yourself. By using wizard, it’s fast but it doesn’t work well if your xml message is too complex.
- Solution 1: using BizTalk Schema Generator
- To use this wizard, you need to enable it before use once by execute VBScript file that is in BizTalk SDK Utilities directory. If you installed BizTalk on default directory, the files should be in C:\Program Files\Microsoft BizTalk Server 2006\SDK\Utilities\Schema Generator\. If your document type is DTD, execute InstallDTD.vbs. If your document type is standard XML (Well-formed XML), execute InstallWFX.vbs. Or you can execute both files.

- Back to the orchestration, in solution explorer. Select Add Generated Items.

- Select Generate Schemas on left side and select Generate Schemas on right side. Click Add.

- On document type, select Well-Formed XML and select input file from sample xml message. Click OK.

- Wait for a while and you will see your schema has been created.

- You’ll need to clear target namespace because the sample file doesn’t have any target namespace by click on “Schema” and clear Target Namespace in Properties.
- Solution 2: create the schema manually
- In solution explorer, select Add New Items.

- Select Schema Files on left side and select Schema on right side. Also, named the schema as person1.xsd. Click Add.

- Now you’ll see empty schema file. You can add new element by right click on root node -> select Insert Schema Node -> Child Field Element.

- Try to create element as the same in sample xml message. Also, you can change data type in properties window.

- You’ll need to clear target namespace because the sample file doesn’t have any target namespace by click on “Schema” and clear Target Namespace in Properties.
- Change name of the root to Person and now you’ll get the schema for incoming message.
- Create new Message
- On orchestration1, move to Orchestration View. Right click on Messages and select New Message.
- Highlight on Message_1, change Identifier to msgPerson and select Message Type as schema that you’ve created in 5). (Schema -> BizTalkTraining.person1)
- Change Message on receive and send components in the orchestration1 to msgPerson.

- Create logical ports
- You have configured to receive msgPerson and send out msgPerson. Next you need to create logical ports to receive and send these messages from/to.
- Create receive port.
- Right click on Port Surface area (red rectangular) and select New Configured Port.

- Click Next. Named the port as RecvPersonPort. Click Next.

- Configure Port Type.
Name Port Type Name as ‘RecvPersonPortType’. Leave Create a new Port Type, Communication Pattern as One-Way and Access Restrictions as Internal selected. Click Next.
- Configure Port Binding.
- Ensure that “I’ll always be receiving messages on this port.” is selected.
- Select Port binding as “Specify now”.
- Select Transport as “FILE”.
- Type URI: as path with file mask that you want to receive. In this sample, it is “C:\FILE1\IN\*.xml”. That means to read any .xml file in C:\FILE1\IN.
- Select Receive pipeline as XMLReceive.
- Click Next and Finish.
- Right click on Port Surface area (red rectangular) and select New Configured Port.
- Create send port.
- Right click on Port Surface area (red rectangular) and select New Configured Port.

- Click Next. Named the port as SendPersonPort. Click Next.

- Configure Port Type.
Name Port Type Name as ‘SendPersonPortType’. Leave Create a new Port Type, Communication Pattern as One-Way and Access Restrictions as Internal selected. Click Next.

- Configure Port Binding.
- Ensure that “I’ll always be sending messages on this port.” is selected.
- Select Port binding as “Specify now”.
- Select Transport as “FILE”.
- Type URI: as path to destination file that you want to send. In this sample, it is “C:\FILE1\OUT\%SourceFileName%”.
Note: %SourceFileName% is the mask that means using file name as it was receive. - Select Send pipeline as XMLTransmit.
- Click Next and Finish.
- Now you have configured logical ports to map with physical paths. Next is to connect logical ports to receive and send components that you have created previously. Drag green button on RecvPersonPort (1) to green button on Receive_1 component (2). Also, repeat this on send port.

- Deploy the project
- Click on Receive_1 component and change Activate to “True” in the properties.

- We have finished on the orchestration. Next, we are going to deploy the project on BizTalk Administration. On the solution explorer, right click on Solution ‘BizTalkTraining’ and select Properties.

- On Solution Property Pages
- Select Configuration in Configuration Properties.
- Change Configuration to Deployment.
- Ensure that Deploy has been checked.
- Click OK.
- Next create strong name key and assign to the project
- Open Visual Studio 2005 Command Prompt by select on Programs.

- Type in the command prompt ‘sn -k c:\FILE1\BizTalkTraining.snk’. Then the key will be created in c:\FILE1.

- Back to the BizTalkTraining project, right click on BizTalkTraining and select Properties.

- On Property Pages
- Select Assembly in Common Properties.
- Find Assembly Key File. Click … to browse.
- Select file that you have just created “BizTalkTraining.snk”.
- Click Open and OK.
- To change name of the application when deployed, select Deployment in Configuration Properties.
- On Application Name, change to “BizTalkTraining”.
- Click OK.

- Open Visual Studio 2005 Command Prompt by select on Programs.
- Now you’re ready to deploy the project to BizTalk Administration. Right click on Solution ‘BizTalkTraining’ and select Deploy Solution.

- You’ll see in output window if the deploy was succeeded.

- Configure BizTalk Administration
- Open BizTalk Administration; expand BizTalk Server 2006 Administration -> BizTalk Group -> Applications. You’ll see BizTalk Training was deployed to here. Right click on BizTalkTraining and click configure.

- On Configure Application window, select Host to BizTalkServerApplication. Click OK.

- Now you can start your application, but you need to create folder as you have already configured in Visual Studio. For receive folder, C:\FILE1\IN. For send folder, C:\FILE1\OUT.
- Right click BizTalkTraining again; click start to start BizTalk application.

- Click Start again.

- Now BizTalkTraining application is running, you can test your application by copy person1.xml (sample xml file) to receive folder (C:\FILE1\IN). If the application is configured correctly, the file will be moved to send folder (C:\FILE1\OUT) with the same name as in receive folder.
- Result in C:\FILE1\OUT\Person1.xml.

Resources
You can download the example source code (zip file) at here.
The zip file contains
- BizTalkTraining folder which is the example project on Visual Studio 2005.
- FILE1 folder which contains IN and OUT empty sub folders for test receive and send message, BizTalkTraining.snk which is a strong name key file used in the example project and person1.xml which is an example xml message.
- binding.xml file which is a configuration file for import in BizTalk Administration.






























