Professional Documents
Culture Documents
Overview
This tutorial shows how to create simple orchestration to send/receive xml messages using FILE Adapter.
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
1. 2. 3. 4. 5. 6. 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>
Page 1 of 47
Page 2 of 47
and Send
2. Create schema o Now I need to create schema for receive and send component. If you dont 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, its fast but it doesnt work well if your xml message is too complex. o Solution 1: using BizTalk Schema Generator
Page 3 of 47
3. 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.
Page 4 of 47
5. Select Generate Schemas on left side and select Generate Schemas on right side. Click Add.
6. On document type, select Well-Formed XML and select input file from sample xml message. Click OK.
Page 5 of 47
7. Wait for a while and you will see your schema has been created.
8. Youll need to clear target namespace because the sample file doesnt have any target namespace by click on Schema and clear Target Namespace in Properties.
Page 6 of 47
9. Select Schema Files on left side and select Schema on right side. Also, named the schema as person1.xsd. Click Add.
Page 7 of 47
1. Now youll see empty schema file. You can add new element by right click on root node -> select Insert Schema Node -> Child Field Element.
Page 8 of 47
10. Try to create element as the same in sample xml message. Also, you can change data type in properties window.
1. Youll need to clear target namespace because the sample file doesnt have any target namespace by click on Schema and clear Target Namespace in Properties.
Page 9 of 47
2. Change name of the root to Person and now youll get the schema for incoming message.
11. Create new Message o On orchestration1, move to Orchestration View. Right click on Messages and select New Message.
Page 10 of 47
Highlight on Message_1, change Identifier to msgPerson and select Message Type as schema that youve created in 5). (Schema -> BizTalkTraining.person1)
Page 11 of 47
12. Create logical ports o 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. o Create receive port. 1. Right click on Port Surface area (red rectangular) and select New Configured Port.
Page 12 of 47
3. 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
Page 13 of 47
Next.
4. Configure Port Binding. Ensure that Ill 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.
Page 14 of 47
Page 15 of 47
1. Right click on Port Surface area (red rectangular) and select New Configured Port.
Page 16 of 47
3. 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.
4. Configure Port Binding. Ensure that Ill 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.
Page 17 of 47
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.
Page 18 of 47
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 1. Select Configuration in Configuration Properties. 2. Change Configuration to Deployment. 3. Ensure that Deploy has been checked. 4. Click OK.
Page 19 of 47
Next create strong name key and assign to the project 1. Open Visual Studio 2005 Command Prompt by select on Programs.
Page 20 of 47
2. Type in the command prompt sn -k c:\FILE1\BizTalkTraining.snk. Then the key will be created in c:\FILE1.
3. Back to the BizTalkTraining project, right click on BizTalkTraining and select Properties.
4. On Property Pages Select Assembly in Common Properties. Find Assembly Key File. Click to browse. Select file that you have just created BizTalkTraining.snk.
Page 21 of 47
To change name of the application when deployed, select Deployment in Configuration Properties. On Application Name, change to BizTalkTraining.
Page 22 of 47
Click OK.
Now youre ready to deploy the project to BizTalk Administration. Right click on Solution BizTalkTraining and select Deploy Solution.
Page 23 of 47
14. Configure BizTalk Administration o Open BizTalk Administration; expand BizTalk Server 2006 Administration -> BizTalk Group -> Applications. Youll see BizTalk Training was deployed to here. Right click on BizTalkTraining and click configure.
Page 24 of 47
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.
Page 25 of 47
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.
Page 26 of 47
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.
Objectives
Learn to create schema using Flat File Schema Wizard. Learn to receive file which is plain text to BizTalk. Learn to send file from BizTalk to plain text.
Prerequisites
Page 27 of 47
Topics
1. 2. 3. 4. Create schema from plain text using Flat File Schema Wizard. Add receive and send pipeline for receive/send plain text. Modify orchestration. Deploy the project.
Step-by-step
As from training 1, I have sample file which is an xml message. Now what if I want a plain text as an input, BizTalk can receive any file format which you can determine the schema in pipeline. Suppose, I have the same data as in training 1 but its a plain text instead of xml in C:\FILE2\person1.txt.
1. Create schema from plain text using Flat File Schema Wizard. 2. Open existing BizTalkTraining project, Add New Item to the project.
Page 28 of 47
3. Select Schema Files -> Flat File Schema Wizard and name the schema as FlatFilePersonSchema.xsd?.
Page 29 of 47
5. On Instance file, click Browse and select the sample text file that you want to create schema from. Change Record name to Person and click Next.
Page 30 of 47
6. On Select Document Data, leave the data highlight and click Next.
7. Click Next.
Page 31 of 47
8. Ensure that Child delimiter is {CR}{LF} which means split data with new line characters. Click Next.
Page 32 of 47
Page 33 of 47
11. Now that you have created a schema file from plain text.
12. Add receive and send pipeline for receive/send plain text. o Add New Receive Pipeline. Right click on the project -> Add New Item -> select Pipeline Files -> Receive Pipeline -> name
Page 34 of 47
as ReceivePersonPipeline.btp.
Page 35 of 47
Page 36 of 47
Click on Flat file disassembler object that youve just dropped. On Properties, change Document schema to BizTalkTraining.FlatFilePersonSchema? which is the schema that weve created previously.
o
Now add new Send Pipeline. Right click on the project -> Add New Item -> select Pipeline Files -> Send Pipeline -> name
Page 37 of 47
as SendPersonPipeline.btp.
Page 38 of 47
Click on Flat file assembler object that youve just dropped. On Properties, change Document schema to BizTalkTraining.FlatFilePersonSchema?
o
Page 39 of 47
Now youve configured receive pipeline for receive plain text and send pipeline for send to plain text. 13. Modify orchestration. o Back to Orchestration1.
o
Change the schema from person1.xsd to FlatFilePersonSchema.xsd on ports and receive/send components.
Page 40 of 47
14. Break the green link between ports and receive/send components by right click on the line and select Delete.
16. Change message type for msgPerson. o On orchestration1, switch to Orchestration View. o Select msgPerson.
Page 41 of 47
On Properties, change message type to BizTalkTraining.FlatFilePersonSchema? which is the schema that weve created recently.
17. Change message type on both ports. 18. Click Request on RecvPersonPort. Be sure that you click on Request which inside the port, youll notice the highlight only around in Request not entire port.
Page 42 of 47
19. On Properties, change message type to BizTalkTraining.FlatFilePersonSchema? which is the schema that weve created recently.
Repeat change message type on SendPersonPort, too. 20. Connect ports and receive/send components back.
o
Modify RecvPersonPort. Click on RecvPersonPort and move to Properties window. Change the Receive pipeline to BizTalkTraining.RecvPersonPipeline? which is the receive pipeline that weve created.
Page 43 of 47
o Modify SendPersonPort. 22. Click on SendPersonPort and move to Properties window. 23. Change the Send pipeline to BizTalkTraining.SendPersonPipeline? which is the send pipeline that weve created. 24. Change the URI (Receive location) to C:\FILE2\OUT\%SourceFileName%?.
Youve just configured to receive plain text (*.txt) from a folder to send to another folder as plain text. 25. Deploy the project.
o
Page 44 of 47
If you have deployed this project before (in Training 1), you need to restart BizTalkServerApplication and refresh the application. 0. Expand BizTalk Server 2006 Administration -> BizTalk Group -> Platform Settings -> Host Instances.
Page 45 of 47
27. Right click on the host which runs BizTalkTraining application (Host type as In-Process) and click Restart.
0. Next, refresh the application by right click on BizTalk Training and select Refresh. Now your application on BizTalk is up-to-date.
If you havent deployed this application before, go back to Training 1 for further detail.
Page 46 of 47
Now you can test by drop person1.txt to C:\FILE2\IN and wait for result come out in C:\FILE2\OUT.
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. FILE2 folder which contains IN and OUT empty sub folders for test receive and send message and person1.txt which is an example text message. binding.xml file which is a configuration file for import in BizTalk Administration.
Page 47 of 47