2

I've to get data from web service. But web service request is serialized instance of C# class DataTable. Is there any ability to convert it into any java class?

Thanks

stemm
  • 5,960
  • 2
  • 34
  • 64
  • please look at [this](http://stackoverflow.com/questions/1340283/c-datatable-equivalent-in-java) link. I hope this will help. – Asad Rasheed Jun 30 '11 at 09:43
  • Thanks. Is that means, that I could simply convert received C# serialized object into instance of java object?? – stemm Jun 30 '11 at 09:52

3 Answers3

5

(I'm assuming the server uses the default .NET serializer.)

The .NET and Java serializer are incompatible, so you can't deserialize the C# class to Java.

To connect the C# server to the Java client, you have to use a compatible serialization library on both platforms. One example is WOX, as of this answer to a similar question. (This is an XML serializer, so there will be considerable overhead.)

Community
  • 1
  • 1
Tamschi
  • 1,089
  • 7
  • 23
  • Thanks a lot. I don't have access to server, so I can't to patch it with WOX. So it means that there is no way to convert it reply into java object? – stemm Jun 30 '11 at 10:01
  • 1
    You could run a .NET proxy-application on the client that connects to the server and translates the objects for the java client. The .NET default serialization format doesn't seem to be public, so it's probably not a good solution to parse it in Java for production use. – Tamschi Jun 30 '11 at 11:19
0

As pointed out in other answers you need to use a cross platform serialization library like wox (https://github.com/codelion/wox). Wox will allow you to serialize your objects in Java and deserialize them in C# (or vice versa).

codelion
  • 1,056
  • 1
  • 11
  • 17
0

You could use a

Code:

java.sql.ResultSet

object which is pretty close to what you want in C#.

Something like

Code:

Statement s = conn.createStatement(); ResultSet rs = s.executeQuery("select * from generic_table"); ResultSetMetaData md = rs.getMetaData();

Rupok
  • 2,062
  • 16
  • 16
  • Thanks, but my problem is that web service request is serialized C# class DataTable. How can I convert it into java class? – stemm Jun 30 '11 at 09:40