Echo sample now uses MessageDispatcherServlet; airline sample uses WsdlDefinitionHandlerAdapter
This commit is contained in:
@@ -71,14 +71,11 @@ public class SoapMessageDispatcher extends MessageDispatcher {
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the default implementations for the dispatcher's strategies: <code>MessageEndpointAdapter</code> and
|
||||
* <code>PayloadEndpointAdapter</code> as endpoint adapters, and a <code>SimpleSoapExceptionResolver</code> as
|
||||
* exception resolver.
|
||||
* Initialize the default implementations for the dispatcher's strategies, in addition to the strategies defined in
|
||||
* the base class: a <code>SimpleSoapExceptionResolver</code> as exception resolver.
|
||||
*
|
||||
* @see #setEndpointAdapters(java.util.List)
|
||||
* @see org.springframework.ws.MessageDispatcher#initDefaultStrategies()
|
||||
* @see #setEndpointExceptionResolvers(java.util.List)
|
||||
* @see org.springframework.ws.endpoint.MessageEndpointAdapter
|
||||
* @see org.springframework.ws.endpoint.PayloadEndpointAdapter
|
||||
* @see org.springframework.ws.soap.endpoint.SimpleSoapExceptionResolver
|
||||
*/
|
||||
protected void initDefaultStrategies() {
|
||||
|
||||
@@ -3,11 +3,15 @@
|
||||
|
||||
<beans>
|
||||
<description>
|
||||
This application context contains the Spring-WS beans.</description>
|
||||
This application context contains the Spring-WS beans.
|
||||
</description>
|
||||
|
||||
<bean id="messageDispatcher" class="org.springframework.ws.soap.SoapMessageDispatcher">
|
||||
<description>
|
||||
The MessageDispatcher is responsible for routing messages to endpoints.</description>
|
||||
The MessageDispatcher is responsible for routing messages to endpoints. It uses three endpoint mappings to
|
||||
determine the endpoint suitable for handling a particular incoming request. This is not a recommended
|
||||
approach, it's done here only for illustration purposes.
|
||||
</description>
|
||||
<property name="endpointMappings">
|
||||
<list>
|
||||
<ref local="payloadMapping"/>
|
||||
@@ -23,16 +27,26 @@
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="airlineWsdl" class="org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition">
|
||||
<description>
|
||||
This bean definition represents the airline.wsdl file found in the root of the web application. It is used
|
||||
by the WsdlDefinitionHandlerAdapter in airline-servlet.xml.
|
||||
</description>
|
||||
<property name="wsdl" value="/airline.wsdl"/>
|
||||
</bean>
|
||||
|
||||
<bean id="payloadMapping" class="org.springframework.ws.endpoint.mapping.PayloadRootQNameEndpointMapping">
|
||||
<description>
|
||||
This endpoint mapping uses the qualified name of the payload (body contents) to determine the endpoint for
|
||||
an incoming message. The name GetFlightsRequest with namespace
|
||||
http://www.springframework.org/spring-ws/samples/airline/schemas is mapped to the getFlightsEndpoint.
|
||||
Additionally, messages are logged using the logging interceptor.</description>
|
||||
Additionally, messages are logged using the logging interceptor.
|
||||
</description>
|
||||
<property name="mappings">
|
||||
<props>
|
||||
<prop key="{http://www.springframework.org/spring-ws/samples/airline/schemas}GetFlightsRequest">
|
||||
getFlightsEndpoint</prop>
|
||||
getFlightsEndpoint
|
||||
</prop>
|
||||
</props>
|
||||
</property>
|
||||
<property name="interceptors">
|
||||
@@ -44,11 +58,13 @@
|
||||
<description>
|
||||
This endpoint mapping uses SOAP Actions to determine the endpoint for an incoming message. The key
|
||||
http://www.springframework.org/spring-ws/samples/airline/BookFlight is mapped to the bookFlightEndpoint.
|
||||
Additionally, message are logged and validated.</description>
|
||||
Additionally, message are logged and validated.
|
||||
</description>
|
||||
<property name="mappings">
|
||||
<props>
|
||||
<prop key="http://www.springframework.org/spring-ws/samples/airline/BookFlight">
|
||||
bookFlightEndpoint</prop>
|
||||
bookFlightEndpoint
|
||||
</prop>
|
||||
</props>
|
||||
</property>
|
||||
<property name="interceptors">
|
||||
@@ -62,7 +78,8 @@
|
||||
<bean id="validatingInterceptor" class="org.springframework.ws.endpoint.interceptor.PayloadValidatingInterceptor">
|
||||
<description>
|
||||
This interceptor validates both incoming and outgoing message contents according to the 'airline.xsd' XML
|
||||
Schema file.</description>
|
||||
Schema file.
|
||||
</description>
|
||||
<property name="schema" value="airline.xsd"/>
|
||||
<property name="validateRequest" value="true"/>
|
||||
<property name="validateResponse" value="true"/>
|
||||
@@ -70,18 +87,21 @@
|
||||
|
||||
<bean id="loggingInterceptor" class="org.springframework.ws.endpoint.interceptor.PayloadLoggingInterceptor">
|
||||
<description>
|
||||
This interceptor logs the message payload.</description>
|
||||
This interceptor logs the message payload.
|
||||
</description>
|
||||
</bean>
|
||||
|
||||
<bean id="bookFlightEndpoint" class="org.springframework.ws.samples.airline.ws.BookFlightEndpoint">
|
||||
<description>
|
||||
This endpoint handles book flight request.</description>
|
||||
This endpoint handles book flight request.
|
||||
</description>
|
||||
<property name="airlineService" ref="airlineService"/>
|
||||
</bean>
|
||||
|
||||
<bean id="getFlightsEndpoint" class="org.springframework.ws.samples.airline.ws.GetFlightsEndpoint">
|
||||
<description>
|
||||
This endpoint handles get flights request.</description>
|
||||
This endpoint handles get flights request.
|
||||
</description>
|
||||
<property name="airlineService" ref="airlineService"/>
|
||||
<property name="marshaller" ref="jaxbMarshaller"/>
|
||||
<property name="unmarshaller" ref="jaxbMarshaller"/>
|
||||
@@ -90,7 +110,8 @@
|
||||
<bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb1Marshaller">
|
||||
<description>
|
||||
The validating JAXB Marshaller is used by the getFlightsEndpoint to unmarshal XML to objects and
|
||||
vice-versa.</description>
|
||||
vice-versa.
|
||||
</description>
|
||||
<property name="contextPath" value="org.springframework.ws.samples.airline.schema"/>
|
||||
<property name="validating" value="true"/>
|
||||
</bean>
|
||||
@@ -100,7 +121,8 @@
|
||||
This exception resolver maps exceptions to SOAP Faults. The business logic exceptions
|
||||
NoSeatAvailableException and NoSuchFlightException are mapped to custom SOAP Fault. Both
|
||||
UnmarshallingException andValidationFailureException are mapped to a SOAP Fault with a "Sender" fault code.
|
||||
All other exceptions are mapped to a "Receiver" error code, the default.</description>
|
||||
All other exceptions are mapped to a "Receiver" error code, the default.
|
||||
</description>
|
||||
<property name="defaultFault">
|
||||
<value>RECEIVER,Server error</value>
|
||||
</property>
|
||||
@@ -108,10 +130,12 @@
|
||||
<props>
|
||||
<prop key="org.springframework.ws.samples.airline.service.NoSeatAvailableException">
|
||||
{http://www.springframework.org/spring-ws/samples/airline}airline:NoMoreSeats, No more seats
|
||||
available</prop>
|
||||
available
|
||||
</prop>
|
||||
<prop key="org.springframework.ws.samples.airline.service.NoSuchFlightException">
|
||||
{http://www.springframework.org/spring-ws/samples/airline}airline:NoSuchFlight, No such flight
|
||||
exists</prop>
|
||||
exists
|
||||
</prop>
|
||||
<prop key="org.springframework.oxm.UnmarshallingFailureException">SENDER,Invalid request</prop>
|
||||
<prop key="org.springframework.oxm.ValidationFailureException">SENDER,Invalid request</prop>
|
||||
</props>
|
||||
|
||||
@@ -14,12 +14,25 @@
|
||||
|
||||
<bean id="messageContextFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageContextFactory"/>
|
||||
|
||||
<bean id="wsdlDefinitionHandlerAdapter" class="org.springframework.ws.transport.http.WsdlDefinitionHandlerAdapter">
|
||||
<description>
|
||||
This handler adapter adds support for WsdlDefinitions to Spring's DispatcherServlet. It transforms location
|
||||
attributes in the original WSDL to reflect the URL of the incoming HTTP request.
|
||||
</description>
|
||||
<property name="transformLocations" value="true"/>
|
||||
</bean>
|
||||
|
||||
<bean id="handlerMapping"
|
||||
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
|
||||
<description>
|
||||
All incoming request are mapped to the messageDispatcher defined in applicationContext-ws.xml
|
||||
</description>
|
||||
<property name="defaultHandler" ref="messageDispatcher"/>
|
||||
<property name="mappings">
|
||||
<props>
|
||||
<prop key="airline.wsdl">airlineWsdl</prop>
|
||||
</props>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@@ -37,10 +37,10 @@
|
||||
<servlet-name>airline</servlet-name>
|
||||
<url-pattern>/Airline</url-pattern>
|
||||
</servlet-mapping>
|
||||
<mime-mapping>
|
||||
<extension>wsdl</extension>
|
||||
<mime-type>text/xml</mime-type>
|
||||
</mime-mapping>
|
||||
<servlet-mapping>
|
||||
<servlet-name>airline</servlet-name>
|
||||
<url-pattern>*.wsdl</url-pattern>
|
||||
</servlet-mapping>
|
||||
<mime-mapping>
|
||||
<extension>xsd</extension>
|
||||
<mime-type>text/xml</mime-type>
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
|
||||
<beans>
|
||||
<!-- Spring-WS beans -->
|
||||
<bean id="messageDispatcher" class="org.springframework.ws.soap.SoapMessageDispatcher">
|
||||
<description>
|
||||
The MessageDispatcher is responsible for routing messages to endpoints.</description>
|
||||
<property name="endpointMappings" ref="payloadMapping"/>
|
||||
<property name="endpointExceptionResolvers" ref="endpointExceptionResolver"/>
|
||||
</bean>
|
||||
|
||||
<bean id="payloadMapping" class="org.springframework.ws.endpoint.mapping.PayloadRootQNameEndpointMapping">
|
||||
<description>
|
||||
This endpoint mapping uses the qualified name of the payload (body contents) to determine the endpoint for
|
||||
an incoming message. Every message is passed to the default endpoint. Additionally, messages are logged
|
||||
using the logging interceptor.</description>
|
||||
<property name="defaultEndpoint" ref="echoEndpoint"/>
|
||||
<property name="interceptors">
|
||||
<list>
|
||||
<ref local="validatingInterceptor"/>
|
||||
<ref local="loggingInterceptor"/>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="validatingInterceptor" class="org.springframework.ws.endpoint.interceptor.PayloadValidatingInterceptor">
|
||||
<description>
|
||||
This interceptor validates both incoming and outgoing message contents according to the 'echo.xsd' XML
|
||||
Schema file.</description>
|
||||
<property name="schema" value="/echo.xsd"/>
|
||||
<property name="validateRequest" value="true"/>
|
||||
<property name="validateResponse" value="true"/>
|
||||
</bean>
|
||||
|
||||
<bean id="loggingInterceptor" class="org.springframework.ws.endpoint.interceptor.PayloadLoggingInterceptor">
|
||||
<description>
|
||||
This interceptor logs the message payload.</description>
|
||||
</bean>
|
||||
|
||||
<bean id="echoEndpoint" class="org.springframework.ws.samples.echo.ws.EchoEndpoint">
|
||||
<description>
|
||||
This endpoint handles echo requests.</description>
|
||||
<property name="echoService" ref="echoService"/>
|
||||
</bean>
|
||||
|
||||
<bean id="echoWsdl" class="org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition">
|
||||
<property name="wsdl" value="/echo.wsdl"/>
|
||||
</bean>
|
||||
|
||||
<bean id="endpointExceptionResolver" class="org.springframework.ws.soap.endpoint.SimpleSoapExceptionResolver"/>
|
||||
|
||||
<!-- "Business" (POJO) services -->
|
||||
<bean id="echoService" class="org.springframework.ws.samples.echo.service.impl.EchoServiceImpl"/>
|
||||
|
||||
|
||||
</beans>
|
||||
@@ -1,35 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
|
||||
"http://www.springframework.org/dtd/spring-beans.dtd">
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
|
||||
<beans>
|
||||
<bean id="messageEndpointHandlerAdapter"
|
||||
class="org.springframework.ws.transport.http.MessageEndpointHandlerAdapter">
|
||||
<bean id="payloadMapping" class="org.springframework.ws.endpoint.mapping.PayloadRootQNameEndpointMapping">
|
||||
<description>
|
||||
This handler adapter makes sure that Spring's DispatcherServlet supports MessageEndpoint instances as
|
||||
handlers. It uses a SAAJ to construct SoapMessageContexts (and SoapMessages).
|
||||
This endpoint mapping uses the qualified name of the payload (body contents) to determine the endpoint for
|
||||
an incoming message. Every message is passed to the default endpoint. Additionally, messages are logged
|
||||
using the logging interceptor.
|
||||
</description>
|
||||
<property name="messageContextFactory">
|
||||
<bean class="org.springframework.ws.soap.saaj.SaajSoapMessageContextFactory"/>
|
||||
<property name="defaultEndpoint" ref="echoEndpoint"/>
|
||||
<property name="interceptors">
|
||||
<list>
|
||||
<ref local="validatingInterceptor"/>
|
||||
<ref local="loggingInterceptor"/>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="wsdlDefinitionHandlerAdapter" class="org.springframework.ws.transport.http.WsdlDefinitionHandlerAdapter">
|
||||
<bean id="validatingInterceptor" class="org.springframework.ws.endpoint.interceptor.PayloadValidatingInterceptor">
|
||||
<description>
|
||||
This handler adapter adds support for WsdlDefinitions to Spring's DispatcherServlet. It transforms location
|
||||
attributes in the original WSDL to reflect the URL of the incoming HTTP request.
|
||||
This interceptor validates both incoming and outgoing message contents according to the 'echo.xsd' XML
|
||||
Schema file.
|
||||
</description>
|
||||
<property name="transformLocations" value="true"/>
|
||||
<property name="schema" value="/echo.xsd"/>
|
||||
<property name="validateRequest" value="true"/>
|
||||
<property name="validateResponse" value="true"/>
|
||||
</bean>
|
||||
|
||||
<bean id="handlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
|
||||
<bean id="loggingInterceptor" class="org.springframework.ws.endpoint.interceptor.PayloadLoggingInterceptor">
|
||||
<description>
|
||||
All incoming request are mapped to the messageDispatcher defined in applicationContext-ws.xml
|
||||
This interceptor logs the message payload.
|
||||
</description>
|
||||
<property name="defaultHandler" ref="messageDispatcher"/>
|
||||
<property name="mappings">
|
||||
<props>
|
||||
<prop key="/services/*">messageDispatcher</prop>
|
||||
<prop key="echo.wsdl">echoWsdl</prop>
|
||||
</props>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="echoEndpoint" class="org.springframework.ws.samples.echo.ws.EchoEndpoint">
|
||||
<description>
|
||||
This endpoint handles echo requests.
|
||||
</description>
|
||||
<property name="echoService" ref="echoService"/>
|
||||
</bean>
|
||||
|
||||
<!-- "Business" (POJO) services -->
|
||||
<bean id="echoService" class="org.springframework.ws.samples.echo.service.impl.EchoServiceImpl"/>
|
||||
|
||||
</beans>
|
||||
@@ -22,21 +22,10 @@
|
||||
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
|
||||
</listener>
|
||||
|
||||
<!-- Loads the root application context of this web app at startup.
|
||||
Use WebApplicationContextUtils.getWebApplicationContext(servletContext)
|
||||
to access it anywhere in the web application, outside of the framework.
|
||||
|
||||
The root context is the parent of all servlet-specific contexts.
|
||||
This means that its beans are automatically available in these child contexts,
|
||||
both for getBean(name) calls and (external) bean references. -->
|
||||
<listener>
|
||||
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
|
||||
</listener>
|
||||
|
||||
<!-- Starts the web service servlet. -->
|
||||
<servlet>
|
||||
<servlet-name>spring-ws</servlet-name>
|
||||
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
|
||||
<servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<!-- We map all service request to the springws servlet. -->
|
||||
@@ -45,10 +34,10 @@
|
||||
<url-pattern>/services</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>spring-ws</servlet-name>
|
||||
<url-pattern>*.wsdl</url-pattern>
|
||||
</servlet-mapping>
|
||||
<mime-mapping>
|
||||
<extension>wsdl</extension>
|
||||
<mime-type>text/xml</mime-type>
|
||||
</mime-mapping>
|
||||
|
||||
<mime-mapping>
|
||||
<extension>xsd</extension>
|
||||
|
||||
Reference in New Issue
Block a user