Need a good XSD-to-Java class generator


So far I’ve tried Castor and I’ve tried XBeans.  Two more downloads, and once again I’m reminded that every class in Java must exist in its own file.  The result of trying to use Castor to generate code from an XSD that describes two complex types?  Four class files … one for each complex type definition and one for each top-level element that is of one of the given complex types.  I haven’t got XBeans working yet as I’ve got some issue with my CLASSPATH at the moment.

Why do I want an XSD-to-Java class generator?  I’m a firm beleiver in message-first design for Web services.  While it doesn’t guarentee interoperability as there are still some wierd differences between Java and .NET (i.e, datetime’s are reference types in Java and value types in .NET, the former which can be nillable and the later which complains if they are), it does make it possible for both sides to share the same base definition of the messages we want to send back and forth.

So, while I have the capability right now to cons up any Java class I want and have Axis 1.2 alpha serialize the class to XML, I don’t trust myself to create Java classes that are compatible with .NET.  Gimme a shout if anyone has some good guidance!


Comments (4)

  1. Kris says:

    Have you tried JAXB(Java XML Binding). It comes with the JWSDP (Java WebServices Developers Pack) from Sun. I think the current version is 1.4. I make use of it extensively in my project. When you compile the schema with jaxbc compiler, it generates both interfaces and implementations. You can the marshall and unmarhall these interfaces to spew out or consume XML. The API is a little cumbersome to use, but once you become familiar, it should be okay. I dont know how well it interoperates with .NET as I only had to interoperate with Java based applications.

  2. Did you try XmlSpy’s code generation feature? Honestly, I do not know a lot about its quality. And I think there is also a tool in the Axis package.

    Finally, I hope on the .NET side you use this tool:

    http://www.thinktecture.com/resources/software/wscontractfirst/default.html

    😉

    Cheers,

    Christian

  3. Ron says:

    Hello —

    I think JAXB is what you are looking for.

    IBM’s Eclipse foundation has something called EMF which is actually really good, but sounds more complicated than you need.

  4. Sai says:

    Guess JaxB requires JDK 5 .Cant run on earlier versions of JDK..

    Anyother solution which can be used with jdk1.4.1_02/1.4.1_03