Author |
Message
|
ranjitgopalan |
Posted: Wed Apr 29, 2009 8:34 am Post subject: RCB and BLOB |
|
|
Newbie
Joined: 19 Nov 2008 Posts: 8
|
I am trying to convert a BLOB to the logical model using a java node and RCD.
The java code i have takes the CDATA section of a XML message node and tries to convert it to a BLOB through the RCD.
The code i have written in java to convert it into BLOB is
String value = (String) inPayloadMessage.getValue();
MbElement outParser = payloadOutMessage.getRootElement()
.createElementAsLastChild(MbBLOB.PARSER_NAME);
outParser.createElementAsLastChild(MbElement.TYPE_NAME_VALUE,
BLOB, value.getBytes());
value will the BLOB data.
This doesnot work the RCB is throwing a parser exception.
But when i run the same with fileinput and parse it there the MRM work.
Please tell me if i my java code is correct or if need to make any modifications. |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Apr 29, 2009 9:01 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
You're almost certainly doing something you don't want to do when you cast your BLOB to a String like that, and getBytes() may not give you what you expect either.
Try just
Code: |
byte[] value = (byte[]) inPayloadMessage.getValue(); |
and then pass value directly, instead of trying to "getBytes()" it. |
|
Back to top |
|
 |
ranjitgopalan |
Posted: Wed Apr 29, 2009 10:51 am Post subject: |
|
|
Newbie
Joined: 19 Nov 2008 Posts: 8
|
Tried giving a class cast exception seems like string cannot be typecasted to byte[]. seems like i have to only use getBytes().
Any other suggestion whic i can try |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Apr 29, 2009 11:11 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Right. The XMLNSC CDATA section is gonna contain a string.
Means your corruption is caused by something else. Is the CDATA section in the same codepage as the XML Document? |
|
Back to top |
|
 |
ranjitgopalan |
Posted: Wed Apr 29, 2009 12:50 pm Post subject: |
|
|
Newbie
Joined: 19 Nov 2008 Posts: 8
|
No i have not added any specific code page to the CDATA but not sure what is causing the issue. THE MRM is of USE DATA PATTERN, would this cause a issue ? |
|
Back to top |
|
 |
ranjitgopalan |
Posted: Wed Apr 29, 2009 8:30 pm Post subject: |
|
|
Newbie
Joined: 19 Nov 2008 Posts: 8
|
I tried instead of RCD putting the BLOB into a MQ OUput and then through another MQ Input i read it parsing as MRM it works. I assume the issue with charcodedset or encoding but not able pin point what is causing the issue. Is there any way i can debug or trace this. |
|
Back to top |
|
 |
rekarm01 |
Posted: Thu Apr 30, 2009 9:22 pm Post subject: Re: RCD and BLOB |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
ranjitgopalan wrote: |
I am trying to convert a BLOB to the logical model using a java node and RCD. |
Is there a particular reason for using a Java Compute node, rather than ESQL?
ranjitgopalan wrote: |
This does not work the RCD is throwing a parser exception. |
Which parser exception?
ranjitgopalan wrote: |
Code: |
MbElement outParser = payloadOutMessage
.getRootElement()
.createElementAsLastChild(MbBLOB.PARSER_NAME);
outParser.createElementAsLastChild(
MbElement.TYPE_NAME_VALUE,
BLOB, // what is BLOB?
value.getBytes()); |
|
What is BLOB? If it's a string literal, it should be double-quoted: "BLOB"
getBytes() converts a String to a byte[], using the platform's default charset. This might or might not agree with the message's CCSID. If they don't agree, that can cause problems; either change the CCSID, (before the RCD), or use getBytes(charsetName), so that they do agree.
ranjitgopalan wrote: |
Is there any way i can debug or trace this? |
Yes. Put a trace node between the Java Compute node and the RCD node, to capture ${Root}; optionally put a trace node after the RCD node, too. Configure the trace nodes to write to a file, or to usertrace (and then run a usertrace). |
|
Back to top |
|
 |
ranjitgopalan |
Posted: Tue May 05, 2009 6:17 am Post subject: |
|
|
Newbie
Joined: 19 Nov 2008 Posts: 8
|
Thanks for the info. How do i know which java charsetname i need to use for a CCSID |
|
Back to top |
|
 |
rekarm01 |
Posted: Wed May 06, 2009 1:23 am Post subject: Re: RCD and BLOB |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
ranjitgopalan wrote: |
Thanks for the info. How do i know which java charsetname i need to use for a CCSID |
Perhaps this hyperlink can help:
rekarm01 wrote: |
... either change the CCSID, (before the RCD), or use getBytes(charsetName), so that they do agree. |
Click.
Quote: |
Parameters: charsetName - the name of a supported charset |
Click.
Quote: |
Standard charsets
Every implementation of the Java platform is required to support the following standard charsets. Consult the release documentation for your implementation to see if any other charsets are supported.
Code: |
US-ASCII Seven-bit ASCII, a.k.a. ISO646-US ...
ISO-8859-1 ISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1
UTF-8 Eight-bit UCS Transformation Format
UTF-16BE Sixteen-bit UCS Transformation Format, big-endian byte order
UTF-16LE Sixteen-bit UCS Transformation Format, little-endian byte order
UTF-16 Sixteen-bit UCS Transformation Format, byte order identified by
an optional byte-order mark
|
|
Javadoc information is also accessible using the WMB toolkit Java editor's command assist. |
|
Back to top |
|
 |
|