Home Page › Forums › BizTalk 2004 – BizTalk 2010 › Zip pipeline component
- This topic has 1 reply, 1 voice, and was last updated 9 years, 7 months ago by
community-content.
-
AuthorPosts
-
-
June 4, 2008 at 11:19 AM #19849
Hello,
I am new to pipeline component development. I am developing a component to zip the incoming message. The message gets zipped properly as i intercept and write the zippedmemorystream data to a file and i can see the zipped file C:\\My.zip.
However i need to return the zipped message back and i expect the message to come to the FTP Folder set up thro the send port. I see the file with zero bytes. I think the issue is with assigning back the zipped stream to the IBaseMessage. ie.. the last 2 lines
messageIn.BodyPart.Data = zipMemoryStream;
return messageIn;
Any help is appreciated.
Thanks.
NReddy
public IBaseMessage Execute(IPipelineContext pc, IBaseMessage messageIn)
{
try
{
//get msg into a stream
Stream originalStream = messageIn.BodyPart.GetOriginalDataStream();//convert stream to a string
StreamReader sr = new StreamReader(originalStream);
string strConverted = sr.ReadToEnd();System.IO.MemoryStream zipMemoryStream = new System.IO.MemoryStream();
ICSharpCode.SharpZipLib.Zip.ZipOutputStream MyZipStream = new ICSharpCode.SharpZipLib.Zip.ZipOutputStream(zipMemoryStream);
MyZipStream.SetLevel(5);
byte[] buffer = Encoding.UTF8.GetBytes(strConverted);// Zip the file
ICSharpCode.SharpZipLib.Checksums.Crc32 objCrc32 = new ICSharpCode.SharpZipLib.Checksums.Crc32();
ICSharpCode.SharpZipLib.Zip.ZipEntry entry = new ICSharpCode.SharpZipLib.Zip.ZipEntry(“Image.txt”);
entry.DateTime = DateTime.Now;
entry.Size = buffer.Length;
objCrc32.Reset();
objCrc32.Update(buffer);
entry.Crc = objCrc32.Value;MyZipStream.PutNextEntry(entry);
MyZipStream.Write(buffer, 0, buffer.Length);
MyZipStream.Finish();FileStream outStream = File.OpenWrite(“C:\\My.zip”);
zipMemoryStream.WriteTo(outStream);
outStream.Flush();
outStream.Close();messageIn.BodyPart.Data = zipMemoryStream;
return messageIn;
}
catch (Exception ex)
{
ex.Source = Properties.Resources.ZIPPER_NAME;
SystemLogger.LogError(Properties.Resources.ZIPPER_NAME + ” : Execute exception”, ex);
throw;
}
} -
June 4, 2008 at 12:37 PM #19850
I juts figured out i was not respositioning my memorystream ..
zipMemoryStream.position = 0;
messageIn.BodyPart.Data = zipMemoryStream;
return messageIn;
Thanks
-
-
AuthorPosts
- The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.