Announcement Announcement Module
Collapse
No announcement yet.
Adding MVC to a Spring-ws project Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Adding MVC to a Spring-ws project

    Hi,

    I have a working project with a spring webservice and some jUnit-tests.

    Now I wanted to add MVC to the same project.

    But I run into problems when adding MVC capabilities. My previously working
    test fails and says WebServiceTransportException Not Found.

    So it must be something wrong with the configuration I added for MVC.

    Anyone who can help?

    web.xml
    ----------------------------
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    version="2.4">

    <!-- code for spring-ws

    <display-name>Archetype Created Web Application</display-name>

    <servlet>
    <servlet-name>spring-ws2</servlet-name>
    <servlet-class>org.springframework.ws.transport.http.Messag eDispatcherServlet</servlet-class>
    </servlet>

    <servlet-mapping>
    <servlet-name>spring-ws2</servlet-name>
    <url-pattern>/*</url-pattern>
    </servlet-mapping>
    -->


    <!-- code for spring-ws & mvc -->

    <!--
    -->
    <servlet>
    <servlet-name>spring-wsmvc</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherSe rvlet</servlet-class>
    <init-param>
    <description>This is used by SpringWS to dynamically convert WSDL urls</description>
    <param-name>transformWsdlLocations</param-name>
    <param-value>true</param-value>
    </init-param>
    <init-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/spring-wsmvc-servlet-config.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
    <servlet-name>spring-wsmvc</servlet-name>
    <url-pattern>/competence/*</url-pattern>
    </servlet-mapping>

    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/spring-wsmvc-application-config.xml</param-value>
    </context-param>

    <listener>
    <listener-class>org.springframework.web.context.ContextLoade rListener</listener-class>
    </listener>

    </web-app>
    -------------------------------------------------------------------------

    spring-ws2-servlet.xml (only used before I added MVC)
    -------------------------------------------------------------------------
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:oxm="http://www.springframework.org/schema/oxm"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schem...ring-beans.xsd
    http://www.springframework.org/schema/oxm
    http://www.springframework.org/schem...ng-oxm-3.0.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-2.5.xsd">



    <oxm:jaxb2-marshaller id="marshaller" contextPath="webservice.types"/>

    <bean class="org.springframework.ws.server.endpoint.adap ter.GenericMarshallingMethodEndpointAdapter">
    <constructor-arg ref="marshaller"/>
    </bean>

    <bean class="org.springframework.ws.server.endpoint.mapp ing.PayloadRootAnnotationMethodEndpointMapping"/>

    <bean name="competence" class="org.springframework.ws.wsdl.wsdl11.DefaultW sdl11Definition">
    <property name="schema">
    <bean class="org.springframework.xml.xsd.SimpleXsdSchema ">
    <property name="xsd" value="/WEB-INF/schemas/network.xsd" />
    </bean>
    </property>
    <property name="portTypeName" value="competence" />
    <property name="locationUri" value="http://localhost:8080/competence" />
    </bean>

    <bean id="endPoint" class="webservice.CompetenceResponse2EndPoint"/>



    </beans>

    --------------------------------------------------------------------------

    spring-wsmvc-application-config.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"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schem...-beans-2.5.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schem...ing-tx-2.5.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-2.5.xsd">



    <context:annotation-config/>

    <bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMe ssageFactory"/>

    <bean class="org.springframework.ws.transport.http.WebSe rviceMessageReceiverHandlerAdapter">
    <property name="messageFactory" ref="messageFactory"/>
    </bean>


    <bean class="org.springframework.web.servlet.handler.Sim pleUrlHandlerMapping">
    <property name="defaultHandler" ref="messageDispatcher"/>
    </bean>

    <bean id="messageDispatcher" class="org.springframework.ws.soap.server.SoapMess ageDispatcher"/>

    <bean class="org.springframework.web.servlet.mvc.SimpleC ontrollerHandlerAdapter"/>

    </beans>

    -------------------------------------------------------------------------

    spring-wsmvc-servlet-config.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"
    xmlns:oxm="http://www.springframework.org/schema/oxm"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schem...-beans-2.5.xsd
    http://www.springframework.org/schema/oxm
    http://www.springframework.org/schem...ng-oxm-3.0.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-2.5.xsd">

    <oxm:jaxb2-marshaller id="marshaller" contextPath="webservice.types"/>

    <bean class="org.springframework.ws.server.endpoint.adap ter.GenericMarshallingMethodEndpointAdapter">
    <constructor-arg ref="marshaller"/>
    </bean>

    <bean class="org.springframework.ws.server.endpoint.mapp ing.PayloadRootAnnotationMethodEndpointMapping"/>

    <bean name="competence" class="org.springframework.ws.wsdl.wsdl11.DefaultW sdl11Definition">
    <property name="schema">
    <bean class="org.springframework.xml.xsd.SimpleXsdSchema ">
    <property name="xsd" value="/WEB-INF/schemas/network.xsd" />
    </bean>
    </property>
    <property name="portTypeName" value="competence" />
    <property name="locationUri" value="http://localhost:8080/competence" />
    </bean>

    <bean id="endPoint" class="webservice.CompetenceResponse2EndPoint"/>

    <context:component-scan base-package="accounts.web"/>

    <bean class="org.springframework.web.servlet.view.Intern alResourceViewResolver">
    <property name="prefix" value="/WEB-INF/views/"/>
    <property name="suffix" value=".jsp"/>
    </bean>

    </beans>
    Last edited by thomas123456; Feb 25th, 2011, 01:43 AM. Reason: Better title
Working...
X