Tuesday, February 5, 2008

Creating an 0kb File

For a project I needed to create an XML file and also a 0kb Control file.
This 0Kb file is needed for the external software to know for sure when the Xml file is created. Only when the 0Kb file is available, the external software will read the Xml file.
This situation is still frequently used in the environment I work (Mainframe, old VB6,….)
A Some Microsoft consultant told us to create an custom pipeline and did some custom coding.

How to create an 0Kb file with BizTalk without creating a custom pipeline with custom code.

Create a Flat File Schema, called CrtFile

Set the following schema parameter:
Default Child Delimiter Type: none
Default Escape Character Type: none
Default Pad Character Type: none
Default repeating Delimiter Character Type: none
Default Wrap Character Type: none

Set the following properties on the root node:
Child Delimited Type : none
Child Order: infix
Escape Character Type: none
Nillable: true
Preserve Delimiter for Empty Data: No
Suppress Trailing Delimters: No

Create a Flat File Send Pipeline
Add the Flat File assembler to the Assemble Block.

In the Orchestration,
Add a message assign shape and add the following code

//-- Initialize the CrtFile Variable --
tempXmlDoc = new System.Xml.XmlDocument();
tempXmlDoc.LoadXml("<?xml:namespace prefix = ns0 /><ns0:root ns0="http://My0kbProject.Schemas.CrtFile"></ns0:root>");

zeroKbMsg = tempXmlDoc;

When sending the zeroKbMsg to the File Adapter, using the FlatFileSendPipeline, you will have an 0kb file created.

No comments: