Posted: Mon Apr 14, 2014 4:16 am Post subject: Extract Attachment From MIME using ESQL
Newbie
Joined: 18 Feb 2010 Posts: 4
I’m struggling to find a solution on my new requirement on MIME. Please find the message flow involved in my design.
Flow 1 :
EmailInputNode -> compute node -> SoapReqnode
I’m polling on mail server and reading the mails which contains the JPG images as attacments. I have to extract the images from MIME domain and create soap request to webservice. Eventually that webservice will write these images into file directory. This is my complete requirement. Till this point everything is working as expected but after that I’m not able to open the image.
I guess I’m doing something wrong in creating SOAP request with attachment extracted from MIME domain.
For your reference please check my ESQL. I have used BASE64ENCODE and DECODE functions as well to ensure xml has proper base64binary data.
I don’t understand how to make use of in esql InputRoot.MIME.Parts.Part[2].Data.BLOB.BLOB. Which is consists of binary security signature.
CALL CopyMessageHeaders();
DECLARE inputData CHARACTER;
DECLARE outRef,outRefEnv,outRefBody,outRef1 REFERENCE TO OutputRoot;
-- CREATE LASTCHILD OF outRef AS outRef DOMAIN 'XMLNSC';
CREATE LASTCHILD OF outRef AS outRefEnv NAMESPACE soapenv NAME 'Envelope';
SET outRefEnv.(XMLNSC.NamespaceDecl)xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/';
SET outRefEnv.(XMLNSC.NamespaceDecl)xmlns:ns24='http://www.bmi.com/Enterprise/Services/Core/Media/V1/';
CREATE LASTCHILD OF outRefEnv AS outRefBody NAMESPACE soapenv NAME 'Header';
CREATE LASTCHILD OF outRefEnv AS outRefBody NAMESPACE soapenv NAME 'Body';
CREATE LASTCHILD OF outRefBody AS outRef1 NAMESPACE ns24 NAME 'SaveMedia';
CREATE LASTCHILD OF outRef1 AS outRef1 NAME 'SaveMediaReq';
CREATE LASTCHILD OF outRef1 AS outRef1 NAME 'messageHeader';
SET outRef1.routingInfo.toSystem.systemName = 'MDM';
MOVE outRef1 PARENT;
CREATE LASTCHILD OF outRef1 AS outRef1 NAME 'mediaGeneric';
CREATE LASTCHILD OF outRef1 AS outRef1 NAME 'image';
SET outRef1.alternateIdentifier.systemName = 'FINANCIAL';
SET outRef1.alternateIdentifier.alternateId = InputRoot.EmailInputHeader.Subject;
SET outRef1.name.displayName = InputRoot.MIME.Parts.Part[2]."Content-Description";
IF InputRoot.EmailInputHeader.Size > 0 THEN
DECLARE encoded CHARACTER BASE64ENCODE(InputRoot.MIME.Parts.Part[1].Data.BLOB.BLOB);
DECLARE decoded BLOB BASE64DECODE(encoded);
--DECLARE attachmentAsChar CHARACTER CAST(InputRoot.MIME.Parts.Part[1].Data.BLOB.BLOB AS CHAR CCSID InputProperties.CodedCharSetId);
SET outRef1.bytes = decoded;
ELSE
THROW USER EXCEPTION VALUES('No attachments to the mail');
END IF;
Note : If I connect EmailInput node out terminal to FileOutputNode In terminal. Image is writing properly and able to open it.
I’m very thankful to you. If you can reply quickly.
you have an XML namespace declaration for ns24, but no ESQL namespace declaration for it:
Code:
declare ns24 NAMESPACE 'http:....'
, yet you seem to be using it as an esql namespace declaration..., same for soapenv... Hope this is because you're just not showing the section of code where they've been declared...
FYI shouldn't the blob outref1.bytes be 64bitencoded ?? or at least be a hex representation of the data?? _________________ MQ & Broker admin
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum