In Many situations we may have to save the file in the Output folder in a proper format.
BizTalk Send Port with File Adapter supports the following formats (macros) for the files saved.
%MessageID%
%datetime%
%SourceFileName%
%time%
Incase if we want the output file name to be some thing other than the available macros, we need to do some coding either in the Orchestration or in the Pipeline.
This Post will show you how you set the output file name in an Orchestration.
Scenario: Create a schema, receive a file of that type and set a name for the file and save it back to an output folder.
1. Create a sample schema in a BizTalk Project and add an Orchestration to the project.
2. Create two messages of the Schema Created in above step
3. Add a Receive, Message assignment and Send Shape as shown below.
4. Configure the Receive shape to Receive Message_1, set activate to true.
5. Configure the Construct Message shape to construct Message_2 and Send shape to Send Message_2. Resulting Orchestration should look like below.
6. Add the following code in the Message Assignment shape.
Message_2 = Message_1;
Message_2(FILE.ReceivedFileName) = "MyOutputFile";
7. Add a receive and send ports and complete the Orchestration.
8. Deploy the Orchestration.
9. Configure the Send Port File Adapter as show below. (Change the file name to use %SourceFileName% Macro. (Case Sensitive)
10. Drop an instance of the Schema in the input folder, and see that the Output file name will be the same as what I have given in Step6.
The idea behind this is that, I have change the ReceivedFileName Context Property of the message received to my desired format and then I have used the % SourceFileName% macro.
The same can also be done using a Pipeline.
Hope it helps.
- Shiv
Saturday, 4 December 2010
Issue: Schema not found in BizTalk Type Picker of a BizTalk Map
Today I had a different issue when in I started to work on a BizTalk Sample created by a colleague.
It has a source and destination schema, which are to be mapped.
A new map is then created and a source schema is added. When I clicked on Select Destination Schema, I was not able to find the destination schema in the BizTalk Type Picker of the BizTalk Map.
There are no build errors and every thing looked fine.
The culprit which led to this is the Build Action property of the schema.
This property will be shown when you select the schema in the Solution Explorer.
If this property is set to None, it will not be included in the Build and hence will not be able to use that in BizTalk Tools.
I made the Build Action to BTSCompile and it showed up in the BizTalk Type Picker of the BizTalk Map.
The reason being for this is that the schema was not created using BizTalk Schema Editor rather using an external tool. Hence when this schema was imported to BizTalk Project, its Build Action property was set to None.
So, care should be taken for the schemas that are created outside BizTalk Schema Editor.
Hope it helps.
- Shiv
It has a source and destination schema, which are to be mapped.
A new map is then created and a source schema is added. When I clicked on Select Destination Schema, I was not able to find the destination schema in the BizTalk Type Picker of the BizTalk Map.
There are no build errors and every thing looked fine.
The culprit which led to this is the Build Action property of the schema.
This property will be shown when you select the schema in the Solution Explorer.
If this property is set to None, it will not be included in the Build and hence will not be able to use that in BizTalk Tools.
I made the Build Action to BTSCompile and it showed up in the BizTalk Type Picker of the BizTalk Map.
The reason being for this is that the schema was not created using BizTalk Schema Editor rather using an external tool. Hence when this schema was imported to BizTalk Project, its Build Action property was set to None.
So, care should be taken for the schemas that are created outside BizTalk Schema Editor.
Hope it helps.
- Shiv
Wednesday, 1 December 2010
How to modify a BizTalk Message using C# or External Dll ?
In many situations the Mapper available with BizTalk Server or Xpath functions might not be sufficient to construct the Required Message in BizTalk Server.
In these scenarios, we can pass the necessary inputs to an external library and construct the message there using C# code.
This article will show two possible ways of achieving this.
Scenario:
You have a schema in your BizTalk Project. You receive a message of this type in a receive folder and pass this message to an External Library, update the message and send it back to BizTalk. Save the updated message to a new location.
Solution:
There are two possible ways of doing this.
Create an equivalent class file for the Schema and pass the message as class object to the External dll
Pass the message contents as an XML Document to the External Dll and modify the message using XMLDocument or XLinkq or any other thing else.
1. Create a new BizTalk Project and add a Sample schema Schema1 as shown below.
2. Use the XSD.EXE utility to convert the schema created above into a serializable class. For this, Go to Visual Studio Command Prompt and give the following Command at the directory where Schema is located.
XSD Schema1.xsd /c /o:c:\
Note: See this for more details on xsd.exe
3. Create a Class Library Project and add the above class file to the Project. Now we have an equivalent class file for the schema.
4. Create a Static method in the Class that updates the Received Object and sends it back using C #as shown below.
5. Build it and add a reference of this class library to the BizTalk Project.
6. Add an orchestration to the BizTalk Project and create two messages of the Type Schema1
7. Add a Receive Shape and Message Constructor shape and a send shape and complete the orchestration as shown below.
8. Add the below code in the Message assignment shape.
Message_2 = ClassLib.Root.GetClassReference(Message_1);
9. This will call the GetClassReference and the Message Message_1 will be automatially serialized into the class Object. Within the method, schema elements and attributs can be accessed just like class properties.
10. To Test this project, deploy both BizTalk project and Class Library to GAC and put an input file, you will see that the values are updated.
11. The same can also be achieved by passing the Message Contents as an XML object as given below.
Variable_1 = Message_1;
Variable_1.LoadXml(ClassLib.Root.GetClassReferenceUsingXML(Variable_1.OuterXml));
Message_3 = Variable_1;
Note: Variable_1 is of tpye XMLDocument.
12. Now you should have a method in the External Library that modifies the message using XML Operations. A sample is given below.
While I tested with Schemas with more than 50 Elements, I find that using XMLDocument to modify the Contents was very much faster that using Class Objects.
Hope it helps.
- Shiv
In these scenarios, we can pass the necessary inputs to an external library and construct the message there using C# code.
This article will show two possible ways of achieving this.
Scenario:
You have a schema in your BizTalk Project. You receive a message of this type in a receive folder and pass this message to an External Library, update the message and send it back to BizTalk. Save the updated message to a new location.
Solution:
There are two possible ways of doing this.
Create an equivalent class file for the Schema and pass the message as class object to the External dll
Pass the message contents as an XML Document to the External Dll and modify the message using XMLDocument or XLinkq or any other thing else.
1. Create a new BizTalk Project and add a Sample schema Schema1 as shown below.
2. Use the XSD.EXE utility to convert the schema created above into a serializable class. For this, Go to Visual Studio Command Prompt and give the following Command at the directory where Schema is located.
XSD Schema1.xsd /c /o:c:\
Note: See this for more details on xsd.exe
3. Create a Class Library Project and add the above class file to the Project. Now we have an equivalent class file for the schema.
4. Create a Static method in the Class that updates the Received Object and sends it back using C #as shown below.
5. Build it and add a reference of this class library to the BizTalk Project.
6. Add an orchestration to the BizTalk Project and create two messages of the Type Schema1
7. Add a Receive Shape and Message Constructor shape and a send shape and complete the orchestration as shown below.
8. Add the below code in the Message assignment shape.
Message_2 = ClassLib.Root.GetClassReference(Message_1);
9. This will call the GetClassReference and the Message Message_1 will be automatially serialized into the class Object. Within the method, schema elements and attributs can be accessed just like class properties.
10. To Test this project, deploy both BizTalk project and Class Library to GAC and put an input file, you will see that the values are updated.
11. The same can also be achieved by passing the Message Contents as an XML object as given below.
Variable_1 = Message_1;
Variable_1.LoadXml(ClassLib.Root.GetClassReferenceUsingXML(Variable_1.OuterXml));
Message_3 = Variable_1;
Note: Variable_1 is of tpye XMLDocument.
12. Now you should have a method in the External Library that modifies the message using XML Operations. A sample is given below.
While I tested with Schemas with more than 50 Elements, I find that using XMLDocument to modify the Contents was very much faster that using Class Objects.
Hope it helps.
- Shiv
Project Reference Errors in BizTalk
While developing BizTalk projects that referencing several other projects, many errors will be shown while compiling the BizTalk Projects. These errors will go away once the references are removed and added again.
Also, sometimes, updated made in the referenced projects will not be updated automatically.
This is a known issue with BizTalk Server 2009 and after googling I found that Microsoft has given a Hot Fix for this which can be downloaded here.
Also, sometimes, updated made in the referenced projects will not be updated automatically.
This is a known issue with BizTalk Server 2009 and after googling I found that Microsoft has given a Hot Fix for this which can be downloaded here.
Thursday, 25 November 2010
How to Send & Receive Custom Headers from a WCF Service in Orchestration?
In many practical scenarios, Headers of the WCF Message are used to Establish Session / Send some sensitive / routing information
In this post I will show you how to Send and Receive data through Custom Headers from a WCF Service.
Solution:
Scenario:
Orchestration adds Header and Sends to the Service -> Service Receives the Header and writes to EventLog -> Service adds and outbound header and sends back to Orchestration -> Orchestration Receives the Header
1. Create a Sample WCF Service that gets the value from the Incoming Message and adds an outbound header to the outgoing message. Sample code is given below.
public string GetHeaderValue(string HeaderName, string URI)
{
// Receive Inbound Header
string val = OperationContext.Current.IncomingMessageHeaders.GetHeader(HeaderName, URI);
EventLog.WriteEntry("Received Header", "Header Value: " + val);
// Send Outbound Header
MessageHeader header = MessageHeader.CreateHeader("Test","Test.com","TestValue");
OperationContext.Current.OutgoingMessageHeaders.Add(header);
return val;
}
2. Deploy the Service and Consume it in a BizTalk Project. It creates input message schema, orchestration, output message schema, port type and Binding Files.
3. Create 3 Message as shown below in the Orchestration.
Let Message_1 and Message_2 represent Input Message Schema and Message_3 represent Output message Schema
4. Create a Receive Shape, set the Message property to Message_1, activate to True
5. Add a Construct messsage shape, set the Message Constructed property to Message_2. We pass header message to the Service by using the property (WCF.OutboundCustomHeaders). Add the following code in the Message Assignment shape.
Message_2 = Message_1;
Message_2(WCF.OutboundCustomHeaders) = @"From Clietn";
Resulting Orchestration should be like below
Note: In this step, I created a new message Message_2 (same schema as Message_1) rather than editing a Message_1 because, messages in BizTalk are Immutable. I alse added the header to the message which will be passed to the Server.
6. Add a send shape, and set the Message property to Message_2.
7. Add a port to the Orchestration and set the port type to the existing port type which is created automatically while consuming the Service.
8. Join the Send shape with the receive port of Service. Resulting orchestration should be like below
9. Add a receive shape and set the Message Property to Message_3 and connect the Response port of the Service with the Send shape.
10. Create a string variable and add an expression shape to extract the Headers that the service sent using the property
Variable_1 = Message_3(WCF.InboundHeaders);
System.Diagnostics.EventLog.WriteEntry("InBound Headers", "Received InBound Headers: " + Variable_1);
11. Now add a Send Shape, Receive and Send ports and complete the Orchestration
12. Deploy the Service and place the below file in the input folder.
Note: Input will vary depending on the Logic you use.
13. In the event log, it should display two events.
14. One will be created by the service (Step 1) after it received the inbound header) and One will be Created by the Client Orchestration after it receives the header from the service. (Step 10).
Hope it is helpful. Mail me if you need the source code.
- Shiv
In this post I will show you how to Send and Receive data through Custom Headers from a WCF Service.
Solution:
Scenario:
Orchestration adds Header and Sends to the Service -> Service Receives the Header and writes to EventLog -> Service adds and outbound header and sends back to Orchestration -> Orchestration Receives the Header
1. Create a Sample WCF Service that gets the value from the Incoming Message and adds an outbound header to the outgoing message. Sample code is given below.
public string GetHeaderValue(string HeaderName, string URI)
{
// Receive Inbound Header
string val = OperationContext.Current.IncomingMessageHeaders.GetHeader(HeaderName, URI);
EventLog.WriteEntry("Received Header", "Header Value: " + val);
// Send Outbound Header
MessageHeader header = MessageHeader.CreateHeader("Test","Test.com","TestValue");
OperationContext.Current.OutgoingMessageHeaders.Add(header);
return val;
}
2. Deploy the Service and Consume it in a BizTalk Project. It creates input message schema, orchestration, output message schema, port type and Binding Files.
3. Create 3 Message as shown below in the Orchestration.
Let Message_1 and Message_2 represent Input Message Schema and Message_3 represent Output message Schema
4. Create a Receive Shape, set the Message property to Message_1, activate to True
5. Add a Construct messsage shape, set the Message Constructed property to Message_2. We pass header message to the Service by using the property (WCF.OutboundCustomHeaders). Add the following code in the Message Assignment shape.
Message_2 = Message_1;
Message_2(WCF.OutboundCustomHeaders) = @"From Clietn";
Resulting Orchestration should be like below
Note: In this step, I created a new message Message_2 (same schema as Message_1) rather than editing a Message_1 because, messages in BizTalk are Immutable. I alse added the header to the message which will be passed to the Server.
6. Add a send shape, and set the Message property to Message_2.
7. Add a port to the Orchestration and set the port type to the existing port type which is created automatically while consuming the Service.
8. Join the Send shape with the receive port of Service. Resulting orchestration should be like below
9. Add a receive shape and set the Message Property to Message_3 and connect the Response port of the Service with the Send shape.
10. Create a string variable and add an expression shape to extract the Headers that the service sent using the property
Variable_1 = Message_3(WCF.InboundHeaders);
System.Diagnostics.EventLog.WriteEntry("InBound Headers", "Received InBound Headers: " + Variable_1);
11. Now add a Send Shape, Receive and Send ports and complete the Orchestration
12. Deploy the Service and place the below file in the input folder.
<ns0:GetHeaderValue xmlns:ns0="http://tempuri.org/">
<ns0:HeaderName>FromClient</ns0:HeaderName>
<ns0:URI>FromClient.com</ns0:URI>
</ns0:GetHeaderValue>
Note: Input will vary depending on the Logic you use.
13. In the event log, it should display two events.
14. One will be created by the service (Step 1) after it received the inbound header) and One will be Created by the Client Orchestration after it receives the header from the service. (Step 10).
Hope it is helpful. Mail me if you need the source code.
- Shiv
Tuesday, 23 November 2010
Splitting XML Files using Envelope Schema
Envelope Schema is a special type of schema used in BizTalk Server that is used to represent more than one XML messages embedded in it.
You can use Envelope schema to Split up a Batch XML into individual Files or Split up an XML file that has more that one Embedded XML files into individual Files. This is show below.
Eg: Input – Batch XML File
Eg: Input – Has two types of XML Files
Output – Two separate xml files
and
Solution:
- Shiv
You can use Envelope schema to Split up a Batch XML into individual Files or Split up an XML file that has more that one Embedded XML files into individual Files. This is show below.
- Split up a Batch XML into Individual XML files.
Eg: Input – Batch XML File
<Items>
<Item>
<ID>1</ID>
</Item>
<Item>
<ID>2</ID>
</Item>
</Items>
Output - two Individual XML Files
<Item>
<ID>1</ID>
</Item>
and
<Item>
<ID>2</ID>
</Item>
- Split up an XML file that has more than one Embedded XML files into individual Files
Eg: Input – Has two types of XML Files
<Items>
<Item1>
<ID1>1</ID1>
</Item1>
<Item2>
<ID2>2</ID2>
</Item2>
</Items>
Output – Two separate xml files
<Item1>
<ID1>1</ID1>
</Item1>
and
<Item2>
<ID2>2</ID2>
</Item2>
Solution:
- Create a new BizTalk Server Project and two Schemas – Schema1 & Schema2 as shown below
- Create a new Schema Schema3 and rename the Root Node to Envelope or some thing else
- Scheme and Go to Properties and make Envelope property to Yes
- Now select the Root Node Envelope and Go to Properties. Click on the Ellipses next to Body XPath and Select the Root Node itself. ( Here you are specifying that the Body of the Envelope starts with the Root Node itself)
- Deploy the Application
- Create One File Receive Port and 2 File Send Ports. Use XML Receive pipeline for Receive Port and pass through pipeline for the send ports.
- Since we are not using any orchestrations for receiving/routing the separated individual XML files, we have to set the Filter properties of Both the send ports to Subscribe for the individual XML files as given below.
- Create an Envelope XML file which has Embedded XML files of Schema1 & Schema2
- Drop the above XML in the Receive Folder. Very soon it will be split up into 2 separate XML Files
- These two will be stored in the two folders specified in the Send Ports
For Send Port1 - BTS.MessageType == http://BizTalk_Server_Project2.Schema1#Root1
For Send Port2 - BTS.MessageType == http://BizTalk_Server_Project2.Schema2#Root2
Note: Change the Values according to your project, schema and Root Names. It should be in the format TargetNamespace+#+RootName
<ns0:Envelope xmlns:ns0="http://BizTalk_Server_Project2.Schema3">
<ns1:Root1 xmlns:ns1="http://BizTalk_Server_Project2.Schema1">
<Field1>Field1_0</Field1>
</ns1:Root1>
<ns2:Root2 xmlns:ns2="http://BizTalk_Server_Project2.Schema2">
<Field2>Field2_0</Field2>
</ns2:Root2>
</ns0:Envelope>
<ns1:Root1 xmlns:ns1="http://BizTalk_Server_Project2.Schema1">
<Field1>Field1_0</Field1>
</ns1:Root1>
and
<ns2:Root2 xmlns:ns2="http://BizTalk_Server_Project2.Schema2">
<Field2>Field2_0</Field2>
</ns2:Root2>
- Shiv
Issue: Unable to add parameters in Call Rules Shape
I created my first BRS Rule (using XSD) in BizTalk Server Business Rules Composer and deployed it.
When I tried to call this rule from Call Rules shape of an Orchestration, it didn’t give my any option to add an input parameter to the Rules
After browsing for some time, I find that it happened because, the Document Type Property for the Schema in the Facts Explorer (shown above) is different from the Fully Qualified name of the Actual Schema in the BizTalk Project
So, I modified Document Type Property of the Schema in the Business Rules Composer to the Fully Qualified Name as in the BizTalk Server Project as shown below
Then the parameter is shown in the Call Rules Shape
Result:
The issue is that, in the beginning, Call Rules shape was not able to find any matching Message to the Schema which is deployed with the Rule.
Since I modified the schema in BRE with the Fully Qualified Name of the BizTalk solution, it found a matching message and displayed in the Call Rules Shape.
Hope it is useful..
- Shiv
When I tried to call this rule from Call Rules shape of an Orchestration, it didn’t give my any option to add an input parameter to the Rules
After browsing for some time, I find that it happened because, the Document Type Property for the Schema in the Facts Explorer (shown above) is different from the Fully Qualified name of the Actual Schema in the BizTalk Project
So, I modified Document Type Property of the Schema in the Business Rules Composer to the Fully Qualified Name as in the BizTalk Server Project as shown below
Then the parameter is shown in the Call Rules Shape
Result:
The issue is that, in the beginning, Call Rules shape was not able to find any matching Message to the Schema which is deployed with the Rule.
Since I modified the schema in BRE with the Fully Qualified Name of the BizTalk solution, it found a matching message and displayed in the Call Rules Shape.
Hope it is useful..
- Shiv
Sunday, 21 November 2010
Auto Mapping feature in BizTalk Mapper
Many of us are not aware that BizTalk Mapper can map the Source Fields to Destination Fields automatically.
There are two options available for Auto Linking.
1. Structure
2. Node Name
This can be seen by clicking on the Grid between the Source and Destination schemas and opening the properties.
Auto Link by Structure:
This will map source fields with destination fields one by one (structure wise) without looking for the name of the node.
This can be achieved by holding SHIFT Key and dragging from the source Root node to the destination Root node
Auto Link by Node Name:
This will map the Source node to the matching destination node.
This can also be achieved by setting AutoLink By Property to Node Name and holding SHIFT Key and dragging from the source Root node to the destination Root node
- Shiv
There are two options available for Auto Linking.
1. Structure
2. Node Name
This can be seen by clicking on the Grid between the Source and Destination schemas and opening the properties.
Auto Link by Structure:
This will map source fields with destination fields one by one (structure wise) without looking for the name of the node.
This can be achieved by holding SHIFT Key and dragging from the source Root node to the destination Root node
Auto Link by Node Name:
This will map the Source node to the matching destination node.
This can also be achieved by setting AutoLink By Property to Node Name and holding SHIFT Key and dragging from the source Root node to the destination Root node
- Shiv
Catching SOAP Faults from WCF Service in BizTalk Orchestration
This Link has the Structure of Soap Version 1.1 & 1.2 Fault Message
This post will show how to Catch a Soap Fault returned by a WCF Service in a BizTalk Orchestration.
Note: Message_3 should be of Soap_Fault type as selected in Step 4.
- Shiv
This post will show how to Catch a Soap Fault returned by a WCF Service in a BizTalk Orchestration.
- Consume a WCF Service and Implement the Logic for Sending the Request and Receiving the Response from the WCF Service.
- Right Click on the PortType and Select New Fault Message as shown below.
- A new fault port will then be created as shown below
- Now set the Message Type to either Soap Fault 1.1 or 1.2 as shown below
- Add a scope block to the Orchestration, set the transaction type to None and an Exception handler
- Give any Valid Name to the Object Name and Set Object Type to Fault_1
- Keep a Message Assignment shape in the Exception Handler and assign the captured fault to another Message
- Handle the Message as required
Note: Message_3 should be of Soap_Fault type as selected in Step 4.
- Shiv
Using BizTalk Server Config File
Assume that you have a Class Library where all the commonly used functions are written and compiled.
If that class library uses any keys from an app.config file, how will you add those keys in BizTalk Server Runtime?
Answer is very simple.
BizTalk Server too has a config file which will be access during runtime.
So, if you use any external library in any orchestration and if that External Library needs any key values from Config file, all those key value pairs should be copied to the BizTalk Server Config file for the Orchestration to run properly.
BizTalk Server config file can be found the below location.
32 Bit:
C:\Program Files (x86)\Microsoft BizTalk Server 2009\BTSNTSvc.exe.config
64 Bit:
C:\Program Files (x86)\Microsoft BizTalk Server 2009\BTSNTSvc64.exe.config
So, next time if your external library is using any config file, make sure that all those keys are also there in BizTalk Server Config file.
Note: Once the config file is updated, host instance should be restarted to reflect the values.
- Shiv
If that class library uses any keys from an app.config file, how will you add those keys in BizTalk Server Runtime?
Answer is very simple.
BizTalk Server too has a config file which will be access during runtime.
So, if you use any external library in any orchestration and if that External Library needs any key values from Config file, all those key value pairs should be copied to the BizTalk Server Config file for the Orchestration to run properly.
BizTalk Server config file can be found the below location.
32 Bit:
C:\Program Files (x86)\Microsoft BizTalk Server 2009\BTSNTSvc.exe.config
64 Bit:
C:\Program Files (x86)\Microsoft BizTalk Server 2009\BTSNTSvc64.exe.config
So, next time if your external library is using any config file, make sure that all those keys are also there in BizTalk Server Config file.
Note: Once the config file is updated, host instance should be restarted to reflect the values.
- Shiv
Thursday, 11 November 2010
Cross Reference Functoids in BizTalk Server
While using BizTalk server for Integration of Applications, we may face a situation where a Value - for Eg: A status of "Pending" - in Application1 may have to be mapped to an equivalent and different value in Application2.
Literally, you may receive a message in which Status is "Pending" and assume you may have to map this to a status call "On Hold" to an outgoing message.
How can we achieve this??
There are many possible ways.
1. Write an inline script / xslt in a Scripting Functoid
2. Use an External dll that takes an input and returns an equivalent output
3. Use of BizTalk Server Cross Reference Functoids.
4. Custom Functoids and Lots of more options....
This article will describe the use of BizTalk Server Cross Reference.
Problem:
Assume that you input message status has to be mapped to an output message status in the following way.
Input Status (Application1 Message) --> Output Status (Applicaiton2 Message)--> Common Value which we use to Represent both of them
1. Approved --> Accepted --> Accept
2. Pending --> On Hold --> Hold
3. Denied --> Stopped --> Deny
Approach:
The idea behind the Cross Reference is Simple.
a) You create XML Files that represent the Cross Reference Data.
b) These XML files (data) are imported to a set of Tables inside BizTalk Management Database using a Cross Reference Utility
There are 2 types of Cross Reference - ID Cross Reference and Value Cross Reference.
The purpose of both of them will be same and the way they operate internally will be different.
c) From the input message, if you receive the status as "Approved" use this status "Approved" and the Application Source as "Application1" and find the Common Value "Accept"
(This is done using Get Common Value / Get Common Id Functoids)
d) Use the Common Value as "Accept" and use the Application Name as "Application2" and find the key word "Accepted" which is mapped to Application2
(This is done using Get Application Value / Get Application Id Functoids)
Solution:
Hope this gives an Idea. So lets start working on the above 4 points.
Using ID Cross Referencing.
a) create XML Files that represent the Cross Reference Data.
Below are the XML Files Required for ID Cross Referencing.
SetUp-Files Document- Download the Sample here
listOfAppType Document- Download the Sample here
listOfAppInstance Document- Download the Sample here
listOfIDXRef Document - Download the Sample here
listOfIDXRefData Document - Download the Sample here
Purpose of the above XML Files:
SetUp-Files - This will have the path to all other files
listOfAppType - This will have the list of applications. In our case it is "Application1" and "Application2"
listOfAppInstance - For each Application created, an instance should be created
listOfIDXRef - This XML file will hold the IDs for which we create Data. In our case it is the "Status"
listOfIDXRefData - This file will hold the data for Common value, "Application1" data and "Application2" Data
b) Modify the above XML files.
SetUp-Files:
Create a folder named IDXref in C Drive and copy all the XML files to that location. The name of the XML files that you mention in the Setup file should match the physical name of the XML Files.
Update the Setup-File like below.
listOfAppType - Here we have 2 applications "Application1" & "Application2"
listOfAppInstance - Here create an Instance for each of the 2 applications.
listOfIDXRef - Here we create IDs for each of the cross referencing we do.
listOfIDXRefData - Here we define the data for both "Application1" & "Application2"
c) Now you have all the data that you need for your ID cross Reference. Now deploy these data to the BizTalk Management Database.
Give the following Command in your command prompt c:\IDXref\.
btsxrefimport –file=setupfile
Note: Your current prompt should be pointing to the path c:\IDXref\. The name of the setup file should be setupfile.xml
Now log into the BizTalk Management Database, check the below tables.
xref_AppType, xref_AppInstance ,xref_IDXRef ,xref_IDXRefData.
These tables would have been updated with the data that you imported.
d) Using the Cross Reference in your MAP.
From the Tool box drop the Get Common ID Functoid and connect the Status field from your source schema to it.
Double Click the Get Common ID Functoid and add 2 more inputs as shown below
First Input – ID which you added in listOfIDXRef XML file.
Second Input – Application Instance from which the input is coming.
Third Input – Actual value which should be converted.
The output of this Functoid will be our common values. Eg: Accept, Deny, Hold based on the input.
Now drop the Get Application ID Functoid and connect the output of Get Common ID Functoid to this one.
Configure the Get Application ID Functoid Inputs as shown below.
First Input – ID which you added in listOfIDXRef XML file.
Second Input – Application Instance to which the input is to be converted.
Third Input – Common value from the Get Common ID Functoid.
The Output of this Functoid will be the equivalent Application2 value for the Application1 Input.
Using Value Cross Referencing:
Value cross Reference is used in the same way as ID Cross Reference. The only change is the Input to the Get Common Value and Get Application Value Functoids.
However there is a difference in which these two operate internally.
a) Create XML Files that represent the Cross Reference Data.
Below are the XML files required for Value Cross Referencing.
SetUp-Files Document- Download the Sample here
listOfAppType Document- Download the Sample here
listOfAppInstance Document- Download the Sample here
listOfValueXRef Document - Download the Sample here
listOfValueXRefData Document - Download the Sample here
Purpose of the above XML Files:
SetUp-Files - This will have the path to all other files
listOfAppType - This will have the list of applications. In our case it is "Application1" and "Application2"
listOfAppInstance - For each Application created, an instance should be created
listOfValueXRef - This XML file will hold the IDs for which we create Data. In our case it is the "Status"
listOfValueXRefData - This file will hold the data for Common value, "Application1" data and "Application2" Data
b) Modify the above XML files.
SetUp-Files:
Create a folder named ValueXref in C Drive and copy all the XML files to that location. The name of the XML files that you mention in the Setup file
should match the physical name of the XML Files.
Update the Setup-File like below.
listOfAppType - Here we have 2 applications "Application1" & "Application2"
listOfAppInstance - Here create an Instance for each of the 2 applications.
listOfValueXref - Here we create IDs for each of the cross referencing we do.
listOfValueXrefData - Here we define the data for both "Application1" & "Application2"
Note: While defining this XML, Application name is used. Whereas in IDXref Application Instance is used.
c) Now you have all the data that you need for your ID cross Reference. Now deploy these data to the BizTalk Management Database.
Give the following Command in your command prompt c:\ValueXref\.
btsxrefimport –file=setupfile
Note: Your current prompt should be pointing to the path c:\ValueXref\. The name of the setup file should be setupfile.xml
Now log into the BizTalk Management Database, check the below tables.
xref_AppType, xref_AppInstance ,xref_ValueXref ,xref_ValueXrefData.
These tables would have been updated with the data that you imported.
d) Using the Cross Reference in your MAP.
From the Tool box drop the Get Common Value Functoid and connect the Status field from your source schema to it.
Double Click the Get Common Value Functoid and add 2 more inputs as shown below
First Input – ID which you added in listOfValueXRef XML file.
Second Input – Application Name (not Instance) from which the input is coming.
Third Input – Actual value which should be converted.
The output of this Functoid will be our common values. Eg: Accept, Deny, Hold based on the input.
Now drop the Get Application Value Functoid and connect the output of Get Common Value Functoid to this one.
Configure the Get Application Value Functoid Inputs as shown below.
First Input – ID which you added in listOfValueXRef XML file.
Second Input – Application Name (Not Instance name) to which the input is to be converted.
Third Input – Common value from the Get Common Value Functoid.
The Output of this Functoid will be the equivalent Application2 value for the Application1 Input.
- Shiv
Literally, you may receive a message in which Status is "Pending" and assume you may have to map this to a status call "On Hold" to an outgoing message.
How can we achieve this??
There are many possible ways.
1. Write an inline script / xslt in a Scripting Functoid
2. Use an External dll that takes an input and returns an equivalent output
3. Use of BizTalk Server Cross Reference Functoids.
4. Custom Functoids and Lots of more options....
This article will describe the use of BizTalk Server Cross Reference.
Problem:
Assume that you input message status has to be mapped to an output message status in the following way.
Input Status (Application1 Message) --> Output Status (Applicaiton2 Message)--> Common Value which we use to Represent both of them
1. Approved --> Accepted --> Accept
2. Pending --> On Hold --> Hold
3. Denied --> Stopped --> Deny
Approach:
The idea behind the Cross Reference is Simple.
a) You create XML Files that represent the Cross Reference Data.
b) These XML files (data) are imported to a set of Tables inside BizTalk Management Database using a Cross Reference Utility
There are 2 types of Cross Reference - ID Cross Reference and Value Cross Reference.
The purpose of both of them will be same and the way they operate internally will be different.
c) From the input message, if you receive the status as "Approved" use this status "Approved" and the Application Source as "Application1" and find the Common Value "Accept"
(This is done using Get Common Value / Get Common Id Functoids)
d) Use the Common Value as "Accept" and use the Application Name as "Application2" and find the key word "Accepted" which is mapped to Application2
(This is done using Get Application Value / Get Application Id Functoids)
Solution:
Hope this gives an Idea. So lets start working on the above 4 points.
Using ID Cross Referencing.
a) create XML Files that represent the Cross Reference Data.
Below are the XML Files Required for ID Cross Referencing.
SetUp-Files Document- Download the Sample here
listOfAppType Document- Download the Sample here
listOfAppInstance Document- Download the Sample here
listOfIDXRef Document - Download the Sample here
listOfIDXRefData Document - Download the Sample here
Purpose of the above XML Files:
SetUp-Files - This will have the path to all other files
listOfAppType - This will have the list of applications. In our case it is "Application1" and "Application2"
listOfAppInstance - For each Application created, an instance should be created
listOfIDXRef - This XML file will hold the IDs for which we create Data. In our case it is the "Status"
listOfIDXRefData - This file will hold the data for Common value, "Application1" data and "Application2" Data
b) Modify the above XML files.
SetUp-Files:
Create a folder named IDXref in C Drive and copy all the XML files to that location. The name of the XML files that you mention in the Setup file should match the physical name of the XML Files.
Update the Setup-File like below.
<?xml version="1.0" encoding="UTF-8" ?>
<Setup-Files>
<App_Type_file>c:\IDXref\ListOfAppType.xml</App_Type_file>
<App_Instance_file>c:\IDXref\ListOfAppInstance.xml</App_Instance_file>
<IDXRef_file>c:\IDXref\ListOfIDXRef.xml</IDXRef_file>
<IDXRef_Data_file>c:\IDXref\ListOfIDXRefData.xml</IDXRef_Data_file>
</Setup-Files>
listOfAppType - Here we have 2 applications "Application1" & "Application2"
<?xml version="1.0" encoding="UTF-8" ?>
<listOfAppType>
<appType>
<name>Application1</name>
</appType>
<appType>
<name>Application2</name>
</appType>
</listOfAppType>
listOfAppInstance - Here create an Instance for each of the 2 applications.
<?xml version="1.0" encoding="UTF-8" ?>
<listOfAppInstance>
<appInstance>
<instance>Application1Instance</instance>
<type>Application1</type>
</appInstance>
<appInstance>
<instance>Application2Instance</instance>
<type>Application2</type>
</appInstance>
</listOfAppInstance>
listOfIDXRef - Here we create IDs for each of the cross referencing we do.
<?xml version="1.0" encoding="UTF-8" ?>
<listOfIDXRef>
<idXRef>
<name>Status</name>
</idXRef>
</listOfIDXRef>
listOfIDXRefData - Here we define the data for both "Application1" & "Application2"
<listOfIDXRefData>
<idXRef name="Status">
<appInstance name="Application1Instance">
<appID commonID="Accept">Approved</appID>
<appID commonID="Hold">Pending</appID>
<appID commonID="Deny">Denied</appID>
</appInstance>
<appInstance name="Application2Instance">
<appID commonID="Accept">Accepted</appID>
<appID commonID="Hold">On Hold</appID>
<appID commonID="Deny">Stopped</appID>
</appInstance>
</idXRef>
</listOfIDXRefData>
c) Now you have all the data that you need for your ID cross Reference. Now deploy these data to the BizTalk Management Database.
Give the following Command in your command prompt c:\IDXref\.
btsxrefimport –file=setupfile
Note: Your current prompt should be pointing to the path c:\IDXref\. The name of the setup file should be setupfile.xml
Now log into the BizTalk Management Database, check the below tables.
xref_AppType, xref_AppInstance ,xref_IDXRef ,xref_IDXRefData.
These tables would have been updated with the data that you imported.
d) Using the Cross Reference in your MAP.
From the Tool box drop the Get Common ID Functoid and connect the Status field from your source schema to it.
Double Click the Get Common ID Functoid and add 2 more inputs as shown below
First Input – ID which you added in listOfIDXRef XML file.
Second Input – Application Instance from which the input is coming.
Third Input – Actual value which should be converted.
The output of this Functoid will be our common values. Eg: Accept, Deny, Hold based on the input.
Now drop the Get Application ID Functoid and connect the output of Get Common ID Functoid to this one.
Configure the Get Application ID Functoid Inputs as shown below.
First Input – ID which you added in listOfIDXRef XML file.
Second Input – Application Instance to which the input is to be converted.
Third Input – Common value from the Get Common ID Functoid.
The Output of this Functoid will be the equivalent Application2 value for the Application1 Input.
Using Value Cross Referencing:
Value cross Reference is used in the same way as ID Cross Reference. The only change is the Input to the Get Common Value and Get Application Value Functoids.
However there is a difference in which these two operate internally.
a) Create XML Files that represent the Cross Reference Data.
Below are the XML files required for Value Cross Referencing.
SetUp-Files Document- Download the Sample here
listOfAppType Document- Download the Sample here
listOfAppInstance Document- Download the Sample here
listOfValueXRef Document - Download the Sample here
listOfValueXRefData Document - Download the Sample here
Purpose of the above XML Files:
SetUp-Files - This will have the path to all other files
listOfAppType - This will have the list of applications. In our case it is "Application1" and "Application2"
listOfAppInstance - For each Application created, an instance should be created
listOfValueXRef - This XML file will hold the IDs for which we create Data. In our case it is the "Status"
listOfValueXRefData - This file will hold the data for Common value, "Application1" data and "Application2" Data
b) Modify the above XML files.
SetUp-Files:
Create a folder named ValueXref in C Drive and copy all the XML files to that location. The name of the XML files that you mention in the Setup file
should match the physical name of the XML Files.
Update the Setup-File like below.
<?xml version="1.0" encoding="UTF-8" ?>
<Setup-Files>
<App_Type_file>c:\ValueXref\ListOfAppType.xml</App_Type_file>
<App_Instance_file>c:\ValueXref\ListOfAppInstance.xml</App_Instance_file>
<ValueXref_file>c:\ValueXref\ListOfValueXref.xml</ValueXref_file>
<ValueXref_Data_file>c:\ValueXref\ListOfValueXrefData.xml</ValueXref_Data_file>
</Setup-Files>
listOfAppType - Here we have 2 applications "Application1" & "Application2"
<?xml version="1.0" encoding="UTF-8" ?>
<listOfAppType>
<appType>
<name>Application1</name>
</appType>
<appType>
<name>Application2</name>
</appType>
</listOfAppType>
listOfAppInstance - Here create an Instance for each of the 2 applications.
<?xml version="1.0" encoding="UTF-8" ?>
<listOfAppInstance>
<appInstance>
<instance>Application1Instance</instance>
<type>Application1</type>
</appInstance>
<appInstance>
<instance>Application2Instance</instance>
<type>Application2</type>
</appInstance>
</listOfAppInstance>
listOfValueXref - Here we create IDs for each of the cross referencing we do.
<?xml version="1.0" encoding="UTF-8" ?>
<listOfValueXRef>
<valueXRef>
<name>Status</name>
</valueXRef>
</listOfValueXRef>
listOfValueXrefData - Here we define the data for both "Application1" & "Application2"
<?xml version="1.0" encoding="UTF-8" ?>
<listOfValueXRefData>
<valueXRef name="Status">
<appType name="Application1">
<appValue commonValue="Accept">Approved</appValue>
<appValue commonValue="Hold">Pending</appValue>
<appValue commonValue="Deny">Denied</appValue>
</appType>
<appType name="Application2">
<appValue commonValue="Accept">Accepted</appValue>
<appValue commonValue="Hold">On Hold</appValue>
<appValue commonValue="Deny">Stopped</appValue>
</appType>
</valueXRef>
</listOfValueXRefData>
Note: While defining this XML, Application name is used. Whereas in IDXref Application Instance is used.
c) Now you have all the data that you need for your ID cross Reference. Now deploy these data to the BizTalk Management Database.
Give the following Command in your command prompt c:\ValueXref\.
btsxrefimport –file=setupfile
Note: Your current prompt should be pointing to the path c:\ValueXref\. The name of the setup file should be setupfile.xml
Now log into the BizTalk Management Database, check the below tables.
xref_AppType, xref_AppInstance ,xref_ValueXref ,xref_ValueXrefData.
These tables would have been updated with the data that you imported.
d) Using the Cross Reference in your MAP.
From the Tool box drop the Get Common Value Functoid and connect the Status field from your source schema to it.
Double Click the Get Common Value Functoid and add 2 more inputs as shown below
First Input – ID which you added in listOfValueXRef XML file.
Second Input – Application Name (not Instance) from which the input is coming.
Third Input – Actual value which should be converted.
The output of this Functoid will be our common values. Eg: Accept, Deny, Hold based on the input.
Now drop the Get Application Value Functoid and connect the output of Get Common Value Functoid to this one.
Configure the Get Application Value Functoid Inputs as shown below.
First Input – ID which you added in listOfValueXRef XML file.
Second Input – Application Name (Not Instance name) to which the input is to be converted.
Third Input – Common value from the Get Common Value Functoid.
The Output of this Functoid will be the equivalent Application2 value for the Application1 Input.
- Shiv
Subscribe to:
Posts (Atom)