Reputation: 9599
I am using the BizTalk flat file schema to process CSV files. My schema essentially looks like this:
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://My.Namespace.For.Schema" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://My.Namespace.For.Schema" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:annotation>
<xs:appinfo>
<schemaEditorExtension:schemaInfo namespaceAlias="b" extensionClass="Microsoft.BizTalk.FlatFileExtension.FlatFileExtension" standardName="Flat File" xmlns:schemaEditorExtension="http://schemas.microsoft.com/BizTalk/2003/SchemaEditorExtensions" />
<b:schemaInfo standard="Flat File" codepage="65001" default_pad_char=" " pad_char_type="char" count_positions_by_byte="false" parser_optimization="speed" lookahead_depth="3" suppress_empty_nodes="false" generate_empty_nodes="true" allow_early_termination="false" early_terminate_optional_fields="false" allow_message_breakup_of_infix_root="false" compile_parse_tables="false" root_reference="MyFile" />
</xs:appinfo>
</xs:annotation>
<xs:element name="MyFile">
<xs:annotation>
<xs:appinfo>
<b:recordInfo structure="delimited" child_delimiter_type="hex" child_delimiter="0x0D 0x0A" child_order="postfix" sequence_number="1" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" rootTypeName="MyFile" />
</xs:appinfo>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:annotation>
<xs:appinfo>
<groupInfo sequence_number="0" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
</xs:appinfo>
</xs:annotation>
<xs:element maxOccurs="unbounded" name="MasEdiAuditRecord">
<xs:annotation>
<xs:appinfo>
<b:recordInfo structure="delimited" child_delimiter_type="char" child_delimiter="," child_order="infix" sequence_number="1" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" />
</xs:appinfo>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:annotation>
<xs:appinfo>
<groupInfo sequence_number="0" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
</xs:appinfo>
</xs:annotation>
<xs:element name="SomeField" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="1" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="SomeOtherField" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="2" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<!-- And a whole bunch more fields -->
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
This works fine when the file actually contains CSV records. However, I sometimes receive blank files, and I need those to still be parsed (and eventually kick off an orchestration. So, I would like a blank CSV file to produce something like:
<ns0:MyFile xmlns:ns0="http://My.Namespace.For.Schema">
</ns0:MyFile>
But from what I can tell, when the receive port gets a blank file, the receive pipeline kicks in, and then nothing else happens downstream. I assume this is because the flat file schema is producing an empty message and then BizTalk is stopping at that point.
How do I make the flat file schema still produce an XML record with no child records when a blank file is received?
Upvotes: 3
Views: 1772
Reputation: 9599
What I ended up doing was changing the process so that the header record is not removed in the receive pipeline. Therefore, there is never a "blank" message, just a message that contains only the header record. Then, I filter out the header record in the mapping that kicks off the orchestration, using Filtering records using Maps and conditional looping.
Upvotes: 1
Reputation: 10274
You might be able to write a custom pipeline component to handle this scenario: a component that checks out the inbound message and, if empty, creates some kind of a message with nothing but whitespace in it. That might work.
There is a decent example of creating a custom pipeline component here.
Upvotes: 3