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 » Convert BLOB to String in JavaCompute Node

Post new topic  Reply to topic
 Convert BLOB to String in JavaCompute Node « View previous topic :: View next topic » 
Author Message
kayhansefat
PostPosted: Thu Mar 08, 2007 2:21 am    Post subject: Convert BLOB to String in JavaCompute Node Reply with quote

Acolyte

Joined: 18 Oct 2006
Posts: 65

I am trying to convert the BLOB data in an incoming message to a String within the Java Compute Node. I create the incoming message on a previous flow and attach the string as a byte array (the "data" variable is the String to be inserted):

Code:
byte[] byteData = data.getBytes();
MbElement blobData = blob.createElementAsFirstChild(MbElement.TYPE_NAME_VALUE, "BLOB", byteData);


That all seems to work fine but using the following code to get the String out from the byte array comes up with a cast exception:

Code:
MbElement inRoot = inMessage.getRootElement();
MbElement blob = inRoot.getLastChild();
MbElement blobData = blob.getLastChild();
byte[] dataByteArray = (byte[])(blobData.getValue());
String dataString = new String(dataByteArray);


The message gets parsed out of the Failure terminal of the JavaCompute Node, I am pretty sure it is caused by line 4 of the code above.

I am not sure this is the best way to do it, any ideas?
Back to top
View user's profile Send private message
au@kosa
PostPosted: Thu Mar 08, 2007 3:05 am    Post subject: Reply with quote

Centurion

Joined: 04 Jan 2007
Posts: 103
Location: pune

Check the below url

http://www.mqseries.net/phpBB2/viewtopic.php?t=33857&highlight=
_________________
Regards,
au@kosa
IBM Certified SOA Solution Designer/Associate
Back to top
View user's profile Send private message Yahoo Messenger
kayhansefat
PostPosted: Thu Mar 08, 2007 7:22 am    Post subject: Reply with quote

Acolyte

Joined: 18 Oct 2006
Posts: 65

Ok thanks but my code was correct in the casting aspect, the problem was that the "MbElement blobData = blob.getLastChild()" did not contain the last child of the BLOB node. It had to be replaced with:

Code:
MbElement blobData = blob.getLastChild().getNextSibling();


Getting the last child, then its next sibling to me doesnt make much sense but there we go!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Convert BLOB to String in JavaCompute Node
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.