Biztalk: How to save all original incoming Streams/Files to an archive folder.
Hello,
i need to save all incoming streams/files (EDI, JSON, XML etc) as .txt files into an archive Folder before it is converted to xml by the biztalk server.
A custom pipeline component does not seem to be the recommended solution for this.
Is there any Solution considered as the best for this purpose?
yes, i have to do it in Biztalk. I have strict orders to not use another application or script for this.
this is what i've done in the Execute Method of my custom Pipeline Component:
(The Method Copy2Archive is just a simple string to file procedure and the Variable CustomPath is an object inside the IpropertyBag which lets you define a custom archivefolder for every port.)
public IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg)
{
if (pInMsg.BodyPart != null)
{
MemoryStream copyStream = new MemoryStream();
long positionOfOriginalStream = pInMsg.BodyPart.GetOriginalDataStream().Position;
pInMsg.BodyPart.GetOriginalDataStream().CopyTo(copyStream);
pInMsg.BodyPart.GetOriginalDataStream().Position = positionOfOriginalStream;
byte[] input = new byte[copyStream.Length];
copyStream.Read(input, 0, (Int32)copyStream.Length);
string basestring = Encoding.UTF8.GetString(input);
Copy2Archive(basestring, CustomPath.ToString());
copyStream.Close();
}
return pInMsg;
}