| Author | 
		  Message
		 | 
		
		  | kendras | 
		  
		    
			  
				 Posted: Wed Dec 20, 2006 7:35 am    Post subject: .NET and J2EE Interoperability using WebSphere MQ | 
				     | 
			   
			 
		   | 
		
		
		   Novice
 
 Joined: 31 Jan 2006 Posts: 12
  
  | 
		  
		    
			  
				Hi guys,
 
 
I've a .Net Client whitch put a message on a mq file, and a java client that read the message.
 
I've got an error. I think that is due to the a problem of interoperability.
 
 
I've read this article : A Basic .NET and J2EE Interoperability using WebSphere MQ, and try their samples, but it does not work at all.
 
 
Is there somebody to help me ?
 
 
Thanks | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | Vitor | 
		  
		    
			  
				 Posted: Wed Dec 20, 2006 7:39 am    Post subject: Re: .NET and J2EE Interoperability using WebSphere MQ | 
				     | 
			   
			 
		   | 
		
		
		    Grand High Poobah
 
 Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA 
  | 
		  
		    
			  
				
   
	| kendras wrote: | 
   
  
	| Is there somebody to help me ? | 
   
 
 
 
There are really quite a few of us.    
 
 
Something a bit more detailed than "I've got an error" would get a more helpful response. Also details of what version of MQ & .NET you're using would be nice. _________________ Honesty is the best policy.
 
Insanity is the best defence. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | kendras | 
		  
		    
			  
				 Posted: Wed Dec 20, 2006 7:44 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Novice
 
 Joined: 31 Jan 2006 Posts: 12
  
  | 
		  
		    
			  
				Yeah of course    
 
 
My original message is :
 
   
	| Code: | 
   
  
	<balise>
 
      <pouet>test</pouet>
 
</balise> | 
   
 
 
 
When i write with the WriteString method (queueMessage.WriteString( message ) ), the java client get a message like this :
 
   
	| Quote: | 
   
  
	<balise>
 
      <pouet>test</pouet>
 
</balise>?>?>?>?>?>?>?>?>?>?>?>?>?>?>?>?>?>?>?>?>? | 
   
 
 
 
 
If i use WriteUTF( message ) (queueMessage.WriteUTF( message )), an error is occured in the java client
 
An IOException occured while writing to the message buffer: java.io.EOFException
 
 
(sorry for my language, i'm french    ) | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | jefflowrey | 
		  
		    
			  
				 Posted: Wed Dec 20, 2006 7:49 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Grand Poobah
 
 Joined: 16 Oct 2002 Posts: 19981
  
  | 
		  
		    
			  
				How long is "message"?
 
 
You will use WriteString, you will not use WriteUTF. _________________ I am *not* the model of the modern major general. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | fjb_saper | 
		  
		    
			  
				 Posted: Wed Dec 20, 2006 3:44 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Grand High Poobah
 
 Joined: 18 Nov 2003 Posts: 20768 Location: LI,NY 
  | 
		  
		    
			  
				And remember string conversions in .NET where the default is unicode and not UTF-8....
 
 
Make sure when you write to the queue that the buffer is clean. Always clear/initialize the buffer before setting the message content into the buffer.
 
Always make sure the buffer length is correct before starting the put operation...    _________________ MQ & Broker admin | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | kendras | 
		  
		    
			  
				 Posted: Thu Dec 21, 2006 1:08 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Novice
 
 Joined: 31 Jan 2006 Posts: 12
  
  | 
		  
		    
			  
				My message lenght is 36.
 
   
	| Code: | 
   
  
	| String message = "<balise><pouet>test</pouet></balise>"; | 
   
 
 
 
First Test :
 
   
	| Code: | 
   
  
	| queueMessage.WriteUTF( message ); | 
   
 
 
 
On The WMQ Server, my message is received as :
 
   
	| Quote: | 
   
  
	| $ <balise><pouet>test</pouet></balise> | 
   
 
 
 
=> Lengh : 38 ($ and a space have been added at the begining, i don't know why)
 
   
	| Code: | 
   
  
	24 00 3C 62 61 6C 69 73  $.<balis
 
65 3E 3C 70 6F 75 65 74  e><pouet
 
3E 74 65 73 74 3C 2F 70  >test</p
 
6F 75 65 74 3E 3C 2F 62  ouet></b
 
61 6C 69 73 65 3E        alise>  | 
   
 
 
 
Second Test :
 
   
	| Code: | 
   
  
	| queueMessage.WriteString( message ); | 
   
 
 
 
On The WMQ Server, my message is received as :
 
   
	| Quote: | 
   
  
	| <balise><pouet>test</pouet></balise> | 
   
 
 
 
=> Lengh : 72 (i don't know why, it add 00 between char)
 
 
   
	| Code: | 
   
  
	3C 00 62 00 61 00 6C 00  <.b.a.l.
 
69 00 73 00 65 00 3E 00  i.s.e.>.
 
3C 00 70 00 6F 00 75 00  <.p.o.u.
 
65 00 74 00 3E 00 74 00  e.t.>.t.
 
65 00 73 00 74 00 3C 00  e.s.t.<.
 
2F 00 70 00 6F 00 75 00  /.p.o.u.
 
65 00 74 00 3E 00 3C 00  e.t.>.<.
 
2F 00 62 00 61 00 6C 00  /.b.a.l.
 
69 00 73 00 65 00 3E 00  i.s.e.>. | 
   
 
 
 
 
Java client can't get both message... | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | Vitor | 
		  
		    
			  
				 Posted: Thu Dec 21, 2006 1:20 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Grand High Poobah
 
 Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA 
  | 
		  
		    
			  
				Disclaimer - I know very little about Java. I could be talking rubbish.
 
 
1st test - it may just be a freaky coincidence, but X'24' = 36 in decimal, the length of your message without what looks like a little endian integer on the front of it-it's not a space it's a null, so is actually X'0024'. I think it's a length indicator been added by some means (buffer length incorporated into message??)
 
 
2nd test - you get that when unicode (double byte) is interpreted as a string. Possibly the other way round. 
 
 
I think you need to sit down, work out how to set the code page on both sides, set a common string strategy (like write.String as per jefflowrey and make both sides common. _________________ Honesty is the best policy.
 
Insanity is the best defence. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | kendras | 
		  
		    
			  
				 Posted: Thu Dec 21, 2006 1:33 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Novice
 
 Joined: 31 Jan 2006 Posts: 12
  
  | 
		  
		    
			  
				AHHH YESS
 
 
I've found the method !
 
 
In my .Net client, i've used the WriteBytes Method, and on the java client, i've used the ReadString method, and it's work.
 
 
Thanks lot for help | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | Vitor | 
		  
		    
			  
				 Posted: Thu Dec 21, 2006 1:37 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Grand High Poobah
 
 Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA 
  | 
		  
		    
			  
				
   
	| kendras wrote: | 
   
  
	
 
I've found the method !
 
 | 
   
 
 
 
If it works, it's a solution. Well done you.
 
 
   
	| kendras wrote: | 
   
  
	
 
Thanks lot for help
 
 | 
   
 
 
 
You're welcome.    _________________ Honesty is the best policy.
 
Insanity is the best defence. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | fjb_saper | 
		  
		    
			  
				 Posted: Thu Dec 21, 2006 2:52 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Grand High Poobah
 
 Joined: 18 Nov 2003 Posts: 20768 Location: LI,NY 
  | 
		  
		    
			  
				
   
	| kendras wrote: | 
   
  
	AHHH YESS
 
 
I've found the method !
 
 
In my .Net client, i've used the WriteBytes Method, and on the java client, i've used the ReadString method, and it's work.
 
 
Thanks lot for help | 
   
 
 
Use the search button. You weren't listening. 
 
The .NET default is CCSID 1200 (or unicode or utf-16) and has 00 in front of the char...
 
In order to write in UTF-8 you need to  use some specific method or use something like .writeascii()(CCSID437)...
 
Anyways it should make no difference to your JMS/java app. Just have the format  on the message set to MQSTR and set the correct CCSID and encoding on the message.
 
 
Remember to do a read with convert in base java
 
 
Enjoy    _________________ MQ & Broker admin | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | 
		    
		   |