Illustration einer tropischen Insel mit Palmen und einem hohen Berg

Java Blog für Programmierer

JAX-WS 2.1 with Spring under Java 6

· Christian Ullenboom

First you need some jars in your classpath of an web application

  • commons-logging.jar
  • jaxw-api.jar
  • jaxws-rt.jar
  • jaxws-spring-1.1.jar
  • saaj-api.jar
  • saaj-impl.jar
  • spring.jar
  • stax-ex.jar
  • streambuffer.jar
  • xbean-spring-2.8.jar

The Jars are from Spring itself, , https://jax-ws.dev.java.net/ (jax-ws 2.1, JAXWS2.1_nightly.zip) and https://jax-ws-commons.dev.java.net/spring/ (jaxws-spring-1.1.jar). It is although important to place

  • jaxb-api.jar
  • jaxb-impl.jar

under C:\Programme\Apache Software Foundation\Tomcat 5.5\common\endorsed.

This was the necessary and boring preparation.

Next the Web Service itself

package com.tutego.service;
import javax.jws.WebMethod;import javax.jws.WebService;import javax.jws.soap.SOAPBinding;  @WebService@SOAPBinding(style = SOAPBinding.Style.RPC)public class GreeterService{@WebMethodpublic String greet( String name ){return "Hello " + name + "!"}}

And web.xml:

SpringWebindex.htmlindex.htmindex.jspdefault.htmldefault.htmdefault.jspcontextConfigLocation/WEB-INF/applicationContext.xmlorg.springframework.web.context.ContextLoaderListenerjaxws-servletcom.sun.xml.ws.transport.http.servlet.WSSpringServletjaxws-servlet/greet

The applicationContext.xml follows the suggestions with the namespace.

Now you can consume your WS. If your Web-Context is SpringWeb use http://localhost:8080/SpringWeb/greet?wsdl. Enjoy it!

Kategorien: Spring

← Alle Beiträge