Author |
Message
|
KoGor |
Posted: Tue Jul 15, 2008 7:50 am Post subject: Convert UTF8 string to numeric character reference format? |
|
|
Voyager
Joined: 09 Nov 2005 Posts: 81 Location: Moscow,Russia.
|
Hi All!
I have a message flow (Win32+WMB6.1) where an incoming message is predefined message in MRM domain. There is a field "TEXT" which is defined in message definition as string type. If I stop message flow and look in incoming queue directly - the incoming message has this field in numeric character reference "<sds:text>&#....;&#......;&#.....;&#......;</sds:text>" (I put dots instead of digital, so it could display the string in browser correctly)
When message flow reads this message this field is automatically converted to Unicode string such as "qwerty" - I see it as string in debugger and later when I send the message to the outgoing queue this field still in UTF8. Is it possible to tell broker to convert this field into incoming numeric character reference format ?
I hope I explain my problem clear.
Thanks for any help ! |
|
Back to top |
|
 |
kimbert |
Posted: Wed Jul 16, 2008 12:39 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
What happens when the message is parsed:
a) Character entities ( &#nn; ) in the input XML are automatically converted to characters by the XML scanner. The MRM parser never sees the string '&#nn;'. It sees the UTF8 character which is represented by that character entity.
b) the UTF8 string received from the XML scanner is converted to UTF16, because all strings in the message tree must be in UTF16
What happens when the message is written out:
Any XML markup characters are automatically escaped ( i.e. converted to #&nn; ) using the rules in the XML specification.
So the short answer is 'no, it's not possible to tell message broker to escape characters which don't need to be escaped'. Now you're probably going to tell me why you want this  |
|
Back to top |
|
 |
KoGor |
Posted: Wed Jul 16, 2008 1:12 am Post subject: |
|
|
Voyager
Joined: 09 Nov 2005 Posts: 81 Location: Moscow,Russia.
|
I need send the message by MQ to Websphere Application server, which uses SOAP MIME parser for incoming message. It cannot understand the UTF8 from the broker and requires all string fields in '&#nn' format (for the non-ASCII Cyrillic character). |
|
Back to top |
|
 |
kimbert |
Posted: Wed Jul 16, 2008 3:31 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Please explain why you believe that because it sounds wrong to me. Are you sure that you have specified the code page correctly in your message flow and in WAS? |
|
Back to top |
|
 |
KoGor |
Posted: Wed Jul 16, 2008 5:37 am Post subject: |
|
|
Voyager
Joined: 09 Nov 2005 Posts: 81 Location: Moscow,Russia.
|
I was told by our WAS developer that all the message should be in MIME format and in ASCII7 encoding to be understood by WAS's parser. I think I should try to re encode somehow incoming message which in UTF8 and put in MQOUT using MIME domain |
|
Back to top |
|
 |
kimbert |
Posted: Wed Jul 16, 2008 6:57 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
MIME parts can be base64-encoded. base64 data is 7-bit. If I were you, I would
- check that the WAS MIME parser can handle base64 data ( it should )
- Use XMLNSC instead of MRM XML for the output side
- Convert the TEXT field to a BLOB ( using CAST with the Encoding and CCSID parameters )
- SET OutputRoot.XMLNSC.message.(XMLNSC.PCDataField + XMLNSC.base64Binary)TEXT = myBLOB;
- Let the XMLNSC parser base64 encode the BLOB for you when it writes the message out. |
|
Back to top |
|
 |
KoGor |
Posted: Fri Jul 18, 2008 3:30 am Post subject: |
|
|
Voyager
Joined: 09 Nov 2005 Posts: 81 Location: Moscow,Russia.
|
kimbert
Thanks for advise, I have not yet work with XMLNSC much and now I know how to declare base64 field from the code but I'm afraid this is not my case.
I think for the MIME parser to understand a message - the whole message should be encoded in Base64 - not only one field of the whole XML message.
And using XMLNSC to encode only one field is not right - for WAS the field TEXT will be only string field - in what way it would find out that the field is encoded in Base64?
If you encode the whole message in Base64 and send it by MIME domain you can define Content-Transfer-Encoding=base64, but in case you encode only one field in base64 there must be XML schema or smth else so WAS could parse the incoming message successfully.
I even tried to convert chars into NCR format by hand, so before MQOUT node I had a XML message with 'TEXT' element "<TEXT>& #1233;& #3234;</TEXT>" but WMB serializes the & symbol as "& amp;" so in MQ queue I had a message with the field like that "& amp;#1233;& amp;#1322;"
Now I'm loosing hope to fix this problem. I even can't imagine that WMB is not capable to serialize an XML message with such widespread format as NCR and also I surprised that WAS couldn't get UTF8.
So any chance to fix my problem? |
|
Back to top |
|
 |
kimbert |
Posted: Fri Jul 18, 2008 4:53 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
using XMLNSC to encode only one field is not right |
I agree. But don't give up hope! This is still quite straightforward:
- ASBITSTREAM the entire XML message to obtain a BLOB
- base64 encode the BLOB ( using a call to the java class MIME::base64 )
- Set up the MIME tree to contain the BLOB, and set Content-Transfer-Encoding=base64 |
|
Back to top |
|
 |
KoGor |
Posted: Fri Jul 18, 2008 5:16 am Post subject: |
|
|
Voyager
Joined: 09 Nov 2005 Posts: 81 Location: Moscow,Russia.
|
You are reading my mind
I'm trying to find a way to convert a message to base64. And the only way I have found is to use Java node. Unfortunately I have no experience in using Java compute node at all
If it's possible could you give the java-compute node code how to encode in base64 the whole message. Thank you in advance!
P.S. I'm afraid I would have to do a lot of reading for this weekend  |
|
Back to top |
|
 |
kimbert |
Posted: Fri Jul 18, 2008 5:43 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
You don't need a JavaCompute node. You can call a Java method direct from ESQL. Check the docs or search for base64 in this forum |
|
Back to top |
|
 |
|