开发者

Generating Java data classes from C# data classes - is there an existing tool / method?

开发者 https://www.devze.com 2023-04-11 03:58 出处:网络
开发者_JAVA百科I\'m writing a java client for a WCF REST service. This service uses lots of different data classes for communication, transmitted in JSON. On my side, I\'m using the Gson lib to do han
开发者_JAVA百科

I'm writing a java client for a WCF REST service. This service uses lots of different data classes for communication, transmitted in JSON. On my side, I'm using the Gson lib to do handle the serialization of these classes. However for this to work, I obviously need the Java definitions of the used C# classes.

Currently I'm writing these by hand: I check the C# class definitions, check which property has a [DataMember] annotation and create a corresponding java class with those properties. This is a terrible solution: it's slow, tedious and difficult to keep these classes up to date manually.

What tools / method should I use to generate these classes somehow from their C# counterparts? Is writing some .net console app that generates java classes using reflection the only solution?


You can try a tool like wsdl4j to create a proxy java file and just use the class definitions in it.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号