Search code examples
javaweb-servicesjakarta-eewsdlsoa

WSDL to Java or Java to WSDL?


I've recently picked up a project which has a rather nasty build process. Hand coded XSD schemas are read by JAXB to generate a Java model of classes and factories, which is used in hand coded Java web service classes (annotated), which are then deployed to a server, which is used as a source to read the complete WSDLs from in order to generate a second Java based model which includes the service and factory classes for the complete WSDL, which is used in client programs.

This sounds aweful and I don't think I need it to be so complicated so at some stage I'd like to chuck all this away and either

  • Hand craft the WSDLs, generate a full model and add service code.
  • Or - Write the service and model classes and generate WSDLs as necessary on the server at run time.

Either way I want to end up with one source base for the model which both the server and clients can use and have one "source of truth" for what the model should be, where as at the moment I feel like I have several.

At the moment I'm leaning towards the second option, but which would you choose? And which technologies would you use?


Solution

  • In the project I'm working on, we're currently redoing our web services completely. These services offer server functionalities to clients via SOAP. From what I've learned looking at all the intricacies of that protocol, which highly affect the layout of the WSDL, I'd rather not write a WSDL myself. There are so many things you can get wrong (especially when it comes to things like parameter style and all that). And once your WSDL "is out there" and clients generated from that WSDL are happily communicating with your application you can no longer change it again (or you start thinking about a versioning strategy, which can turn out to be quite painful as well).

    So my strong suggestion is to write your service code in Java and let your library generate a WSDL for you. You can then very easily play around with different binding styles (which in turn affect interoperability with other clients). A very thorough article describing all of that can be found here:

    http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/

    Additionally, WSDLs are not particularly readable for humans and therefore (at least in my view) harder to maintain by humans. Java code on the other hand is fairly easy to read (or at least you can write it that way) which is a even better reason to handcraft the Java code and not the WSDL.

    Hope that helps in making your decision.