Writing a client application for Spring Web Services using JAXB unmarshalling for request

Let us write a simple client application for the author service. The org.springbyexample.ws.service package is scanned for beans and will find the AuthorServiceClient, and inject the web service template into it. The JAXB marshaller/umarshaller is defined and set on this template.

The import of the jetty-context.xml isn't relevant to creating a client, but it creates an embedded Jetty instance that loads the spring-ws-context.xml and its services. The client in the unit test is then able to run in isolation.

AuthorServiceClientTest.xml:

<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ...

Get Mastering Spring Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.