What's New in Spring Web Services 1.5?

Arjen Poutsma

After being in the works for about six months, I'm happy to announce that Spring Web Services 1.5.0 has been released! In this post, I'd like to go over some of the major new features.

New Transports

The 1.5 release includes two new transports: JMS and email. Using these new transports requires no Java code changes: just add a bit of configuration, and you're off! The JMS transport integrates nicely with Spring 2's Message-Driven POJO model, as indicated by the following piece of configuration taken from the airline sample application:

<jms:listener-container connection-factory="connectionFactory">
  <jms:listener destination="RequestQueue" ref="messageListener"/>
</jms:listener-container>

<bean id="messageListener" class="org.springframework.ws.transport.jms.WebServiceMessageListener">
  <property name="messageFactory" ref="messageFactory"/>
  <property name="messageReceiver" ref="messageReceiver"/>
</bean>

Besides the standard JMS configuration (connection factory and destination name to listen to), you only have to define a WebServiceMessageListener, and give it a reference to the message factory you're using (typically the SaajSoapMessageFactory), and the message dispatcher. If you're still stuck in EJB land, there's even a MessageDrivenBean for you to use! Check the airline sample or reference documentation for more details.

On the client side, it's just as easy. Configure the WebServiceTemplate to use a JmsMessageSender, and specify a jms: URL to send the message to. Here's an example, once again taken from the airline sample:

<bean id="jmsClient" class="org.springframework.ws.samples.airline.client.jms.JmsClient">
  <property name="defaultUri" value="jms:RequestQueue"/>
  <property name="messageSenders">
    <bean class="org.springframework.ws.transport.jms.JmsMessageSender">
      <property name="connectionFactory" ref="connectionFactory"/>
    </bean>
  </property>
</bean>

Besides the JMS transport, Spring Web Services 1.5 introduces an email transport, thereby conforming to Zawinski's Law of Software Envelopment ;) . This transport will poll your POP3 or IMAP server for new messages, or—if your server supports it—use the IMAP IDLE command to receive new messages asynchronously.

WSS4J-based WS-Security implementation

Another new feature is the Apache WSS4J-based WS-Security implementation. In 1.0, Spring Web Services already had a WS-Security implementation based on SUN XWSS, but that required Java 1.5, and only worked on SUN JDKs. The WSS4J-based solution works on JDK 1.4 (as does the rest of Spring-WS), and also IBM JDKs used for WebSphere.

See the reference documentation for more details.

WS-Addressing support

WS-Addressing is a W3C specification that defines a transport-neutral routing mechanism. It is based on a To and Action SOAP header, which indicate the destination and intent of the SOAP message, respectively. Spring Web Services 1.5.0 implements both the 1.0 (May 2006) version of the WS-Addressing specification, as well as the August 2004 version, which is still in wide use.

You can configure WS-Addressing either through XML, in an application context, or through annotations:

package samples;

import org.springframework.ws.server.endpoint.annotation.Endpoint;
import org.springframework.ws.soap.addressing.server.annotation.Action

@Endpoint
public class AnnotationOrderEndpoint {
  private final OrderService orderService;

  public AnnotationOrderEndpoint(OrderService orderService) {
    this.orderService = orderService;
  }

  @Action("http://samples/RequestOrder")
  public Order getOrder(OrderRequest orderRequest) {
    return orderService.getOrder(orderRequest.getId());
  }

  @Action("http://samples/CreateOrder")
  public void order(Order order) {
    orderService.createOrder(order);
  }

}

In this case, if a WS-Addressing message comes in with a Action header value http://samples/RequestOrder it will invoke the getOrder() method. You can check the stockquote sample or reference documentation for more details.

Another neat new feature is that @Endpoints are now annotated with @Component, so if you are using Spring 2.5 component scanning, your endpoints are picked up automatically, and require no XML configuration! For configuration of Spring-WS components, we now offer two new namespaces, to configure OXM marshallers and other common constructs. For example, here is the configuration of a JAXB2 marshaller:

<oxm:jaxb2-marshaller id="marshaller" contextPath="org.springframework.ws.samples.airline.schema"/>

Other New Features

Spring Web Services 1.5 also introduce the following other new features:

  • Native support for Java 6, including JAXP 1.4, and the bundled SAAJ 1.3 and JAXB 2.0, as well as the embedded HTTP server. See the stockquote sample for more details,
  • Spring-WS jars are now OSGi bundles, making them easier to use in your OSGi-based application,
  • A new and improved XSD-to-WSDL generator that inlines included and imported XSDs, thus making your WSDL easier to serve for clients which don't follow these references,
  • A new, client-side interception mechanism, including WS-Security support, and
  • Support for Spring Security

More Information

If you want to give Spring Web Services 1.5 a shot, you can go to the site, or directly to the download section.

Update 2008-04-18: changed JMS configuration to use namespace.

 

16 responses


  1. The law of Zani…what? ;-) .

    Anyway, good stuff… as always!

    What about using the XML simplification instead of the more verbose language…


  2. Okay, XML elements in comments don't work. I was saying, what about the jms:listener-container element instead of using the more verbose beans config schema?


  3. Why do you insist on 'contract-first' approach? Why not to see the world as 'WSO2 for Spring' does? I've always felt that SpringSource chooses the best and also the most relax solutions but do not feel that the same approach is followed here in 'Spring Web Services'.


  4. Hello Arjen,

    congratulations to the new release!

    We're currently evaluating WebService frameworks for a new project. Is there some documentation regarding Spring WebServices and attachments? Unfortunately, neither the reference documentation nor the samples seem to contain something in that direction.

    Regards, Ollie


  5. @Alef,

    You cannot use the jms:listener-container yet, because of SPR-4590. As soon as Spring 2.5.3 is out, you can and I will update the snippet.


  6. @Amin,

    Spring and the other portfolio products focus on best practices, and making those practices as simple as possible. Contract-first is widely considered a best practice, so we focus on that. For more information, read Alef's Spring: simple, not simplistic blog post, or the Why Contract first? section in the reference documentation.

    @Oliver

    Spring Web Services supports base64 inlined attachments (slow, but very interoperable), SOAP with Attachments (mainly used in Java), and MTOM (the new kid in town, and therefore not widely supported yet). There is a sample application called mtom that shows you how to use the JAXB2 marshaller to marshal byte arrays and other attachments directly to the MTOM SOAP message; for SwA attachments it's as simple as calling addAttachment on the SoapMessage.


  7. Looks good and I am especially happy to see you are distributing them as OSGi bundles! Looking into collaboration between our CMS service component model and Spring DM for integration will be my next hobby project :)

    Regards,
    Bram


  8. Is there support for RESTful web services in this version?


  9. @Camilo,

    Our REST efforts will not be part of Spring -WS, but of Spring-MVC. See http://jira.springframework.org/browse/SPR-4419.


  10. I'm trying to use spring-ws in an osgi environment. It would be great if a simple example could be given. But as i struggle to do it myself, spring-ws bundle org.springframework.bundle.ws.support expects framework bundles from 2.0.0 to 2.5.0, but i have 2.5.3 and so the dependencies aren't found.


  11. [quote post="304"]I'm trying to use spring-ws in an osgi environment. It would be great if a simple example could be given. But as i struggle to do it myself, spring-ws bundle org.springframework.bundle.ws.support expects framework bundles from 2.0.0 to 2.5.0, but i have 2.5.3 and so the dependencies aren't found.[/quote]

    Yeah, that's a known issue. Will be fixed in 1.5.1.


  12. Ok, thanks. So i unzipped all the spring-ws jars, and modified the manifest to say 2.0-2.6. I also created osgi bundles for activation, stax and wsdl4j. Now all the bundles start up fine, and jetty starts as well. I tried to take the echo sample and use that. But when i hit any page, say for instance http://mbfg:9999/spring-ws/echo.wsdl

    all i get on the browser is

    HTTP ERROR: 404
    ProxyServlet: /spring-ws/echo.wsdl
    RequestURI=/spring-ws/echo.wsdl

    Powered by Jetty://

    —-

    How does one even begin to debug what is wrong?


  13. Hello Arjen,

    congratulations to the new release - we suppose to apply Spring-WS on a large financial transaction platform due to the new support of WS Security. So if you may are interested in user feedback (especially concerning WS Security) - would be no problem.

    Side Note: the documentation is very comprehensible. Well done!

    Greetings

    Mario


  14. Hello ! One foundation stone of the propagation of web services has been the ability to take a WSDL file for any web service and generate the appropriate web service client painlessly (a classic case of web service standards facilitating, not constraining) the machinations of enterprise application integration. There are an army of web service client tools out there now of course, we're using SOAPUI just now to test document literal web services. In this context, the reason for this note is a plea to consider extending WSDL support to make spring-ws more useful in current (WS-I compliant) web service environments. Essentially I am a little confused at the Dynamic WSDL implementation (DefaultWsdl11Definition replacing DynamicWsdl11Definition) since the WSDL is incomplete in the sense it can not be used in web client generation tools here since there is no Message Exchange Pattern abstraction to support the message definition. I think this is by design but this ommission fundamentally constrains our usage of Spring-ws since I can not leverage any of the existing web service client mechanisms (in place from the WS-I/WSDL conventions) for standing applications, without having to change web service client implementations to accommodate the simple message (xsd schema) driven definition of the facade. So 'lightweight' becomes 'limited-use' in standing environments where Web Service industry standards in competing tools deployed today do facilitate simple deployment transparently incoporating the power of Web Service Standards based compliance.
    In this case a workaround could subclass the Spring type and introduce declarative support to add 'operations' (MEP) support to dynamically generate a meaningful WSDL (WS-I compliant) WSDL.

    Secondly, i'll completely leap out on a limb here and suggest briefly a list of ESB characteristics that a 'lightweight' extensible Message Bus would likely accommodate, (a screaming need for spring imho since the fundamental demand for facilitating mechanisms of enterprise business integration has not gone away :}

    1 Viable definition of an SOA Architecture & Infrastructure for Web Services
    2 Definition of ESB Platform technologies and standards (adopted)
    3 Web Service Messaging (WS-Interoperability compliant SOAP/WSDL/HTTP/XML)
    4 Web Service Registry & Repository (Web Service Metadata Lookup, Classification and Administration)
    5 Reliable, consistent and uniform data exchange mechanisms and protocols
    6 Support for asynchronous Message Exchange Patterns (MEP) facilitating Reliable Messaging Web Service standards (SOAP over JMS etc)
    7 Dynamic and transparent content-based & rules-based message routing
    8 Web Service location transparency (rules based)
    9 Web Service Composition - transparent Business Service to implementation service(s) coordination and dynamic management
    10 Protocol mediation and translation
    11 Message data transformation capabilities (e.g. consistent with Common Data Model, Double Transformation Model etc)
    12 Security connection and message level technologies, Access & SSO capabilities, Identity Management (SSL/TLS & XML Message Security/Ws-Security/SSO/SAML etc)
    13 Web Service BAM /Monitoring /Metering /Configuration /Administration…
    14 Event Model Support
    15 Pluggable Validation and metadata abstraction technologies
    16 Strategy for Business Process Modelling & Process Orchestration

    Thanks for yout time and keep up the great work !!!

    Regards Gavin Bayfield
    Spring Certified Professional


  15. @Dave:

    It might be best to move this discussion to the community forum, because there are more people who can answer it.

    @Mario:

    Thanks!

    @Gavin:

    Wow, that's a lot of suggestions! :) Some of these are more related to Spring Integration than Spring-WS. Spring Integration will have Spring-WS adapters soon, so they will nicely play together. As for implementing more specs: I am always a bit reluctant with them, because adding more WS-* specs doesn't necessarily increase interoperability.

    Finally, I am not entire clear why the WSDLs generated by DefaultWsdl11Definition are incomplete. I go through great lengths to tests these WSDLS for interoperability with all the major platforms (Axis, .NET, WIndows Communication Foundation, etc.). If it is not sufficient, than note that the XSD to WSDL generation is much more pluggable than it used to be: it's now quite easy to change a specific part of the WSDL by using the *Provider mechanism. The DefaultWsdl11Definition is just a convenient wrapper around these providers, for the common case.


  16. Hey Isn't Hot news for the people. Now Spring Web Services has released Its 1.5.0 after being worked for six months. congrats to Arjen for this success….

5 trackbacks

Leave a Reply