Hi!
I am new to JAX-WS and Spring and try to setup a few WebServices which need run on Tomcat 6.
I am using Maven as build tool therefore I just list my two dependencies here:
my service classes are located in com.test.services and are named TestService & HelloWorldService and look as follows:Code:<dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>3.0.5.RELEASE</version> </dependency> <dependency> <groupId>org.glassfish.metro</groupId> <artifactId>webservices-rt</artifactId> <version>2.1</version> </dependency> </dependencies>
this is my web.xml:Code:package com.test.services; import javax.jws.WebMethod; import javax.jws.WebService; @WebService( name = "Test", serviceName = "TestService" ) public class TestService { @WebMethod public String getTest() { return "Test"; } }
and this is my sun-jaxws.xml:Code:<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <display-name>toolbox</display-name> <description>testing webservices</description> <listener> <listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class> </listener> <servlet> <servlet-name>jaxws-servlet</servlet-name> <servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>jaxws-servlet</servlet-name> <url-pattern>/testservice</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>jaxws-servlet</servlet-name> <url-pattern>/helloworldservice</url-pattern> </servlet-mapping> <session-config> <session-timeout>10</session-timeout> </session-config> </web-app>
This works great and I can access the services by pointing my browser to http://localhost:8080/toolbox/testservice respectively http://localhost:8080/toolbox/helloworldservice.Code:<?xml version="1.0" encoding="UTF-8"?> <endpoints xmlns='http://java.sun.com/xml/ns/jax-ws/ri/runtime' version='2.0'> <endpoint name="jaxws-servlet" implementation="com.test.services.TestService" url-pattern="/testservice"/> <endpoint name="jaxws-servlet" implementation="com.test.services.HelloWorldService" url-pattern="/helloworldservice" /> </endpoints>
However Spring support is obviously not activated.
I tried the following which just leaver the HelloWorldService available:
web.xml:
and applicationContext.xml:Code:<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <display-name>toolbox</display-name> <session-config> <session-timeout>30</session-timeout> </session-config> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> </web-app>
furthermore I annotated both Service classes with @Service annotation. As I mentioned before, this only publishes the alphabetically first webservice, hence HelloWorldService.Code:<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:task="http://www.springframework.org/schema/task" xsi:schemaLocation=" http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd"> <context:component-scan base-package="com.test.services" /> <bean class="org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter"> <property name="baseAddress" value="http://localhost:8080/" /> </bean> </beans>
Also it changes the URL, as the service is now available as http://localhost:8080/ rather than http://localhost:8080/toolbox/helloworldservice.
The logging of Tomcat shows, that the Spring Context loads both Classes as Spring beans.
Do you have any ideas or suggestions on how to enable Spring support while keeping both services available??
I have followed also the instructions on the Metro project's site to enable Spring support, however I am missing WSSpringServlet and do not know which dependency may include this class.
Thank you very much!
Iulius


Reply With Quote
