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 » toBitstream problem

Post new topic  Reply to topic
 toBitstream problem « View previous topic :: View next topic » 
Author Message
goffinf
PostPosted: Tue Nov 15, 2005 4:17 am    Post subject: toBitstream problem Reply with quote

Chevalier

Joined: 05 Nov 2005
Posts: 401

WBIMB v5.1

I am using toBitstream on an MbElement. In some circumstance it works fine in others not. The docs states :-

'This method causes the parser associated with the element to serialize the element and all its children.'

However it appears that it just serializes the children of the element ??

This causes a issue when the MbElement has more than 1 child, in which case an exception occurs ??

I'm not certain whether its me (most likely) or I can't use toBitstream in the way that I want to. Here is some example code :-

In an MB flow this data is stored in Environment.myStuff :-

<?xml version="1.0" encoding="UTF-8"?>
<Numbers>
<Odds>
<One>1</One>
<Three>3</Three>
<Five>5</Five>
</Odds>
<Evens>
<Two>2</Two>
<Four>4</Four>
<Six>6</Six>
</Evens>
</Numbers>

Now in a custom node (various bits removed for clarity) :-

public String doStuff(String inputXml, Vector paramsVector, MbMessageAssembly contact admin) throws Exception {

MbMessage localMessage = contact admin.getGlobalEnvironment();
// returns 'Root'
MbElement localRoot = localMessage.getRootElement();

MbElement xmlnsSP = localRoot.getFirstElementByPath("myStuff");

// So at this stage MbElement is pointing to Environment.myStuff

MbElement documentSource;

try {
documentSource = xmlnsSP.getFirstElementByPath("Numbers");

// BLOWS UP HERE
byte[] xmlData = documentSource.toBitstream(null, null, null, 0, 0, 0);

xmlString = new String(xmlData, "ascii");
....

If I remove the <Evens> structure from the data in the Environment the toBitstream method works successfully ???

Cheers

Fraser.
Back to top
View user's profile Send private message
jhosie
PostPosted: Tue Nov 15, 2005 9:13 am    Post subject: Reply with quote

Apprentice

Joined: 12 May 2005
Posts: 28

What are you trying to obtain? something like..

(1)
Code:

<Numbers><Odds>....</Odds><Evens>...</Evens></Numbers>


or (2)
Code:

<Odds>....</Odds><Evens>...</Evens>


for (1), I think you should invoke toBitstream on the parent of Numbers.
(2) is an invalid XML document (more than one top level element) which is why the parser complains.
Back to top
View user's profile Send private message
goffinf
PostPosted: Tue Nov 15, 2005 9:41 am    Post subject: Reply with quote

Chevalier

Joined: 05 Nov 2005
Posts: 401

Thanks for your reply. Yes I am trying to get :-

<Numbers><Odds> ... etc..

As I said, the docs suggest that the call to toBitstream should do exactly that if I position on the 'Numbers' node in the message tree, but it doesn't seem to

Going up a level wouldn't work in this case since at that level a bunch of other children exist including the one that I want ('Numbers'), and, as you rightly point out, an XML doc with more than one root node is invalid !

Environment
|- Variables
|- Numbers
|-----|- Odds
|-----|---|- One
|-----|---|- ...
| ...
|- somethingElse
|- otherStuff

Fraser.
Back to top
View user's profile Send private message
jhosie
PostPosted: Tue Nov 15, 2005 9:59 am    Post subject: Reply with quote

Apprentice

Joined: 12 May 2005
Posts: 28

I don't use Java nodes much but if I were to do this in ESQL, then I would use the FolderBitStream option.
I don't think that this option is available in Java ndoes yet. Maybe it will be in a future release.
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 » toBitstream problem
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.