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 » IBM MQ API Support » IBM.WMQ.MQQueue.Put() is removing BOM while sending message

Post new topic  Reply to topic Goto page Previous  1, 2
 IBM.WMQ.MQQueue.Put() is removing BOM while sending message « View previous topic :: View next topic » 
Author Message
mqjeff
PostPosted: Tue Aug 30, 2011 9:30 am    Post subject: Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Tue Aug 30, 2011 10:27 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
rekarm01
PostPosted: Wed Aug 31, 2011 12:50 am    Post subject: Re: IBM.WMQ.MQQueue.Put() is removing BOM while sending mess Reply with quote

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
View user's profile Send private message
mohan.mmm
PostPosted: Wed Aug 31, 2011 12:52 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page Previous  1, 2 Page 2 of 2

MQSeries.net Forum Index » IBM MQ API Support » IBM.WMQ.MQQueue.Put() is removing BOM while sending message
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.