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 » Creating a string from a message tree fragment in Java

Post new topic  Reply to topic
 Creating a string from a message tree fragment in Java « View previous topic :: View next topic » 
Author Message
goffinf
PostPosted: Thu Sep 13, 2007 9:28 am    Post subject: Creating a string from a message tree fragment in Java Reply with quote

Chevalier

Joined: 05 Nov 2005
Posts: 401

I want to be able to access a part of a message passed into a JavaCompute node, turn it into a string and pass it to some external Java code. I tried something along the lines of the attached but it appears (?) from the help that the toBitStream method of MbElement will only operate on the message body itself.

[quote}Returns the bit stream representation of the element. This method causes the parser associated with the element to serialize the element and all its children. This method can only be called on the message body, i.e. the last child of the message root.[/quote]

Is there another way I can do this ?

Regards

Fraser.

public void evaluate(MbMessageAssembly contact admin) throws MbException {

MbMessage inMessage = contact admin.getMessage();
...

MbElement inMessageRoot = inMessage.getRootElement();
MbElement inboundmessageParser = inMessageRoot.getLastChild();
....

// navigate to the root element of the message body
MbElement MBServiceWrapper = inboundmessageParser.getLastChild();

// navigate to the part that Im interested in
MbElement originalXMLInstance = MBServiceWrapper.getFirstElementByPath("requestPayload/originalXMLInstance").getFirstChild();

// Now turn this into a String

// this fails
byte[] originalXMLbytes = originalXMLInstance.toBitstream(null, null, null, 0, 1208, 0);

// I was intending to do this next
String originalXMLString = null;
originalXMLString = new String(originalXMLbytes, "ascii");
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Sep 13, 2007 9:31 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Do you want a serialization of a subtree?

Or only the VALUE of a particular MbElement?
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
goffinf
PostPosted: Thu Sep 13, 2007 9:32 am    Post subject: Reply with quote

Chevalier

Joined: 05 Nov 2005
Posts: 401

The complete subtree below the MbElement reference
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Sep 13, 2007 9:32 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Does toBitstream throw an exception?
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
goffinf
PostPosted: Thu Sep 13, 2007 9:38 am    Post subject: Reply with quote

Chevalier

Joined: 05 Nov 2005
Posts: 401

Yes, a nested parser exception which says :-

- XML writing errors have occurred
- No valid body of the document could be found
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Sep 13, 2007 9:41 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Okay. You can try figuring out what the value of the ESQL constant "FolderBitStream" as passed to the ASBITSTREAM function is, and pass that to toBitstream in the options parameter.

It might not work.

You can also use MbSQLStatement to call ASBITSTREAM from Java, I believe.
_________________
I am *not* the model of the modern major general.
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 » Creating a string from a message tree fragment in Java
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.