|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
IBM.WMQ.MQQueue.Put() is removing BOM while sending message |
« View previous topic :: View next topic » |
Author |
Message
|
mqjeff |
Posted: Tue Aug 30, 2011 9:30 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Is the reading app taking the right steps to cause MQ to convert the incoming message to the correct format for itself? |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Aug 30, 2011 10:27 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
mohan.mmm wrote: |
Removing the CStr and removing the CCSID setting to 1200 is not helping.
The XML string is constructed in the .Net application. Here I have created a sample application to read the xml string from file. I have tried both the ways. Still no BOM. |
If you want a BOM you may have to read it as a bytestream, and not as a string. So set a CCSID 1202 or 1204 on the message. Read as bytes and not as text and pass the bytestream to your method...
Per definition a String in .NET does not have a BOM. All those problems are already fixed before you ever get a String. However the serialized version of the String might have a BOM and this may be what is required, as in ... you are using an XML parser that expects raw data, hence the request for a BOM.
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
rekarm01 |
Posted: Wed Aug 31, 2011 12:50 am Post subject: Re: IBM.WMQ.MQQueue.Put() is removing BOM while sending mess |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
mohan.mmm wrote: |
The receiving application is MQSC adaptor of BizTalk 2010 ... We don't have control on how to read the message. |
That bit of information would have been more useful in the initial post. But this forum is probably not the best place to figure out how to configure the BizTalk adapter to work correctly without a BOM.
mohan.mmm wrote: |
Code: |
Dim sr As New StreamReader("C:\OUT\JustSavedinNotepad.xml", Encoding.UTF8)
sInputMsg = sr.ReadToEnd()
' sInputMsg variable will have the string "<?xml version="1.0" encoding="utf-16"?><LName>mohan.mmm</LName>" |
|
byte-order-marks only apply to bytes; they don't apply to characters, or strings. Whether the file had a BOM or not, sInputMsg won't (and shouldn't) have one.
mohan.mmm wrote: |
Code: |
'--- Inserted this code to just check the HEX values ---
Dim byteArray() As Byte = Encoding.UTF8.GetBytes(sInputMsg)
Dim hexString As String = BitConverter.ToString(byteArray, 0, 10)
' -- Output shows as "3C-3F-78-6D-6C-20-76-65-72-73" |
|
Unfortunately, that just checks the HEX values of byteArray. It says nothing useful about sInputMsg.
mohan.mmm wrote: |
Code: |
hexString = BitConverter.ToString(byteArrayBOM, 0, 10)
' -- Output shows as "FF-FE-3C-3F-78-6D-6C-20-76-65"
' -- FF-FE are BOM |
|
No, FF-FE is not a BOM, because byteArrayBOM is supposed to be UTF-8, not UTF-16LE. Here, FF-FE is an ill-formed UTF-8 sequence. Converting back to a string replaces these bytes with U+FFFD ('�'), as shown here:
mohan.mmm wrote: |
Code: |
'--- MQMessage in RFHUtil tool shows as FDFFFDFF 3C003F00 78006D00 6C002000..... |
|
WriteString doesn't create a BOM, but the .NET Encoding objects can. Perhaps it's easier to use them to convert characters to bytes, and then use Write instead of WriteString to write the MQMessage. For example:
Code: |
' new Unicode Encoding object: Big-Endian=False, BOM=True
Dim u16LE As New UnicodeEncoding(False, True)
' ...
Dim bInputMsg() As Byte = u16LE.GetBytes(sInputMsg)
' ...
objMessage.Write(bInputMsg) |
|
|
Back to top |
|
 |
mohan.mmm |
Posted: Wed Aug 31, 2011 12:52 pm Post subject: |
|
|
Newbie
Joined: 26 Aug 2011 Posts: 7
|
The issue is resolved. I have added the BOM bytes manually to the message. Here is the solution
Code: |
objMessage.WriteByte(Convert.ToByte(&HFF))
objMessage.WriteByte(Convert.ToByte(&HFE))
objMessage.WriteString(sInputMsg)
objMQQueue.ClearErrorCodes()
objMQQueue.Put(objMessage, objMessageOptions)
|
Thank you all for your help. |
|
Back to top |
|
 |
|
|
|
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
|
|
|
|