Author |
Message
|
yugan8055 |
Posted: Thu Jul 04, 2013 4:37 am Post subject: Error:Invalid byte 2 of 2-byte UTF-8 sequence |
|
|
Novice
Joined: 19 Aug 2009 Posts: 12
|
Hi
We have arequirement, where we get input data to the MQ Input node. Same input should be sent as an email attachment to the list of emails.
Input will be from a file like .pdf, .csv, .txt and .xls.
Once, we get the blob data in ESQL, we cast it as a character and then pass that character sting to java compute node which is a service that will take care of sending emails.
We are able to pass all inputs except xls data.(handled pdf files with base64encode() )
Below is the code where we cast input blob (content from excel) to character: Here, CCSID and Encoding values are broker default values.
Code: |
SET Environment.JavaCompute.Email.Attachment=CAST(InputRoot.BLOB."BLOB" AS CHARACTER CCSID InputRoot.Properties.CodedCharSetId Encoding InputRoot.Properties.Encoding); |
Below is the code snippet from java compute node, here we read character string and place into a Xml field. here code fails and giving error.
Code: |
String attachment = envNot.getFirstElementByPath("Email/Attachment").getValueAsString();
MbElement attach = email.createElementAsLastChild(MbXMLNSC.FOLDER, "Attachment", null);
attach.createElementAsLastChild(MbXMLNSC.CDATA_FIELD, "Content", attachment); |
It seems As we are using default CCSID and Encoding values while casting blob to character in ESQL, it is failing in java compute node.
Quote: |
(0x03000000:NameValue):Encoding = 273 (INTEGER)
(0x03000000:NameValue):CodedCharSetId = 819 |
Can any one please let me know what should be the CCSID and Encoding for excel blob data as these values are not coming for me in the input properties.
Thanks in advance .. |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Jul 04, 2013 4:40 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
you need to use either binary or base64 encoding. What you are doing is mangling the hex values.
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
kimbert |
Posted: Thu Jul 04, 2013 5:21 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
I agree. Not all data is text. An Excel spreadsheet is not text ( unless it has been exported into a CSV file ). If you try to process binary data as text you will get character conversion errors - as you have just discovered. |
|
Back to top |
|
 |
yugan8055 |
Posted: Thu Jul 04, 2013 5:21 am Post subject: |
|
|
Novice
Joined: 19 Aug 2009 Posts: 12
|
Yes, i tried base64encode, but this option gave me the excel file with hexadecimal data.
Can you please tell me how to try binary encoding option?
Thanks.. |
|
Back to top |
|
 |
kimbert |
Posted: Thu Jul 04, 2013 5:24 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
i tried base64encode, but this option gave me the excel file with hexadecimal data |
Why is that a problem? |
|
Back to top |
|
 |
yugan8055 |
Posted: Thu Jul 04, 2013 5:35 am Post subject: |
|
|
Novice
Joined: 19 Aug 2009 Posts: 12
|
Hi Kimbert,
Sorry if i confused or not updated clearly.
With base64encode() , generated excel file in mail attachment is having hexadecimal characters, not as actual excel readable data.
In ESQL, we used base64encoe() on input blob, then the generated character string given to java service which has created excel file.
I may need to think if java service has to handle this character string for excel files in a different way.
I will think in that line as well.
Meanwhile, if any one knows, please guide me how to cast blob with binary data to character.
Thanks a lot for timely response. |
|
Back to top |
|
 |
yugan8055 |
Posted: Thu Jul 04, 2013 5:53 am Post subject: |
|
|
Novice
Joined: 19 Aug 2009 Posts: 12
|
Many thanks to both of you.
Making me to think in correct lines.
As you told, i treated excel files as binary files and enabled a falg in my java service to construct file in binary mode.
Finally, this worked for me..Still yet to test with couple of more excel files.
Thanks once again. |
|
Back to top |
|
 |
kimbert |
Posted: Thu Jul 04, 2013 6:04 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Include an xsi:type attribute on the XML tag. In your Java code, when the xsi:type value is 'xs:base64Binary' you decode it before proceeding. |
|
Back to top |
|
 |
yugan8055 |
Posted: Thu Jul 04, 2013 6:18 am Post subject: |
|
|
Novice
Joined: 19 Aug 2009 Posts: 12
|
|
Back to top |
|
 |
kash3338 |
Posted: Thu Jul 04, 2013 6:45 am Post subject: |
|
|
Shaman
Joined: 08 Feb 2009 Posts: 709 Location: Chennai, India
|
Why not send the BLOB message directly as EMail attachment? Why do you want to CAST to CHAR before that? |
|
Back to top |
|
 |
|