2008/9/25 Jim Morris <ml / e4net.com>:
> Serge Savoie wrote:
>>
>> Ok, I have experiment a lot and found that :
>>
>> When the Java Server use :
>>  ¨ÂòåñõåóôÓïãëåô®çåôÉîðõôÓôòåáí¨©>>
>> It works... I can read what the Ruby socket is sending...
>>
>> But the real Java server that I have to talk with use :
>>
>>  ¨ÂîåÏâêåãôÉîðõôÓôòåáí¨ îåÂõææåòåäÉîðõôÓôòåáí¨
>> requestSocket.getInputStream() ) );
>>
>> And in this case I get :
>>
>> java.io.StreamCorruptedException: invalid stream header
>>  ¨Âêáöá®éï®ÏâêåãôÉîðõôÓôòåáí®òåáäÓôòåáíÈåáäåò¨ÏâêåãôÉîðõôÓôòåáí®êáöặµ³©
>>  ¨Âêáöá®éï®ÏâêåãôÉîðõôÓôòåáí®¼éîéô¾¨ÏâêåãôÉîðõôÓôòåáí®êáöẲ¶¸©
>>  ¨Âðòïêåãô±®ÓåòçåÓåòöåò±®íáéî¨ÓåòçåÓåòöåò±®êáöẴ´©
>
> The Java server is reading a Marshalled Java object, Usually that will only
> be used for two Java processes talking to each other.

Exactly.  Java and Ruby do *not* share a common serialization format.
You must take measures to explicitly handle serialization formats - or
more generally define the protocol you want to use on that connection.

> If you are sending very simple Java Objects you could format it in Ruby and
> transmit it, but it would be messy. You will have to read the Sun documents
> on Java serialized object formats, look at the ObjectInputStream Javadoc for
> references to the required formats.
>
> Try using JRuby instead and serialize the Java object in Java.

There are more alternatives:

- use one of the many XML serialization packages around,
- generally use a SOAP API,
- use YAML on both ends.

Kind regards

robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/