ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Error:Invalid byte 2 of 2-byte UTF-8 sequence

Post new topic  Reply to topic
 Error:Invalid byte 2 of 2-byte UTF-8 sequence « View previous topic :: View next topic » 
Author Message
yugan8055
PostPosted: Thu Jul 04, 2013 4:37 am    Post subject: Error:Invalid byte 2 of 2-byte UTF-8 sequence Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Thu Jul 04, 2013 4:40 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
kimbert
PostPosted: Thu Jul 04, 2013 5:21 am    Post subject: Reply with quote

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
View user's profile Send private message
yugan8055
PostPosted: Thu Jul 04, 2013 5:21 am    Post subject: Reply with quote

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
View user's profile Send private message
kimbert
PostPosted: Thu Jul 04, 2013 5:24 am    Post subject: Reply with quote

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
View user's profile Send private message
yugan8055
PostPosted: Thu Jul 04, 2013 5:35 am    Post subject: Reply with quote

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
View user's profile Send private message
yugan8055
PostPosted: Thu Jul 04, 2013 5:53 am    Post subject: Reply with quote

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
View user's profile Send private message
kimbert
PostPosted: Thu Jul 04, 2013 6:04 am    Post subject: Reply with quote

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
View user's profile Send private message
yugan8055
PostPosted: Thu Jul 04, 2013 6:18 am    Post subject: Reply with quote

Novice

Joined: 19 Aug 2009
Posts: 12

Sure kimbert.
Back to top
View user's profile Send private message
kash3338
PostPosted: Thu Jul 04, 2013 6:45 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Error:Invalid byte 2 of 2-byte UTF-8 sequence
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.