Continuing the application of Part4
Create the following additional folders:
1. C:\BizTalkServerTutorial\FileDrop\TrackingApplication
Charan: We have a tracking application to keep record of all the loan applications received, but this application expects input in the following XML format.
<Request xmlns="http://TrackingApplication">
<SSN></SSN>
<Name></Name>
<Amount></Amount>
</Request>
So we can’t route a copy of the original message and it expect this input at this folder location ‘C:\BizTalkServerTutorial\FileDrop\TrackingApplication’ as XML file.
Rohit: Don’t worry BizTalk provide you maps to transform message from 1 message format to another. But for that you need to specify the format of the message by creating a schema.
Create the schema for Tracking application input XML
Open the BizTalk project ‘BizTalkTutorial.Part4’(Created in Part4 of this tutorial series) in Visual Studio 2010.Right click the ‘BizTalkTutorial.Part4’ and choose ‘Add -> Add New Item’
Choose ‘Schema’ from ‘Schema Files’ and give ‘TrackingApplicationInputSchema.xsd’ as the name of the schema. Click Add button.
Rename the ‘Root’ in the generated schema to ‘Request’ and choose the ‘<Schema>’ node to change the ‘Target namespace’ to ‘http://TrackingApplication’ as shown below
Right click the ‘Request’ node and add the ‘Child Field Element’ as shown below. Rename it from ‘Field’ to ‘SSN’.
Similarly add two more ‘Child Field Element’ and rename them as ‘Name’ and ‘Amount’. Then change the ‘Data Type’ for ‘Amount’ from ‘xs:string’ to ‘xs:int’ as shown below
Next select the ‘TrackingApplicationInputSchema.xsd’ and in the Properties of this schema, set ‘Output Instance Filename’ to ‘C:\BizTalkServerTutorial\FileDrop\TrackingApplicationInput.xml’
Next right-click the ‘TrackingApplicationInputSchema.xsd’ and choose ‘Generate Instance’.
It would generate an XML file ‘C:\BizTalkServerTutorial\FileDrop\TrackingApplicationInput.xml’. The content of this XML should be something similar to
<ns0:Request xmlns:ns0="http://TrackingApplication">
<SSN>SSN_0</SSN>
<Name>Name_0</Name>
<Amount>10</Amount>
</ns0:Request>
Now create a Map
Right click the ‘BizTalkTutorial.Part4’ and choose ‘Add -> Add New Item’
Choose ‘Map’ from ‘Map Files’ and specify ‘LoanRequest_To_TrackingApplicationInput.btm’ as name of the map.Next click ‘Open Source Schema’ and choose ‘BizTalkTutorial.Part4.LoanRequest’ from ‘BizTalk Type Picker’ dialog box.
Click ‘Open Destination Schema’ and choose ‘BizTalkTutorial.Part4.TrackingApplicationInputSchema’ from ‘BizTalk Type Picker’ dialog box.
In mapper editor click ‘SSN’ in ‘LoanRequest’ schema and drag it to ‘SSN’ in the ‘TrackingApplicationInputSchema’. Similary do for the ‘Amount’ field.
In mapper editor drag ‘String Concatenate’ functoid. Then drag ‘FirstName’ field from ‘LoanRequest’ schema to it and then drag the ‘LastName’ field from ‘LoanRequest’ schema to ‘String Concatenate’ functoid. At last drag the ‘String Concatenate’ functoid to the ‘Name’ field in the ‘TrackingApplicationInputSchema’
Next select the ‘LoanRequest_To_TrackingApplicationInput.btm’ and in the Properties of this map set ‘TestMap Input’ to ‘Native’ ‘TestMap Input Instance’ to ‘C:\BizTalkServerTutorial\FileDrop\App1Output.txt’ (Create in Part4 of this tutorial) and ‘TestMap Output Instance’ to ‘C:\BizTalkServerTutorial\FileDrop\MapOutput.xml’.
Next right-click the ‘LoanRequest_To_TrackingApplicationInput.btm’ and choose ‘Test Map’.
It would generate an XML file ‘C:\BizTalkServerTutorial\FileDrop\TrackingApplicationInput.xml’. The content of this XML should be something similar to
<ns0:Request xmlns:ns0="http://TrackingApplication">
<SSN>BMTP2000E</SSN>
<Name>NitinSachdeva</Name>
<Amount>50000</Amount>
</ns0:Request>
Next redeploy this solution and you must see the deployed map in the ‘BizTalkServerTutorialApplication’ as shown below
Next create a send port using the following details
Name: SP_TrackingApplication_FILE
Transport Type Adapter: FILE
Destination Folder: C:\BizTalkServerTutorial\FileDrop\TrackingApplication
Send pipeline: PassThruTransmit
In the ‘Outbound Maps’ tab select the map ‘LoanRequest_To_TrackingApplicationInput’ as shown below
Next create the ‘Send Port Group’. Specify the name of ‘Send Port Group’ as ‘SendPortGroup_RoutrLoanApplications’ and select both the send ports as part of this ‘Send Port Group’.
Go to filter tab and specify filter as ‘BTS.ReceivePortName == RP_SourceApplication’.
Remove the filer created for send port ‘SP_DestinationApplication_FILE’ in part 2 and start both the send ports, after that start the Send port group and test the solution by putting a copy of file ‘C:\BizTalkServerTutorial\FileDrop\App1Output.txt’ in folder ‘C:\BizTalkServerTutorial\FileDrop\SourceLocation’.
Note: You have to restart the host instance so that the changes made to the deployed solution can take in affect.
Note: You have to restart the host instance so that the changes made to the deployed solution can take in affect.
Summary
You have seen
How to create an XML schema.
How to create a sample file complying with schema.
How to create and test map.
How to use mapper at the send port.
How to create send port group
Cheers,
Rohit Sharma