|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Serializing XMLNSC tree with toBitstream() |
« View previous topic :: View next topic » |
Author |
Message
|
nelson |
Posted: Fri Oct 25, 2013 1:23 pm Post subject: Serializing XMLNSC tree with toBitstream() |
|
|
 Partisan
Joined: 02 Oct 2012 Posts: 313
|
Hi all,
I'm working in a User Defined Node developed in Java. When I try to serialize the inputRoot payload data (in this case the XMLNSC) I'm getting only hexa values. What I do is this:
Code: |
...
MbMessage newMsg = new MbMessage(assembly.getMessage());
MbElement root = newMsg.getRootElement().getLastChild();
root.getFirstChild().createElementAsLastChild(MbElement.TYPE_NAME, "DATA",topOfBody.toBitstream(null, null, null, 0, 0, 0));
...
|
And what I get in the <DATA> tag is something like
Code: |
<DATA>f736368656d612f4...a6c6f67696361</DATA> |
I have tried setting the encoding and CCSID as their values in the incoming message, but get this error
Code: |
com.ibm.broker.plugin.MbParserException class:JNI method:ImbXMLNSCParser::refreshBitStreamFromElementsCommon source:BIPmsgs key:5010 |
Any hint on this issue?
WMB 8.0.0.1
Thanks in advance |
|
Back to top |
|
 |
smdavies99 |
Posted: Fri Oct 25, 2013 10:18 pm Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
What are you expecting to see?
Translate hex f7, 63 ,63 etc to a character field. What does that show?
Perhaps you need to convert the bitstream to something a little more human readable? _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
nelson |
Posted: Sat Oct 26, 2013 9:54 pm Post subject: |
|
|
 Partisan
Joined: 02 Oct 2012 Posts: 313
|
smdavies99 wrote: |
What are you expecting to see? |
Answering your first question, I would think that the toBitstream() method behavior should be the same behavior of ASBITSTREAM, in ESQL. Both methods have the same parameters.
Regarding to the java method, I use zeros in the ccsid and encoding parameters values, because of the method description.
Code: |
encoding - The encoding to use when writing the bit stream. A special value of 0 may be supplied to indicate that the queue manager's encoding should be used.
ccsid - The coded character set identifier to use when writing the bit stream. A special value of 0 may be supplied to indicate that the queue manager's ccsid should be used. A ccsid of -1 indicates that the bit stream is to be generated using ccsid information contained in the subtree consisting of the field pointed to by the element and its children. Currently no parsers support this option. |
I'm expecting the method to build for me the XMLNSC tree, as you say, in a more human readable representation.
Kind regards. |
|
Back to top |
|
 |
mqjeff |
Posted: Sun Oct 27, 2013 3:58 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
toBitstream produces a BLOB, not a CHARACTER. |
|
Back to top |
|
 |
nelson |
Posted: Sun Oct 27, 2013 3:04 pm Post subject: |
|
|
 Partisan
Joined: 02 Oct 2012 Posts: 313
|
mqjeff wrote: |
toBitstream produces a BLOB, not a CHARACTER. |
Thanks mqjeff, your clarification helped me a lot. I haven't noticed that the java method was returning a byte array. So, after that, what I do is the following:
Code: |
byte [] stringBytes = root.toBitstream(null, null, null, 0, 0, 0);
String myString = new String(stringBytes);
...
root.getFirstChild().createElementAsLastChild(MbElement.TYPE_NAME, "DATA",myString); |
The output is very close of what I'm expecting. But I have a little issue, (that I understand may not be a WMB concerning issue): in the output string I'm getting the right XML structure, but it includes < > , etc, when a < or > appears on the original XML message, or any other special character is represented in this way. Something like:
Code: |
<hd:MyTag><hd:MyTag2>01234567890785652661</hd:MyTag2>
... |
I have tried generating a new String with
Code: |
String myString2 = myString.replace("<", "<"); |
but didn't succeed, the String remains the same.
If you have any idea on how to solve this issue I would be very appreciated.
Kind regards. |
|
Back to top |
|
 |
fjb_saper |
Posted: Sun Oct 27, 2013 7:15 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
you should not be surprised. You are creating an XML element, the content of which is XML.
This means (as per XML spec) that any <&> and other non XML valid characters need to be escaped... hence the < > & etc ...
Working as designed.  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|