diff --git a/core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/XPathParamMethodArgumentResolver.java b/core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/XPathParamMethodArgumentResolver.java index fa60f9ed..09ca2de3 100644 --- a/core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/XPathParamMethodArgumentResolver.java +++ b/core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/XPathParamMethodArgumentResolver.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -31,7 +31,7 @@ import org.springframework.core.convert.support.ConversionServiceFactory; import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.endpoint.annotation.XPathParam; import org.springframework.ws.server.endpoint.support.NamespaceUtils; -import org.springframework.xml.transform.TransformerObjectSupport; +import org.springframework.xml.transform.TransformerHelper; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -49,10 +49,12 @@ import org.w3c.dom.NodeList; * @author Arjen Poutsma * @since 2.0 */ -public class XPathParamMethodArgumentResolver extends TransformerObjectSupport implements MethodArgumentResolver { +public class XPathParamMethodArgumentResolver implements MethodArgumentResolver { private final XPathFactory xpathFactory = createXPathFactory(); + private TransformerHelper transformerHelper = new TransformerHelper(); + private ConversionService conversionService = ConversionServiceFactory.createDefaultConversionService(); /** @@ -65,6 +67,10 @@ public class XPathParamMethodArgumentResolver extends TransformerObjectSupport i this.conversionService = conversionService; } + public void setTransformerHelper(TransformerHelper transformerHelper) { + this.transformerHelper = transformerHelper; + } + public boolean supportsParameter(MethodParameter parameter) { if (parameter.getParameterAnnotation(XPathParam.class) == null) { return false; @@ -129,7 +135,7 @@ public class XPathParamMethodArgumentResolver extends TransformerObjectSupport i private Element getRootElement(Source source) throws TransformerException { DOMResult domResult = new DOMResult(); - transform(source, domResult); + transformerHelper.transform(source, domResult); Document document = (Document) domResult.getNode(); return document.getDocumentElement(); } diff --git a/src/docbkx/server.xml b/src/docbkx/server.xml index dbbcc626..25a6a327 100644 --- a/src/docbkx/server.xml +++ b/src/docbkx/server.xml @@ -158,14 +158,13 @@ WSDL to clients simply by just defining some beans. - By way of an example, consider the following bean definition, defined in the Spring-WS framework's - configuration file ('/WEB-INF/[servlet-name]-servlet.xml'). Take notice of the - value of the bean's 'id' attribute, because this will be used when exposing - the WSDL. + By way of an example, consider the following <static-wsdl>definition, + defined in the Spring-WS configuration file + (/WEB-INF/[servlet-name]-servlet.xml). + Take notice of the value of the 'id' attribute, because this will be used when + exposing the WSDL. - - -]]> + ]]> The WSDL defined in the 'Orders.wsdl' file can then be accessed via GET requests to a URL of the following form (substitute the host, port and @@ -176,9 +175,10 @@ All WsdlDefinition bean definitions are exposed by the MessageDispatcherServlet under their bean id (or bean name) with the - suffix .wsdl. So if the bean id is echo, the host name - is "server", and the Servlet context (war name) is "spring-ws", the WSDL can be - obtained via http://server/spring-ws/echo.wsdl + suffix .wsdl. + So if the bean id is echo, the host name is "server", and the Servlet + context (war name) is "spring-ws", the WSDL can be obtained via + http://server/spring-ws/echo.wsdl @@ -194,81 +194,70 @@ - - spring-ws - org.springframework.ws.transport.http.MessageDispatcherServlet - - transformWsdlLocations - true - - + + spring-ws + org.springframework.ws.transport.http.MessageDispatcherServlet + + transformWsdlLocations + true + + - - spring-ws - /* - + + spring-ws + /* + ]]> Consult the class-level Javadoc on the WsdlDefinitionHandlerAdapter class - which explains the whole transformation process in more detail. + to learn more about the whole transformation process. - As an alternative to writing the WSDL by hand, and exposing it with the - SimpleWsdl11Definition, Spring Web Services can also generate a WSDL - from an XSD schema. This is the approach shown in . + As an alternative to writing the WSDL by hand, and exposing it with + <static-wsdl>, Spring Web Services can also generate a WSDL + from an XSD schema. + This is the approach shown in . The next application context snippet shows how to create such a dynamic WSDL file: - - - - - - - - -]]> + + +]]> - The DefaultWsdl11Definition which builds - a WSDL from a XSD schema. This definition iterates over all element elements - found in the schema, and creates a message for all elements. Next, it creates - WSDL operation for all messages that end with the - defined request or response suffix. The default request suffix is Request; + The <dynamic-wsdl> builds a WSDL from a XSD schema by using conventions. + It iterates over all element elements + found in the schema, and creates a message for all elements. + Next, it creates WSDL operation for all messages that end with the + defined request or response suffix. + The default request suffix is Request; the default response suffix is Response, though these can be changed by setting the requestSuffix and responseSuffix - properties, respectively. - It also builds a portType, binding, and service based on the operations. + attributes on <dynamic-wsdl />, respectively. + It also builds a portType, binding, and + service based on the operations. For instance, if our Orders.xsd schema defines the - GetOrdersRequest and GetOrdersResponse elements, the - XsdBasedSoap11Wsdl4jDefinitionBuilder will create a + GetOrdersRequest and GetOrdersResponse elements, + <dynamic-wsdl> will create a GetOrdersRequest and GetOrdersResponse message, and a GetOrders operation, which is put in a Orders port type. - If you want to use multiple schemas, either by includes or imports, you might want to use the - CommonsXsdSchemaCollection, and refer to that from the - DefaultWsdl11Definition, like so: - - - - - /WEB-INF/xsds/Orders.xsd - /WEB-INF/xsds/Customers.xsd - - - -]]> - - When the inline property is enabled, it follows all XSD imports and includes, - and inlines them in the WSDL. This greatly simplifies the deployment of the schemas, which still - making it possible to edit them separately. + If you want to use multiple schemas, either by includes or imports, you will want to + put Commons XMLSchema on the class path. + If Commons XMLSchema is on the class path, the above <dynamic-wsdl> + element will follow all XSD imports and includes, + and will inline them in the WSDL as a single XSD. + This greatly simplifies the deployment of the schemas, which still making it possible to edit them + separately. - The DefaultWsdl11Definition uses WSDL providers in the + The <dynamic-wsdl> element depends on the + DefaultWsdl11Definition class. + This definition class uses WSDL providers in the org.springframework.ws.wsdl.wsdl11.provider package and the ProviderBasedWsdl4jDefinition to generate a WSDL the first time it is requested. @@ -284,11 +273,11 @@ reference. - It is therefore recommended to only use the DefaultWsdl11Definition - during the development stages of your project. Then, we recommend to use your browser to - download the generated WSDL, store it in the project, and expose it with the - SimpleWsdl11Definition. This is the only way to be really sure that - the WSDL does not change over time. + It is therefore recommended to only use <dynamic-wsdl> + during the development stages of your project. + Then, we recommend to use your browser to download the generated WSDL, store it in the project, + and expose it with <static-wsdl>. + This is the only way to be really sure that the WSDL does not change over time. @@ -397,7 +386,7 @@ As an alternative to the WebServiceMessageListener, Spring Web Services provides a WebServiceMessageDrivenBean, an EJB MessageDrivenBean. For more information on EJB, refer to the class level - Javadocs of the WebServiceMessageDrivenBean. + Javadoc of the WebServiceMessageDrivenBean.
@@ -699,6 +688,22 @@ public class AnnotationOrderEndpoint { + + To enable the support for @Endpoint and related Spring-WS annotations, + you will need to add the following to your Spring application context: + + <beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:sws="http://www.springframework.org/schema/web-services" + xsi:schemaLocation="http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans-3.0.xsd + http://www.springframework.org/schema/web-services + http://www.springframework.org/schema/web-services/web-services-2.0.xsd"> + + <sws:annotation-driven /> + +</beans> + In the next couple of sections, a more elaborate description of the @Endpoint programming model is given. @@ -750,17 +755,167 @@ public void order(@RequestPayload Element orderElement) { The handling method typically has one or more parameters that refer to various parts of the incoming XML message. Most commonly, the handling method will have a single parameter that will map to the payload of - the message, but it is also possible to map to other parts of the message, such as a SOAP header. + the message, but it is also possible to map to other parts of the request message, such as a SOAP + header. This section will describe the parameters you can use in your handling method signatures. - One + To map a parameter to the payload of the request message, you will need to annotate this parameter + with the @RequestPayload annotation. + This annotation tells Spring-WS that the parameter needs to be bound to the request payload. + + + The following table describes the supported parameter types. + It shows the supported types, whether the parameter should be annotated with + @RequestPayload, and any additional notes. + + + + + Name + Supported parameter types + @RequestPayload required? + Additional notes + + + + + TrAX + + javax.xml.transform.Source and sub-interfaces + (DOMSource, SAXSource, + StreamSource, and StAXSource) + + + Enabled by default. + + + W3C DOM + org.w3c.dom.Element + + Enabled by default + + + dom4j + org.dom4j.Element + + Enabled when dom4j is on the classpath. + + + JDOM + org.jdom.Element + + Enabled when JDOM is on the classpath. + + + XOM + nu.xom.Element + + Enabled when XOM is on the classpath. + + + StAX + + javax.xml.stream.XMLStreamReader and + javax.xml.stream.XMLEventReader + + + Enabled when StAX is on the classpath. + + + XPath + + Any boolean, double, String, + org.w3c.Node, + org.w3c.dom.NodeList, or + type that can be converted from a String by a Spring 3 + conversion service, + and that is annotated with @XPathParam. + + + Enabled by default. + + + Message context + org.springframework.ws.context.MessageContext + + Enabled by default. + + + SOAP + + org.springframework.ws.soap.SoapMessage, + org.springframework.ws.soap.SoapBody, + org.springframework.ws.soap.SoapEnvelope, and + org.springframework.ws.soap.SoapHeader + + + Enabled by default. + + + JAXB2 + + Any type that is annotated with + javax.xml.bind.annotation.XmlRootElement, + and javax.xml.bind.JAXBElement. + + + Enabled when JAXB2 is on the classpath. + + + OXM + + Any type supported by a Spring OXM + Unmarshaller. + + + + Enabled when the unmarshaller attribute of + <sws:annotation-driven/> is specified. + + + + + + + + Here are some examples of possible method signatures: + + + public void handle(@RequestPayload Element element) + This method will be invoked with the payload of the request message as a DOM + org.w3c.dom.Element. + + + public void handle(@RequestPayload DOMSource domSource, SoapHeader header) + This method will be invoked with the payload of the request message as a + javax.xml.transform.dom.DOMSource. + The header parameter will be bound to the SOAP header of the request + message. + + + public void handle(@RequestPayload MyJaxb2Object requestObject, @RequestPayload Element element, Message messageContext) + This method will be invoked with the payload of the request message unmarshalled into + a MyJaxb2Object (which is annotated with + @XmlRootElement). + The payload of the message is also given as a DOM Element. + The whole message context is passed on as the + third parameter. + + + As you can see, there are a lot of possibilities when it comes to defining handling method + signatures. + It is even possible to extend this mechanism, and to support your own parameter types. + Refer to the class-level Javadoc of DefaultMethodEndpointAdapter and + MethodArgumentResolver to see how.
Handling method return types - + To map the return value to the payload of the response message, you will need to annotate the + method with the @ResponsePayload annotation. + This annotation tells Spring-WS that the return value needs to be bound to the response payload.
@@ -1998,7 +2153,7 @@ public class CustomerEndpointIntegrationTest { You will typically statically import this class. - The ResponseMatchers class provides the following request matchers: + The ResponseMatchers class provides the following response matchers: