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.
- 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
> 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