Social Media

Contract First vs Contract Last

There are 2 approaches to defining SOAP web services –

  • Contract First – create wsdl first
  • Contract Last – code first, and wsdl generated from code

Apache CXF supports both contract first and contract last, but Spring WS only supports Contract First

The preferred approach is Contract First, but here is a list of the advantages and disadvantages of each approach.

Contract First


  • Easy for both producer and consumer to see what the contrat is.
  • Reuse schema’s and xsd’s
  • Could resuse interface if you change language at some point, eg you start developing in ruby, and then later want to switch to java


  • Need to learn a new skill – WSDL and XSD

Contract Last


> Retrofit on existing class


  • Object-to-XML impedance mismatch – simply put XML != Java Objects. A good example being the difficulty exporting Map’s
  • Code changes may cause WSDL changes
  • No guarantee what is being sent when Java object converted to XML


About the Author Martin Farrell

My name is Martin Farrell. I have almost 20 years Java experience. I specialize inthe Spring Framework and JEE. I’ve consulted to a range of businesses, and have provide Java and Spring mentoring and training. You can learn more at About or on my consultancy website Glendevon Software

follow me on:

Leave a Comment: