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 Java / JMS » funny hex like chars when reading xml msgs from a queue

Post new topic  Reply to topic
 funny hex like chars when reading xml msgs from a queue « View previous topic :: View next topic » 
Author Message
nr525
PostPosted: Fri May 24, 2002 6:20 am    Post subject: funny hex like chars when reading xml msgs from a queue Reply with quote

Novice

Joined: 16 May 2002
Posts: 15
Location: UK

HI folks, I'm having a problem reading an xml message from a queue using Java.

Basically when I read the message off the queue and write it as a string out to a file or the screen I see some funny hex like chars at the beginning before the xml declaration. If I pass this to the xml parser this causes the parser to spit it out. Basically I see the following:

¬&#8216;<?xml version="1.0 etc...

I can take the string from the first opening tag and the parser is happy but I'd much rather not and I'm sure there is some explanation for this.

Any ideas ?

Thanks very much...
Back to top
View user's profile Send private message
StefanSievert
PostPosted: Fri May 24, 2002 10:30 am    Post subject: Reply with quote

Partisan

Joined: 28 Oct 2001
Posts: 333
Location: San Francisco

Hi,
where is the message coming from? can you ensure that the sending application does not put those 8Bytes in front of the XML document?
If you use amqsbcg to browse the queue with such a message, do you see the same 8 Bytes in the message data? What platforms are involved?
Cheers,
Stefan
_________________
Stefan Sievert
IBM Certified * WebSphere MQ
Back to top
View user's profile Send private message
nr525
PostPosted: Mon May 27, 2002 2:34 am    Post subject: Reply with quote

Novice

Joined: 16 May 2002
Posts: 15
Location: UK

I can see the problem when getting messages put onto the queue using a test program to put the message.

Current levels:
OS: Solaris 2.7
Java: 1.1.3 or/ 1.3.1_02
MQSeries: 5.2.1

I can put an xml message out there using a C program and browse this and it looks fine. When I put the message out using a Java program and browse this using amqsbcg, the message I get has the extra leading chars.

Let me know if you need any more info.
Back to top
View user's profile Send private message
nr525
PostPosted: Tue May 28, 2002 7:03 am    Post subject: Reply with quote

Novice

Joined: 16 May 2002
Posts: 15
Location: UK

Okay I figured this out... A simple error really but It didn't jump out at me unfortunately..Here we go...

When I put the message to the queue I was using writeUTF,
but
When I used a different Java program to read the message back from the queue I was only using
read(retrievedMessage.getMessageLength());where I should have used
readUTF();In this way we do not read the funny hex char, but this is no good when passing to MQSI for example, so I decided to use
writeBytes(); instead.

Just to finish off heres a description of the difference as I understand it now, from RTFM-ing;

The problem stems from the way we handle the message within the program. Unlike the procedural interface where you put and get arrays of bytes, the Java language puts and gets instances of the MQMessage class. This class encapsulates the data buffer which contains the message data together with the MQMD, which describes the message. When we build a new message in java, we create an instance of the MQMessage class and write this to put data into the message buffer. We can use a variety of write's to do this, for example;

writeUTF
writeInt
writeBytes
etc....

Thus this is our problem, we were writing using writeUTF, but if we use writeBytes, similar to the procedural way the funny chars disappear!
Back to top
View user's profile Send private message
StefanSievert
PostPosted: Tue May 28, 2002 11:59 am    Post subject: Reply with quote

Partisan

Joined: 28 Oct 2001
Posts: 333
Location: San Francisco

In the end everything is right. If not, it's not the end!
Glad it works now!
Stefan
_________________
Stefan Sievert
IBM Certified * WebSphere MQ
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » funny hex like chars when reading xml msgs from a queue
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.