Author |
Message
|
ghoshly |
Posted: Tue Mar 08, 2011 9:32 am Post subject: Encoding problem with .NET framework Vs VB script |
|
|
Partisan
Joined: 10 Jan 2008 Posts: 333
|
Hi,
We had a application which used to use VB script code to connect to MQ and put message is processed by Message Broker without any problem. Recently the application changed from VB script to .NET framework and we are experiencing issues while parsing xml messages, more specifically when trying to access integer value in an xml.
The message contains simple english characters and numeric values.
Messages from VB script uses CCSID as 437 and Encoding as 546 and without any convertion through MQ input it used to process successfully, but is failing with .NET framework.
Is anything special needs to be done when connecting .NET framework with MQ?
Application queue manager is in Windows : CCSID : 437
WMB queue manager is in AIX : CCSID : 819
 |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Mar 08, 2011 9:41 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
XML documents by definition always only contain character data.
Some of that character data happens to be a character representation of integer values.
The main difference between VB and .NET when dealing with XML is that .NET will properly produce Unicode output.
Telling MQ that this Unicode data is in codepage 437 is incorrect. It's in 1200. or possibly 1201,1202 or 1203. But probably 1200. |
|
Back to top |
|
 |
ghoshly |
Posted: Tue Mar 08, 2011 10:07 am Post subject: Yes |
|
|
Partisan
Joined: 10 Jan 2008 Posts: 333
|
Yes, initially messages were coming out from .NET with CCSID 1200 but later they changed something so that the CCSID becomes same as it was with VB script.
Please guide me what should be my action so that I can parse data coming out from .NET framework correctly. Do we need to use convert option available in the MQinput node with some encoding and CCSID values? |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Mar 08, 2011 2:48 pm Post subject: Re: Yes |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
ghoshly wrote: |
Yes, initially messages were coming out from .NET with CCSID 1200 but later they changed something so that the CCSID becomes same as it was with VB script.
Please guide me what should be my action so that I can parse data coming out from .NET framework correctly. Do we need to use convert option available in the MQinput node with some encoding and CCSID values? |
No you need the CCSID on the input message to adequately describe the codeset of the data.  _________________ MQ & Broker admin |
|
Back to top |
|
 |
ghoshly |
Posted: Tue Mar 08, 2011 9:36 pm Post subject: How to identify the correct code page ? |
|
|
Partisan
Joined: 10 Jan 2008 Posts: 333
|
Thanks for the help. How to identify the correct code page for the input message?
When I stop the flow and browse the input queue MQMD codepage shows 1200 and the data shows like
[img]<?xml version="1.0" encoding="UTF-8" ?>
<ABTxml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ABThdr>
<Version>1.0</Version>
<Lang>en</Lang>
<AckReq>TRUE</AckReq>
<DeploymentMode>Development</DeploymentMode>
<Route>[/img]
In both view it looks like this.
[img]00000000 <.?.x.m. l. .v.e. 3C003F00 78006D00 6C002000 76006500
00000016 r.s.i.o. n.=.".1. 72007300 69006F00 6E003D00 22003100
00000032 ..0.". . e.n.c.o. 2E003000 22002000 65006E00 63006F00
00000048 d.i.n.g. =.".U.T. 64006900 6E006700 3D002200 55005400
00000064 F.-.8.". .?.>.<. 46002D00 38002200 20003F00 3E003C00
00000080 A.B.T.x. m.l. .x. 41004200 54007800 6D006C00 20007800
00000096 m.l.n.s. :.x.s.i. 6D006C00 6E007300 3A007800 73006900
00000112 =.".h.t. t.p.:./. 3D002200 68007400 74007000 3A002F00
00000128 /.w.w.w. ..w.3... 2F007700 77007700 2E007700 33002E00
00000144 o.r.g./. 2.0.0.1. 6F007200 67002F00 32003000 30003100
00000160 /.X.M.L. S.c.h.e. 2F005800 4D004C00 53006300 68006500
00000176 m.a.-.i. n.s.t.a. 6D006100 2D006900 6E007300 74006100
00000192 n.c.e.". >.<.A.B. 6E006300 65002200 3E003C00 41004200[/img]
but it results to ÿþ at the start of the error message.(byte order mark ?)
If I update the codepage in the MQMD tab of rfhutic to 1202 that mark goes out and we are getting "Exception whilst writing field named" , "The length must be correct"
Does this mean 1202 is the correct encoding for the input message and we need to set the codepage in output properties and MQMD ?
 |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Mar 08, 2011 9:53 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
The start indeed looks like a byte order mark. The MQMD on the Input message needs to carry the right CCSID (like 1200, 1201,1202) and you should do nothing on the broker. The .NET application should also not use the writeUTF method in MQ but use a writeText method...
Remember that writeUTF should only be used in conjunction with readUTF.
So talk to the folks sending the message and make sure they do the right thing...
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
rekarm01 |
Posted: Wed Mar 09, 2011 12:01 am Post subject: Re: How to identify the correct ccsid? |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
ghoshly wrote: |
Thanks for the help. How to identify the correct code page for the input message? |
Examining the source code that generates the message and puts it on the queue should be the easiest way to identify the correct ccsid for the input message.
ghoshly wrote: |
When I stop the flow and browse the input queue ... |
OK, that's another way to do it.
ghoshly wrote: |
In both view it looks like this.
Code: |
00000000 <.?.x.m. l. .v.e. 3C003F00 78006D00 6C002000 76006500
00000016 r.s.i.o. n.=.".1. 72007300 69006F00 6E003D00 22003100
00000032 ..0.". . e.n.c.o. 2E003000 22002000 65006E00 63006F00
00000048 d.i.n.g. =.".U.T. 64006900 6E006700 3D002200 55005400
00000064 F.-.8.". .?.>.<. 46002D00 38002200 20003F00 3E003C00
... |
|
It's much easier to read with [code] tags. That doesn't look like utf-8, though.
ghoshly wrote: |
but it results to ÿþ at the start of the error message. (byte order mark?) ... Does this mean 1202 is the correct encoding for the input message and we need to set the codepage in output properties and MQMD? |
No.- ccsid=1200: UTF-16BE
- ccsid=1202: UTF-16LE
- ccsid=1204: UTF-16 with BOM
- ccsid=1208: UTF-8
The correct value for the above message is ccsid=1204, and it would need to be set in the input headers, since it describes the input message. The message flow can't modify the input message, so the .NET application would have to do it.
[Edit: The only Unicode ccsids that .NET applications support are 1200 and 1208, so the application would need to write out the MQMessage using one of those as the CharacterSet instead.] |
|
Back to top |
|
 |
|