Thursday, August 20, 2009

Handling multipart MIME messages in Biztalk

Scenario:
I am trying to handle multi part MIME messages in Biztalk 2004.My Scenario is like this
I have a flat file which has two parts.The first part is of content type:text/plain and the second part is of Content type:application/pdf with encoding :base64.
What i need to do is,i receive this text file and send a xml output with
the pdf as the attachment.the problem is,i am able to generate the xml file but not the pdf attachment.Is anyone familiar with this issue.please let me know.i am pasting a part of the text file for your reference
--------------------File start------------------- MIME-Version: 1.0 Content-Type: multipart/related; type="text/plain"; start="application/ms-cimessage"; boundary="----=_NextPart_001"
This is a multi-part message in MIME format.
------=_NextPart_001 Content-Type: text/plain; Charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-ID:
DOCFLATRESP087096350 ZZ087096350ZZ937748440937748440087096350A4026 A4026 0
90029627138363-26 WASHINGTON JOHN A123456789WASHINGTON MARIA B222112222123 QA ROAD TESTERVILLE PA1910390000.00 100000.00 Commitment0410200639.00 39 25.0 BYMNSP0.5200.5200.0000.0000.0001
001359 ------=_NextPart_001 Content-Type: application/pdf Content-Transfer-Encoding: base64 Content-ID: Content-Disposition: attachment; filename=Cert_90029627-Date_20051012-114553-CorrID_A4026.pdf
JVBERi0xLjMKJa0KMSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZwovUGFnZXMgMzEgMCBSCi9PdXR­­saW5lcyAzMiAwIFIKL1ZpZXdlclByZWZlcmVuY2VzIDIgMCBSCi9PcGVuQWN0aW9uIFswIC9YW­V­ogMCA3OTIgMF0KPj4KZW5kb2JqCjIgMCBvYmoKPDwgL1R5cGUgL1ZpZXdlclByZWZlcmVuY2V­zC­i9IaWRlVG9vbGJhciBmYWxzZSAvSGlkZU1lbnViYXIgZmFsc2UgPj4KZW5kb2JqCjMgMCBvY­moK­Wy9QREYgL1RleHQgL0ltYWdlQ10KZW5kb2JqCjQgMCBvYmoKPDwKL1R5cGUgL0ZvbnQKL1N­1YnR­5cGUgL1R5cGUxCi9OYW1lIC9GMQovQmFzZUZvbnQgL0NvdXJpZXIKL0Vu
------=_NextPart_001

Solution:

Here are the Steps assuming that you want to convert a MUltipart flat file MIME file into and XML with pdf attachment.This scenario is valid for any output file with any number of attachments.
Assumptions:
1.You must have the Receive Flat File Schema.Mine was a positional Schema. 2.If you have a map,make sure your map works.
Solution.
1.Create a Receive pipeline.Add a MIME/SMIME decoder in the decode Section.you don't have to modify any properties.This decoder automatically decodes your Mime Input messages. 2.Add Flat File or XML Dissembles if needed. 3.In the Orchestration ,Create a Multipart Message Type.If you have 1 attachment,Create 2 MultiParts and Set the Types as "System.XML.XMLDocument". 4.Create 2 Message Types to separate the input text file into the required number of files. a)Set the Body Message of Message Type=Flate File Schema b)Set the Attachment Message of Message Type=System.String 5.Place a receive .Place a construct Message.Add 2 message assignments inside the Construct Message.Here is where you separate the input message into the required 2 documents. 6.In the First message Assigment ,set the msgBody to the MultipartBody Type like this msgBody=msgMultiPart.MultiPartXml;(Based on my Example).Where msgBody is the message and msgMultiPart is my Multipart message 7.Similarly in the Second Message Assigment,set the msgAssignment to multipartPDF Type like this msgAttachment=msgMultiPart.msgPDFPart; 8.From here its a straight forward mapping or sending the output.For my
solution ,i have a parallel shape which posts the msgBody after mapping
to a response location, and the msgAssignment is also posted out to the
same response/send location.

No comments: