News Stay informed about the latest enterprise technology news and product updates.

Spring Web Services 1.0 focuses on 'contract-first'

The 'contract-first' focus in Spring Web Services 1.0 gives developers flexibility and the loose coupling needed for SOA applications, its creator said.

The "contract-first" approach to Web services creation provides developers with the right path to service-oriented architecture (SOA), says the creator of Spring Web Services 1.0 released this week by Interface21 Ltd., the company behind the Spring framework.

The long-awaited release of Spring Web Services is an exciting development for the Java world, and the contract-first development style is one of the most important aspects of the release.
Jason Bloomberg
Senior AnalystZapThink LLC.

The new Spring Web Services framework, which was two years in the making, grew out of a desire to create tools for building Web services "the right way," said Arjen Poutsma, project lead for Spring Web Services. He defined the right way as being contract-first.

Jason Bloomberg, senior analyst with ZapThink LLC, agreed.

"The long-awaited release of Spring Web Services is an exciting development for the Java world, and the contract-first development style is one of the most important aspects of the release," the analyst said.

"Contract-first Web services development is where you define the interface of your Web service in a contract," Poutsma said. "A contract is typically a schema, such as a WSDL file."

Two approaches to building Web services in Java
Contract-first is one of two basic approaches to building Web services in Java, Poutsma explained. One way is to start with the Java Class and make it into a SOAP service, which basically generates the contract from the Java Class. But he said that approach is not flexible and does not lend itself to loose coupling needed for SOA applications.

"If you implement your contract in a Java Class, it's really hard to be a little more liberal about the kinds of SOAP messages or XML messages that come in," he said.

The second way to build Web services is the contract-first development style, which is the only approach supported in Spring Web Services, Poutsma said.

"In the contract-first development style, you define what your XML messages are," he explained. "With Spring Web Services, you can handle the incoming XML any way you want to. We focus on XML because in the end Web services are all about interoperability, and interoperability means XML."

Bloomberg said contract-first is very important for SOA and agreed with Poutsma that it is the best of the two Java development choices for Web services. Bloomberg called "contract-first "an essential part of building Web services in support of a SOA initiative."

"The traditional approach to building Web services with Java is contract-last, where the Java code determines the WSDL contract," Bloomberg said. "The resulting Web services often perpetuate issues with the Java environment and can also lead to needless contract changes, which can severely impede loose coupling. The resulting Web services are generally ill-suited for SOA. With contract-first development, the WSDL file determines the behavior of the service, enabling architects to control contract change as part of their SOA implementation."

For more information
Check out our SOA Learning Guide

How SOAP and WSDL work together

Since Poutsma began initial work on Spring Web Services two years ago, other Web services tools have appeared on the market that include the contract-first approach. But none focuses on it in the laser-like way Spring does, he said.

"Spring Web Services is also designed to help SOA developers follow best practices to support loose coupling," Poutsma added.

Additional features of Spring Web Services 1.0 include the following:

  • Mapping capabilities: Incoming XML requests can be distributed to any object, depending on message payload, SOAP Action header, or an XPath expression.
  • XML API support: Incoming XML messages can be handled in standard JAXP APIs such as DOM, SAX and StAX, but also JDOM, dom4j, XOM or even marshalling technologies.
  • XML marshalling: The Object/XML Mapping module in the Spring Web Services distribution supports JAXB 1 and 2, Castor, XMLBeans, JiBX and XStream. Because it is a separate module, it can be used in non-Web services code as well.
  • Reuse of Spring Framework concepts: Spring Web Services uses Spring application contexts for all configurations.
  • WS-Security support: This allows developers to sign SOAP messages, encrypt and decrypt them, or authenticate against them.
  • Integration with Spring Security: The WS-Security implementation of Spring Web Services provides integration with Spring (Acegi) Security, enabling developers to use existing configuration for SOAP service as well.

Among features being worked on for the next release of Spring Web Services is support for Representational State Transfer (REST), Poutsma said.

Dig Deeper on Topics Archive

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.