Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET to Java serialization/deserialization compatibility

Are there any compatibility issues to take care of when serailizing an object in .NET and then deserializing in Java?

I am facing problems in de-serializing an object in java which has been serialized in .NET

Here is the detailed problem statement:

In .NET platform i have a cookie. 1. Cookie is serialized 2. then it is encrypted using Triple DES algo. 3. Send it across to Java application

In Java platform 1. Decrypt the cookie using Triple DES which gives some bytes 2. Deserialize the bytes using something like

new ObjectInputStream( new ByteArrayInputStream(byte[] decryptedCookie)).readObject();

The exception stack trace I get is: java.io.StreamCorruptedException: invalid stream header: 2F774555 at java.io.ObjectInputStream.readStreamHeader(Unknown Source) at java.io.ObjectInputStream.(Unknown Source)


2 Answers

The WOX serializer provides interoperable serialization for .Net and Java.

like image 180
Eric J. Avatar answered Apr 10 '26 17:04

Eric J.


If you serialize in xml then you shouldnt face any problems de-serializing in java since at worse you have to write your own bit of code to reconstruct the objects.

like image 34
Daniel Avatar answered Apr 10 '26 15:04

Daniel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!