When using a contract-last approach, you start with the Java code, and let the Web service contract (WSDL, see sidebar) be generated from that.When using contract-first, you start with the WSDL contract, and use Java to implement said contract. Our business partner has clients that needs to subscribe with our magazine.
Here's our XSD document: This XSD is comprised of simple and complex element types.
Each simple element has been assigned with restriction.
Let's map this document to a Subscription Request class: Subscription Request For every request sent by the client, we send a response.
We declare a Subscription Response object: Our marshaller will automatically convert this class into an XML document.
The product is based on Spring itself, which means you can use the Spring concepts such as dependency injection as an integral part of your Web service.
Source: Spring WS Reference 2.0When creating Web services, there are two development styles: Contract Last and Contract First.First let's see the actual XML document that is sent to us by the client: Take note that this XML format is not arbitrary!The client has to honor the format that we declared in the XSD document.Source: Spring WS Reference 2.0For an in-depth look of Spring WS, I suggest my readers to visit the Spring WS Reference 2.0 and the Spring WS API 2.0.0. To expose this feature, we decided to use a web service.Our contract is that the clients will send the following information: Since all web services are ultimately XML message, we need to define the format of our messages. If you're not familiar with XSD, please see the excellent XSD tutorial w3XML Schema Tutorial.If you look at the XSD file, we have declared a subscription Response element.