We occasionally have the need to generate a zero byte file, usually as a trigger file. The File Receive Adapter will “helpfully” delete any zero byte files given to it and write a warning to the event log.

The basic solution is to create a new flat-file schema with a single element node. Set the “Generate Instance Type” to “XML”, generate the instance, ctrl-click in the results to view the XML, and right-click to select “View Source”. Copy the XML as the parameter of a LoadXML method call on an XMLDocument object in an Expression shape. (You’ll probably have to escape the quotation marks for the namespace, although you could also opt to use single quotes or declare the schema without a namespace — neither of which I recommend.) In a subsequent Assign Message shape, you assign this XMLDocument as your message. You’ll also need to create a custom pipeline with a Flat-File Assembler component. Your single node schema is your document body. Now, when you send this message through the port with the custom flat-file assembler pipeline, it will output a zero byte file. This works for the file adapter and a popular third-party set of adapters.

Imagine my surprise, however, when it did not work for the built-in Microsoft FTP adapter! Worse, after the process appeared to “hang” during transmission, if left long enough, the process showed a “Completed” status! We had a delivery notification on the port and got no error. We also had logging configured for the port; no log was written. When I switched to a third-party FTP adapter, the process worked correctly. If I find out why this happened, I’ll post. If you know why, don’t be shy. I’d love to hear it.