Announcement Announcement Module
Collapse
No announcement yet.
Spring JAX-WS service as a servlet problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring JAX-WS service as a servlet problem

    Hi,

    I am trying to develop a web-service using JAX-WS annotations (@WebService, @WebMethod, etc) and deploy it on Tomcat as a servlet. Since Tomcat is not capable of JAX-WS I am trying to use Spring to expose my service.

    How do I do that?

    The documentation is not clear. Section "17.5.5. Exposing servlet-based web services using JAX-WS" is talking about how to do autowiring in the web service. It does not say anything about exposing web service as a servlet, which is what the title says. The phrase "To expose our AccountService we extend Spring's SpringBeanAutowiringSupport class" does not seem to hold true, because SpringBeanAutowiringSupport is not exposing the service, it only does autowiring of dependencies, so extending it does not help.

    Currently this is what I have in web.xml:

    Code:
    	<servlet>
    		<servlet-name>services</servlet-name>
    		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    		<load-on-startup>1</load-on-startup>
    	</servlet>
    
    	<servlet-mapping>
    		<servlet-name>services</servlet-name>
    		<url-pattern>/services/*</url-pattern>
    	</servlet-mapping>
    And this is services-servlet.xml:

    Code:
    <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
    
    	<bean id="pingService" class="test.PingServiceImpl" />
    
    </beans>
    Is there anything else I have to do. The class test.PingServiceImpl is fully annotated with JAX-WS and it works well with Apache CXF. So I don't think there is anything wrong with the annotations.

    This is what I am getting in the Tomcat log:

    Code:
    May 6, 2008 9:46:59 AM org.springframework.web.servlet.DispatcherServlet noHandlerFound
    WARNING: No mapping found for HTTP request with URI [/springWeb/services/pingService] in DispatcherServlet with name 'services'
    Thanks,

    Yegor

  • #2
    Hope this helps

    Hi there,

    I think you are missing something in the applicationContext.xml file. That's where you define what services are defined to which part of the URL space.

    I did some scouring on the net and found this - hope it helps:

    -- web.xml --

    <web-app>
    <!-- this is for Spring -->
    <listener>
    <listener-class>org.springframework.web.context.ContextLoade rListener</listener-class>
    </listener>

    <!-- these are for JAX-WS -->
    <servlet>
    <servlet-name>jaxws-servlet</servlet-name>
    <servlet-class>com.sun.xml.ws.transport.http.servlet.WSSpri ngServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>jaxws-servlet</servlet-name>
    <url-pattern>/add</url-pattern>
    </servlet-mapping>
    ... if you deploy more services,
    you might need more <servlet-mapping>s ...
    </web-app>

    -- web.xml --

    and

    -- applicationContext.xml --

    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ws="http://jax-ws.dev.java.net/spring/core"
    xmlns:wss="http://jax-ws.dev.java.net/spring/servlet"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schem...-beans-2.0.xsd
    http://jax-ws.dev.java.net/spring/core
    http://jax-ws.dev.java.net/spring/core.xsd
    http://jax-ws.dev.java.net/spring/servlet
    http://jax-ws.dev.java.net/spring/servlet.xsd">

    <wss:binding url="/add" service="#addService" />
    <wss:binding url="/sub">
    <wss:service><!-- nested bean is of course fine -->
    <ws:service bean="#myService" />
    </wss:service>
    </wss:binding>

    <!-- this bean implements web service methods -->
    <bean id="myService" class="foo.MyService" />

    <!-- simplest definition only needs the class name -->
    <ws:service id="addService" impl="foo.MyAddService" handlers="#myHandler"/>

    <bean id="myHandler" class="foo.MyHandler" />

    </beans>

    -- applicationContext --

    The above was taken from: https://jax-ws-commons.dev.java.net/spring/

    Cheers,

    M.

    Comment


    • #3
      Just as I suspected

      Thank you for your reply. You confirm my suspicion that Spring does not have it's own JAX-WS and SOAP engine, but instead it relies on a 3rd party transport like Sun's JWSDP or Apache CXF.

      I will probably go with CXF & Spring combo.

      Thanks again,

      Yegor

      Comment


      • #4
        You're welcome - I'm pretty new to Spring myself so I learn as I go along

        I also found this on here http://www.springframework.org/node/396:

        "The reference implementation of JAX-WAS (located at java.net) has added direct support for Spring-based configuration, via a custom Spring namespace! This allows you to wire your service implementation classes as well as handlers in a Spring application context."

        So I think your suspicions may be correct but than again I think that is why Spring is a light framework. It does however allow to wire-in components as required.

        Cheers,

        M.

        Comment

        Working...
        X