Author |
Message
|
my_mqmb |
Posted: Mon Dec 09, 2013 5:03 am Post subject: Adobe reader not able to read PDF sent by email node. |
|
|
Voyager
Joined: 08 Jun 2011 Posts: 84
|
Code: |
CREATE FIELD P2."Content-Type" TYPE NameValue VALUE 'application/pdf; name=LCTrade.pdf';
CREATE FIELD P2."Content-Transfer-Encoding" TYPE NameValue VALUE 'base64';
--CREATE FIELD P2."Content-Disposition" TYPE NameValue 'attachment; filename="my.pdf"
CREATE LASTCHILD OF P2 TYPE Name NAME 'Data';
CREATE LASTCHILD OF P2.Data DOMAIN('BLOB') PARSE(CAST(' This is a notification from Middleware Team ' AS BLOB CCSID 1208));
SET OutputLocalEnvironment.Destination.Email.Attachment.Content = P2.Data.BLOB.BLOB; |
any clues why ? Adobe reader says::
Quote: |
Adobe Reader could not open 'LCtrade.pdf' because it is either not a supported file type or because the file has been damaged ( for example , it was sent as an email attachment and wasnt correctlt decoded)
|
is not P2.Data.BLOB.BLOB a binary stream in PDF format or am i missing something in the configuration ?
Please help
 |
|
Back to top |
|
 |
Vitor |
Posted: Mon Dec 09, 2013 6:19 am Post subject: Re: Adobe reader not able to read PDF sent by email node. |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
my_mqmb wrote: |
is not P2.Data.BLOB.BLOB a binary stream in PDF format or am i missing something in the configuration ? |
It's a binary stream of the message tree. If one of the components is supposed to be a PDF file then that's nice, but WMB neither knows nor cares.
Not entirely sure why you're encoding anything as base64. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
kimbert |
Posted: Mon Dec 09, 2013 7:31 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
is not P2.Data.BLOB.BLOB a binary stream in PDF format or am i missing something |
You are missing something.
The BLOB data type is exactly like a BLOB in a database. In your case, it will contain an array of bytes that represent the characters ' This is a notification from Middleware Team ' encoded in CCSID 1208 ( UTF-8 ). A PDF document is something completely different, so I'm not surprised that Adobe complained about it.
Please explain what your message flow is trying to do, and why. _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
my_mqmb |
Posted: Tue Dec 10, 2013 12:07 am Post subject: |
|
|
Voyager
Joined: 08 Jun 2011 Posts: 84
|
kimbert wrote: |
Quote: |
is not P2.Data.BLOB.BLOB a binary stream in PDF format or am i missing something |
You are missing something.
The BLOB data type is exactly like a BLOB in a database. In your case, it will contain an array of bytes that represent the characters ' This is a notification from Middleware Team ' encoded in CCSID 1208 ( UTF-8 ). A PDF document is something completely different, so I'm not surprised that Adobe complained about it.
Please explain what your message flow is trying to do, and why. |
Sir ,
My flow wants to send email to the customer with a body and a PDF attachment containing some info .
What ever code i posted was about creating the attachment .
Wheni recieve the email during testing , i find that ADOBE cannot open the pdf itself . i guess i did not base64 encode my binary data before passing it to the email o/p node .
I want to achieve all this by esql . is it possible ?
Heard that there is a base64encode function in esql ...
your expert advice plz. |
|
Back to top |
|
 |
kimbert |
Posted: Tue Dec 10, 2013 1:26 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
You are missing the point. A PDF is not 'just a BLOB'. It is a document format with a fairly complex internal structure. You need to create the email attachment using a Java library that handles the PDF format.
btw, base64 is 'just a BLOB', but the bytes are encoded using a range of 64 characters. _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
Esa |
Posted: Tue Dec 10, 2013 1:46 am Post subject: Re: Adobe reader not able to read PDF sent by email node. |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
my_mqmb wrote: |
Code: |
CREATE FIELD P2."Content-Type" TYPE NameValue VALUE 'application/pdf; name=LCTrade.pdf';
|
|
This line does not make the broker convert data into pdf format. It's for informing the receiver application about the format.
If you want to create a pdf document with esql, you must code it yourself. Obtain the pdf format specification from Adobe (I guess it should be available) and get prepared to do some really hard work... |
|
Back to top |
|
 |
my_mqmb |
Posted: Tue Dec 10, 2013 3:34 am Post subject: Re: Adobe reader not able to read PDF sent by email node. |
|
|
Voyager
Joined: 08 Jun 2011 Posts: 84
|
Esa wrote: |
my_mqmb wrote: |
Code: |
CREATE FIELD P2."Content-Type" TYPE NameValue VALUE 'application/pdf; name=LCTrade.pdf';
|
|
This line does not make the broker convert data into pdf format. It's for informing the receiver application about the format.
If you want to create a pdf document with esql, you must code it yourself. Obtain the pdf format specification from Adobe (I guess it should be available) and get prepared to do some really hard work... |
oops ! then i guess i would prefer not to create a pdf from broker side ...
Ok what if i change the design to recieve an already made up pdf( base64 encoded) inside an xml picked up from a queue and just send it through email node ?
Will i have to base64decode it before sending to EMAIL output node or just send it like i am recieving ( ie the b64 part of the xml) as binary ??
what does the email op node expect in the content part of the attachment ? |
|
Back to top |
|
 |
smdavies99 |
Posted: Tue Dec 10, 2013 3:52 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
In the time that you have been posting, you could have:-
Created a test flow that
1) reads a PDF from a file
2) formats a messages and sends it to the Emailoutput node, sending it to yourself
3) get the output and see if it is readable by any PDF reader.
4) If not update 2) and repeat. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
Esa |
Posted: Tue Dec 10, 2013 5:04 am Post subject: Re: Adobe reader not able to read PDF sent by email node. |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
my_mqmb wrote: |
Will i have to base64decode it before sending to EMAIL output node or just send it like i am recieving ( ie the b64 part of the xml) as binary ??
|
It depends. The code excerpt in your first post looks like you have constructed the output message using MIME parser. If that's the case, you don't have to (and shouldn't). |
|
Back to top |
|
 |
my_mqmb |
Posted: Wed Dec 11, 2013 5:15 am Post subject: |
|
|
Voyager
Joined: 08 Jun 2011 Posts: 84
|
smdavies99 wrote: |
In the time that you have been posting, you could have:-
Created a test flow that
1) reads a PDF from a file
2) formats a messages and sends it to the Emailoutput node, sending it to yourself
3) get the output and see if it is readable by any PDF reader.
4) If not update 2) and repeat. |
tried that with the below code , which still throws an exception .
Code: |
CREATE FIELD OutputRoot.MIME TYPE Name;
DECLARE M REFERENCE TO OutputRoot.MIME;
-- Create the Content-Type child of MIME explicitly to ensure the correct order. If we set
-- the ContentType property instead, the field could appear as the last child of MIME.
CREATE FIELD M."Content-Type" TYPE NameValue VALUE 'multipart/related; boundary=myBoundary';
CREATE FIELD M."Content-ID" TYPE NameValue VALUE 'new MIME document';
CREATE LASTCHILD OF M TYPE Name NAME 'Parts';
CREATE LASTCHILD OF M.Parts TYPE Name NAME 'Part';
DECLARE P1 REFERENCE TO M.Parts.Part;
-- First part:
CREATE FIELD P1."Content-Type" TYPE NameValue VALUE 'text/plain; charset=us-ascii';
CREATE FIELD P1."Content-Transfer-Encoding" TYPE NameValue VALUE '8bit';
CREATE LASTCHILD OF P1 TYPE Name NAME 'Data';
CREATE LASTCHILD OF P1.Data DOMAIN('BLOB') PARSE(CAST('Dear Customer, Best Regards' AS BLOB CCSID 1208));
CREATE LASTCHILD OF M.Parts TYPE Name NAME 'Part';
DECLARE P2 REFERENCE TO M.Parts.Part[2];
-- Second part:
CREATE FIELD P2."Content-Type" TYPE NameValue VALUE 'application/octet-stream; name=attachment.pdf';
CREATE FIELD P2."Content-Transfer-Encoding" TYPE NameValue VALUE 'base64';
CREATE LASTCHILD OF P2 TYPE Name NAME 'Data';
CREATE LASTCHILD OF P2.Data DOMAIN('BLOB') PARSE(InputRoot.BLOB.BLOB);
SET OutputLocalEnvironment.Destination.Email.Attachment.Content = OutputRoot.MIME.Parts.Part[2] ;
|
exception thrown is :
Quote: |
/build/S700_P/src/MTI/MTIforBroker/MIMEParser/MIMEwriter.cpp
Parts found, but Content-Type does not specify a valid boundary
|
lost completely .. nothings working out ...  |
|
Back to top |
|
 |
my_mqmb |
Posted: Thu Dec 12, 2013 3:05 am Post subject: |
|
|
Voyager
Joined: 08 Jun 2011 Posts: 84
|
finally i achieved it ... anyhow.  |
|
Back to top |
|
 |
smdavies99 |
Posted: Thu Dec 12, 2013 3:50 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
my_mqmb wrote: |
finally i achieved it ... anyhow.  |
Great. would you care to share your solution with us so that others can learn from it? _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
my_mqmb |
Posted: Sun Dec 15, 2013 2:42 am Post subject: |
|
|
Voyager
Joined: 08 Jun 2011 Posts: 84
|
smdavies99 wrote: |
my_mqmb wrote: |
finally i achieved it ... anyhow.  |
Great. would you care to share your solution with us so that others can learn from it? |
I dropped the MIME thing and use a simple 2 line code to pick up a pdf and email it as it is to the destination and it opened without any hassles .
Code: |
SET OutputRoot.BLOB.BLOB = CAST('This is the notification from Middleware.' AS BLOB CCSID 1208);
SET OutputLocalEnvironment.Destination.Email.Attachment.ContentEncoding = 'Base64';
SET OutputLocalEnvironment.Destination.Email.Attachment.Content = InputRoot.BLOB.BLOB ;
|
|
|
Back to top |
|
 |
Esa |
Posted: Sun Dec 15, 2013 11:14 pm Post subject: |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
OK,
Your exception "Parts found, but Content-Type does not specify a valid boundary " may have been caused by your way to mix options 4 and 3 for Configuring the EmailOutput node.
The InfoCenter says "Local environment overrides are not taken into consideration when a MIME message is passed."
The last line in your code is mixing options 3 and 4:
Code: |
SET OutputLocalEnvironment.Destination.Email.Attachment.Content = OutputRoot.MIME.Parts.Part[2] ;
|
Even if the InfoCenter claims that LocalEnvironment overrides are not applied to MIME messages, my humble guess is that this line may have caused the node to generate another boundary that collided with the one defined in your code... or add a third attachment with a different boundary. |
|
Back to top |
|
 |
|