- * An {@code AbstractDom4JPayloadEndpoint} only accept one payload element. Multiple - * payload elements are not in accordance with WS-I. - * - * @author Arjen Poutsma - * @since 1.0.0 - * @see org.dom4j.Element - * @deprecated as of Spring Web Services 2.0, in favor of annotated endpoints - */ -@Deprecated -public abstract class AbstractDom4jPayloadEndpoint extends TransformerObjectSupport implements PayloadEndpoint { - - private boolean alwaysTransform = false; - - /** - * Set if the request {@link Source} should always be transformed into a new - * {@link DocumentResult}. - *
- * Default is {@code false}, which is faster. - */ - public void setAlwaysTransform(boolean alwaysTransform) { - this.alwaysTransform = alwaysTransform; - } - - @Override - public final Source invoke(Source request) throws Exception { - Element requestElement = null; - if (request != null) { - DocumentResult dom4jResult = new DocumentResult(); - transform(request, dom4jResult); - requestElement = dom4jResult.getDocument().getRootElement(); - } - Document responseDocument = DocumentHelper.createDocument(); - Element responseElement = invokeInternal(requestElement, responseDocument); - return (responseElement != null) ? new DocumentSource(responseElement) : null; - } - - /** - * Returns the payload element of the given source. - *
- * Default implementation checks whether the source is a - * {@link javax.xml.transform.dom.DOMSource}, and uses a - * {@link org.dom4j.io.DOMReader} to create a JDOM {@link org.dom4j.Element}. In all - * other cases, or when {@linkplain #setAlwaysTransform(boolean) alwaysTransform} is - * {@code true}, the source is transformed into a {@link org.dom4j.io.DocumentResult}, - * which is more expensive. If the passed source is {@code null}, {@code - * null} is returned. - * @param source the source to return the root element of; can be {@code null} - * @return the document element - * @throws javax.xml.transform.TransformerException in case of errors - */ - protected Element getDocumentElement(Source source) throws TransformerException { - if (source == null) { - return null; - } - if (!this.alwaysTransform && source instanceof DOMSource) { - Node node = ((DOMSource) source).getNode(); - if (node.getNodeType() == Node.DOCUMENT_NODE) { - DOMReader domReader = new DOMReader(); - Document document = domReader.read((org.w3c.dom.Document) node); - return document.getRootElement(); - } - } - // we have no other option than to transform - DocumentResult dom4jResult = new DocumentResult(); - transform(source, dom4jResult); - return dom4jResult.getDocument().getRootElement(); - } - - /** - * Template method. Subclasses must implement this. Offers the request payload as a - * dom4j {@code Element}, and allows subclasses to return a response {@code Element}. - *
- * The given dom4j {@code Document} is to be used for constructing a response element, - * by using {@code addElement}. - * @param requestElement the contents of the SOAP message as dom4j elements - * @param responseDocument a dom4j document to be used for constructing a response - * @return the response element. Can be {@code null} to specify no response. - */ - protected abstract Element invokeInternal(Element requestElement, Document responseDocument) throws Exception; - -} diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractDomPayloadEndpoint.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractDomPayloadEndpoint.java deleted file mode 100644 index 75163780..00000000 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractDomPayloadEndpoint.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright 2005-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://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, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.ws.server.endpoint; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.Source; -import javax.xml.transform.TransformerException; -import javax.xml.transform.dom.DOMResult; -import javax.xml.transform.dom.DOMSource; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -import org.springframework.xml.DocumentBuilderFactoryUtils; -import org.springframework.xml.transform.TransformerObjectSupport; - -/** - * Abstract base class for endpoints that handle the message payload as DOM elements. - *
- * Offers the message payload as a DOM {@code Element}, and allows subclasses to create a - * response by returning an {@code Element}. - *
- * An {@code AbstractDomPayloadEndpoint} only accept one payload element. - * Multiple payload elements are not in accordance with WS-I. - * - * @author Arjen Poutsma - * @author Alef Arendsen - * @since 1.0.0 - * @see #invokeInternal(org.w3c.dom.Element,org.w3c.dom.Document) - * @deprecated as of Spring Web Services 2.0, in favor of annotated endpoints - */ -@Deprecated -public abstract class AbstractDomPayloadEndpoint extends TransformerObjectSupport implements PayloadEndpoint { - - private DocumentBuilderFactory documentBuilderFactory; - - private boolean validating = false; - - private boolean namespaceAware = true; - - private boolean expandEntityReferences = false; - - private boolean alwaysTransform = false; - - /** - * Set whether or not the XML parser should be XML namespace aware. Default is - * {@code true}. - */ - public void setNamespaceAware(boolean namespaceAware) { - this.namespaceAware = namespaceAware; - } - - /** Set if the XML parser should validate the document. Default is {@code false}. */ - public void setValidating(boolean validating) { - this.validating = validating; - } - - /** - * Set if the XML parser should expand entity reference nodes. Default is - * {@code false}. - */ - public void setExpandEntityReferences(boolean expandEntityRef) { - this.documentBuilderFactory.setExpandEntityReferences(expandEntityRef); - } - - /** - * Set if the request {@link Source} should always be transformed into a new - * {@link DOMResult}. - *
- * Default is {@code false}, which is faster. - */ - public void setAlwaysTransform(boolean alwaysTransform) { - this.alwaysTransform = alwaysTransform; - } - - @Override - public final Source invoke(Source request) throws Exception { - if (this.documentBuilderFactory == null) { - this.documentBuilderFactory = createDocumentBuilderFactory(); - } - DocumentBuilder documentBuilder = createDocumentBuilder(this.documentBuilderFactory); - Element requestElement = getDocumentElement(request, documentBuilder); - Document responseDocument = documentBuilder.newDocument(); - Element responseElement = invokeInternal(requestElement, responseDocument); - return (responseElement != null) ? new DOMSource(responseElement) : null; - } - - /** - * Create a {@code DocumentBuilder} that this endpoint will use for parsing XML - * documents. Can be overridden in subclasses, adding further initialization of the - * builder. - * @param factory the {@code DocumentBuilderFactory} that the DocumentBuilder should - * be created with - * @return the {@code DocumentBuilder} - * @throws ParserConfigurationException if thrown by JAXP methods - */ - protected DocumentBuilder createDocumentBuilder(DocumentBuilderFactory factory) - throws ParserConfigurationException { - return factory.newDocumentBuilder(); - } - - /** - * Create a {@code DocumentBuilderFactory} that this endpoint will use for - * constructing XML documents. Can be overridden in subclasses, adding further - * initialization of the factory. The resulting {@code DocumentBuilderFactory} is - * cached, so this method will only be called once. - * @return the DocumentBuilderFactory - * @throws ParserConfigurationException if thrown by JAXP methods - */ - protected DocumentBuilderFactory createDocumentBuilderFactory() throws ParserConfigurationException { - DocumentBuilderFactory factory = DocumentBuilderFactoryUtils.newInstance(); - factory.setValidating(this.validating); - factory.setNamespaceAware(this.namespaceAware); - factory.setExpandEntityReferences(this.expandEntityReferences); - return factory; - } - - /** - * Returns the payload element of the given source. - *
- * Default implementation checks whether the source is a {@link DOMSource}, and - * returns the {@linkplain DOMSource#getNode() node} of that. In all other cases, or - * when {@linkplain #setAlwaysTransform(boolean) alwaysTransform} is {@code true}, the - * source is transformed into a {@link DOMResult}, which is more expensive. If the - * passed source is {@code null}, {@code null} is returned. - * @param source the source to return the root element of; can be {@code null} - * @param documentBuilder the document builder to be used for transformations - * @return the document element - * @throws TransformerException in case of errors - */ - protected Element getDocumentElement(Source source, DocumentBuilder documentBuilder) throws TransformerException { - if (source == null) { - return null; - } - if (!this.alwaysTransform && source instanceof DOMSource) { - Node node = ((DOMSource) source).getNode(); - if (node.getNodeType() == Node.ELEMENT_NODE) { - return (Element) node; - } - else if (node.getNodeType() == Node.DOCUMENT_NODE) { - return ((Document) node).getDocumentElement(); - } - } - // we have no other option than to transform - Document requestDocument = documentBuilder.newDocument(); - DOMResult domResult = new DOMResult(requestDocument); - transform(source, domResult); - return requestDocument.getDocumentElement(); - } - - /** - * Template method that subclasses must implement to process the request. - *
- * Offers the request payload as a DOM {@code Element}, and allows subclasses to - * return a response {@code Element}. - *
- * The given DOM {@code Document} is to be used for constructing {@code Node}s, by - * using the various {@code create} methods. - * @param requestElement the contents of the SOAP message as DOM elements - * @param responseDocument a DOM document to be used for constructing {@code Node}s - * @return the response element. Can be {@code null} to specify no response. - */ - protected abstract Element invokeInternal(Element requestElement, Document responseDocument) throws Exception; - -} diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractJDomPayloadEndpoint.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractJDomPayloadEndpoint.java deleted file mode 100644 index 8ee1cb8d..00000000 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractJDomPayloadEndpoint.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright 2005-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://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, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.ws.server.endpoint; - -import javax.xml.transform.Source; -import javax.xml.transform.TransformerException; -import javax.xml.transform.dom.DOMSource; - -import org.jdom2.Document; -import org.jdom2.Element; -import org.jdom2.input.DOMBuilder; -import org.jdom2.transform.JDOMResult; -import org.jdom2.transform.JDOMSource; -import org.w3c.dom.Node; - -import org.springframework.xml.transform.TransformerObjectSupport; - -/** - * Abstract base class for endpoints that handle the message payload as JDOM elements. - *
- * Offers the message payload as a JDOM {@link Element}, and allows subclasses to create a - * response by returning an {@code Element}. An {@code AbstractJDomPayloadEndpoint} can - * accept only one payload element. Multiple payload elements are not in accordance - * with WS-I. - * - * @author Arjen Poutsma - * @since 1.0.0 - * @deprecated as of Spring Web Services 2.0, in favor of annotated endpoints - */ -@Deprecated -public abstract class AbstractJDomPayloadEndpoint extends TransformerObjectSupport implements PayloadEndpoint { - - private boolean alwaysTransform = false; - - /** - * Set if the request {@link Source} should always be transformed into a new - * {@link JDOMResult}. - *
- * Default is {@code false}, which is faster. - */ - public void setAlwaysTransform(boolean alwaysTransform) { - this.alwaysTransform = alwaysTransform; - } - - @Override - public final Source invoke(Source request) throws Exception { - Element requestElement = getDocumentElement(request); - Element responseElement = invokeInternal(requestElement); - return (responseElement != null) ? new JDOMSource(responseElement) : null; - } - - /** - * Returns the payload element of the given source. - *
- * Default implementation checks whether the source is a {@link DOMSource}, and uses a - * {@link DOMBuilder} to create a JDOM {@link Element}. In all other cases, or when - * {@linkplain #setAlwaysTransform(boolean) alwaysTransform} is {@code true}, the - * source is transformed into a {@link JDOMResult}, which is more expensive. If the - * passed source is {@code null}, {@code null} is returned. - * @param source the source to return the root element of; can be {@code null} - * @return the document element - * @throws TransformerException in case of errors - */ - protected Element getDocumentElement(Source source) throws TransformerException { - if (source == null) { - return null; - } - if (!this.alwaysTransform && source instanceof DOMSource) { - Node node = ((DOMSource) source).getNode(); - DOMBuilder domBuilder = new DOMBuilder(); - if (node.getNodeType() == Node.ELEMENT_NODE) { - return domBuilder.build((org.w3c.dom.Element) node); - } - else if (node.getNodeType() == Node.DOCUMENT_NODE) { - Document document = domBuilder.build((org.w3c.dom.Document) node); - return document.getRootElement(); - } - } - // we have no other option than to transform - JDOMResult jdomResult = new JDOMResult(); - transform(source, jdomResult); - return jdomResult.getDocument().getRootElement(); - } - - /** - * Template method. Subclasses must implement this. Offers the request payload as a - * JDOM {@code Element}, and allows subclasses to return a response {@code Element}. - * @param requestElement the contents of the SOAP message as JDOM element - * @return the response element. Can be {@code null} to specify no response. - */ - protected abstract Element invokeInternal(Element requestElement) throws Exception; - -} diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractMarshallingPayloadEndpoint.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractMarshallingPayloadEndpoint.java deleted file mode 100644 index 1c891eb0..00000000 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractMarshallingPayloadEndpoint.java +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright 2005-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://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, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.ws.server.endpoint; - -import java.io.IOException; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.beans.factory.InitializingBean; -import org.springframework.oxm.Marshaller; -import org.springframework.oxm.Unmarshaller; -import org.springframework.util.Assert; -import org.springframework.ws.WebServiceMessage; -import org.springframework.ws.context.MessageContext; -import org.springframework.ws.support.MarshallingUtils; - -/** - * Endpoint that unmarshals the request payload, and marshals the response object. This - * endpoint needs a {@code Marshaller} and {@code Unmarshaller}, both of which can be set - * using properties. An abstract template method is invoked using the request object as a - * parameter, and allows for a response object to be returned. - * - * @author Arjen Poutsma - * @since 1.0.0 - * @see #setMarshaller(org.springframework.oxm.Marshaller) - * @see Marshaller - * @see #setUnmarshaller(org.springframework.oxm.Unmarshaller) - * @see Unmarshaller - * @see #invokeInternal(Object) - * @deprecated as of Spring Web Services 2.0, in favor of annotated endpoints - */ -@Deprecated -public abstract class AbstractMarshallingPayloadEndpoint implements MessageEndpoint, InitializingBean { - - /** Logger available to subclasses. */ - protected final Log logger = LogFactory.getLog(getClass()); - - private Marshaller marshaller; - - private Unmarshaller unmarshaller; - - /** - * Creates a new {@code AbstractMarshallingPayloadEndpoint}. The {@link Marshaller} - * and {@link Unmarshaller} must be injected using properties. - * @see #setMarshaller(org.springframework.oxm.Marshaller) - * @see #setUnmarshaller(org.springframework.oxm.Unmarshaller) - */ - protected AbstractMarshallingPayloadEndpoint() { - } - - /** - * Creates a new {@code AbstractMarshallingPayloadEndpoint} with the given marshaller. - * The given {@link Marshaller} should also implements the {@link Unmarshaller}, since - * it is used for both marshalling and unmarshalling. If it is not, an exception is - * thrown. - *
- * Note that all {@link Marshaller} implementations in Spring-WS also implement the - * {@link Unmarshaller} interface, so that you can safely use this constructor. - * @param marshaller object used as marshaller and unmarshaller - * @throws IllegalArgumentException when {@code marshaller} does not implement the - * {@link Unmarshaller} interface - * @see #AbstractMarshallingPayloadEndpoint(Marshaller,Unmarshaller) - */ - protected AbstractMarshallingPayloadEndpoint(Marshaller marshaller) { - Assert.notNull(marshaller, "marshaller must not be null"); - if (!(marshaller instanceof Unmarshaller)) { - throw new IllegalArgumentException("Marshaller [" + marshaller + "] does not implement the Unmarshaller " - + "interface. Please set an Unmarshaller explicitly by using the " - + "AbstractMarshallingPayloadEndpoint(Marshaller, Unmarshaller) constructor."); - } - else { - setMarshaller(marshaller); - setUnmarshaller((Unmarshaller) marshaller); - } - } - - /** - * Creates a new {@code AbstractMarshallingPayloadEndpoint} with the given marshaller - * and unmarshaller. - * @param marshaller the marshaller to use - * @param unmarshaller the unmarshaller to use - */ - protected AbstractMarshallingPayloadEndpoint(Marshaller marshaller, Unmarshaller unmarshaller) { - Assert.notNull(marshaller, "marshaller must not be null"); - Assert.notNull(unmarshaller, "unmarshaller must not be null"); - setMarshaller(marshaller); - setUnmarshaller(unmarshaller); - } - - /** Returns the marshaller used for transforming objects into XML. */ - public Marshaller getMarshaller() { - return this.marshaller; - } - - /** Sets the marshaller used for transforming objects into XML. */ - public final void setMarshaller(Marshaller marshaller) { - this.marshaller = marshaller; - } - - /** Returns the unmarshaller used for transforming XML into objects. */ - public Unmarshaller getUnmarshaller() { - return this.unmarshaller; - } - - /** Sets the unmarshaller used for transforming XML into objects. */ - public final void setUnmarshaller(Unmarshaller unmarshaller) { - this.unmarshaller = unmarshaller; - } - - @Override - public void afterPropertiesSet() throws Exception { - afterMarshallerSet(); - } - - @Override - public final void invoke(MessageContext messageContext) throws Exception { - WebServiceMessage request = messageContext.getRequest(); - Object requestObject = unmarshalRequest(request); - if (onUnmarshalRequest(messageContext, requestObject)) { - Object responseObject = invokeInternal(requestObject); - if (responseObject != null) { - WebServiceMessage response = messageContext.getResponse(); - marshalResponse(responseObject, response); - onMarshalResponse(messageContext, requestObject, responseObject); - } - } - } - - private Object unmarshalRequest(WebServiceMessage request) throws IOException { - Unmarshaller unmarshaller = getUnmarshaller(); - Assert.notNull(unmarshaller, "No unmarshaller registered. Check configuration of endpoint."); - Object requestObject = MarshallingUtils.unmarshal(unmarshaller, request); - if (this.logger.isDebugEnabled()) { - this.logger.debug("Unmarshalled payload request to [" + requestObject + "]"); - } - return requestObject; - } - - /** - * Callback for post-processing in terms of unmarshalling. Called on each message - * request, after standard unmarshalling. - *
- * Default implementation returns {@code true}. - * @param messageContext the message context - * @param requestObject the object unmarshalled from the - * {@link MessageContext#getRequest() request} - * @return {@code true} to continue and call {@link #invokeInternal(Object)}; - * {@code false} otherwise - */ - protected boolean onUnmarshalRequest(MessageContext messageContext, Object requestObject) throws Exception { - return true; - } - - private void marshalResponse(Object responseObject, WebServiceMessage response) throws IOException { - Marshaller marshaller = getMarshaller(); - Assert.notNull(marshaller, "No marshaller registered. Check configuration of endpoint."); - if (this.logger.isDebugEnabled()) { - this.logger.debug("Marshalling [" + responseObject + "] to response payload"); - } - MarshallingUtils.marshal(marshaller, responseObject, response); - } - - /** - * Callback for post-processing in terms of marshalling. Called on each message - * request, after standard marshalling of the response. Only invoked when - * {@link #invokeInternal(Object)} returns an object. - *
- * Default implementation is empty. - * @param messageContext the message context - * @param requestObject the object unmarshalled from the - * {@link MessageContext#getRequest() request} - * @param responseObject the object marshalled to the - * {@link MessageContext#getResponse()} request} - */ - protected void onMarshalResponse(MessageContext messageContext, Object requestObject, Object responseObject) { - } - - /** - * Template method that gets called after the marshaller and unmarshaller have been - * set. - *
- * The default implementation does nothing. - * @deprecated as of Spring Web Services 1.5: {@link #afterPropertiesSet()} is no - * longer final, so this can safely be overridden in subclasses - */ - @Deprecated - public void afterMarshallerSet() throws Exception { - } - - /** - * Template method that subclasses must implement to process a request. - *
- * The unmarshalled request object is passed as a parameter, and the returned object - * is marshalled to a response. If no response is required, return {@code null}. - * @param requestObject the unmarshalled message payload as an object - * @return the object to be marshalled as response, or {@code null} if a response is - * not required - */ - protected abstract Object invokeInternal(Object requestObject) throws Exception; - -} diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractSaxPayloadEndpoint.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractSaxPayloadEndpoint.java deleted file mode 100644 index fd38bcaa..00000000 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractSaxPayloadEndpoint.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2005-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://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, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.ws.server.endpoint; - -import javax.xml.transform.Source; -import javax.xml.transform.sax.SAXResult; - -import org.xml.sax.ContentHandler; - -import org.springframework.xml.transform.TransformerObjectSupport; - -/** - * Abstract base class for endpoints that handle the message payload with a SAX - * {@code ContentHandler}. Allows subclasses to create a response by returning a - * {@code Source}. - *
- * Implementations of this class should create a new handler for each call of - * {@code createContentHandler}, because of thread safety. The handlers is later passed on - * to {@code createResponse}, so it can be used for holding request-specific state. - * - * @author Arjen Poutsma - * @since 1.0.0 - * @see #createContentHandler() - * @see #getResponse(org.xml.sax.ContentHandler) - * @deprecated as of Spring Web Services 2.0, in favor of annotated endpoints - */ -@Deprecated -public abstract class AbstractSaxPayloadEndpoint extends TransformerObjectSupport implements PayloadEndpoint { - - /** - * Invokes the provided {@code ContentHandler} on the given request. After parsing has - * been done, the provided response is returned. - * @see #createContentHandler() - * @see #getResponse(org.xml.sax.ContentHandler) - */ - @Override - public final Source invoke(Source request) throws Exception { - ContentHandler contentHandler = null; - if (request != null) { - contentHandler = createContentHandler(); - SAXResult result = new SAXResult(contentHandler); - transform(request, result); - } - return getResponse(contentHandler); - } - - /** - * Returns the SAX {@code ContentHandler} used to parse the incoming request payload. - * A new instance should be created for each call, because of thread-safety. The - * content handler can be used to hold request-specific state. - *
- * If an incoming message does not contain a payload, this method will not be invoked. - * @return a SAX content handler to be used for parsing - */ - protected abstract ContentHandler createContentHandler() throws Exception; - - /** - * Returns the response to be given, if any. This method is called after the request - * payload has been parsed using the SAX {@code ContentHandler}. The passed - * {@code ContentHandler} is created by {@link #createContentHandler()}: it can be - * used to hold request-specific state. - *
- * If an incoming message does not contain a payload, this method will be invoked with - * {@code null} as content handler. - * @param contentHandler the content handler used to parse the request - */ - protected abstract Source getResponse(ContentHandler contentHandler) throws Exception; - -} diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractStaxEventPayloadEndpoint.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractStaxEventPayloadEndpoint.java deleted file mode 100644 index 04ce6ad5..00000000 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractStaxEventPayloadEndpoint.java +++ /dev/null @@ -1,252 +0,0 @@ -/* - * Copyright 2005-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://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, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.ws.server.endpoint; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; - -import javax.xml.namespace.NamespaceContext; -import javax.xml.stream.XMLEventFactory; -import javax.xml.stream.XMLEventReader; -import javax.xml.stream.XMLEventWriter; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.events.XMLEvent; -import javax.xml.stream.util.XMLEventConsumer; -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.TransformerException; -import javax.xml.transform.stream.StreamResult; -import javax.xml.transform.stream.StreamSource; - -import org.springframework.util.xml.StaxUtils; -import org.springframework.ws.WebServiceMessage; -import org.springframework.ws.context.MessageContext; - -/** - * Abstract base class for endpoints that handle the message payload with event-based - * StAX. Allows subclasses to read the request with a {@code XMLEventReader}, and to - * create a response using a {@code XMLEventWriter}. - * - * @author Arjen Poutsma - * @since 1.0.0 - * @see #invokeInternal(javax.xml.stream.XMLEventReader,javax.xml.stream.util.XMLEventConsumer, - * javax.xml.stream.XMLEventFactory) - * @see XMLEventReader - * @see XMLEventWriter - * @deprecated as of Spring Web Services 2.0, in favor of annotated endpoints - */ -@Deprecated -public abstract class AbstractStaxEventPayloadEndpoint extends AbstractStaxPayloadEndpoint implements MessageEndpoint { - - private XMLEventFactory eventFactory; - - @Override - public final void invoke(MessageContext messageContext) throws Exception { - XMLEventReader eventReader = getEventReader(messageContext.getRequest().getPayloadSource()); - XMLEventWriter streamWriter = new ResponseCreatingEventWriter(messageContext); - invokeInternal(eventReader, streamWriter, getEventFactory()); - streamWriter.flush(); - } - - /** - * Create a {@code XMLEventFactory} that this endpoint will use to create - * {@code XMLEvent}s. Can be overridden in subclasses, adding further initialization - * of the factory. The resulting {@code XMLEventFactory} is cached, so this method - * will only be called once. - * @return the created {@code XMLEventFactory} - */ - protected XMLEventFactory createXmlEventFactory() { - return XMLEventFactory.newInstance(); - } - - /** Returns an {@code XMLEventFactory} to read XML from. */ - private XMLEventFactory getEventFactory() { - if (this.eventFactory == null) { - this.eventFactory = createXmlEventFactory(); - } - return this.eventFactory; - } - - private XMLEventReader getEventReader(Source source) throws XMLStreamException, TransformerException { - if (source == null) { - return null; - } - XMLEventReader eventReader = null; - if (StaxUtils.isStaxSource(source)) { - eventReader = StaxUtils.getXMLEventReader(source); - if (eventReader == null) { - XMLStreamReader streamReader = StaxUtils.getXMLStreamReader(source); - if (streamReader != null) { - try { - eventReader = getInputFactory().createXMLEventReader(streamReader); - } - catch (XMLStreamException ex) { - eventReader = null; - } - } - } - } - if (eventReader == null) { - try { - eventReader = getInputFactory().createXMLEventReader(source); - } - catch (XMLStreamException | UnsupportedOperationException ex) { - eventReader = null; - } - } - if (eventReader == null) { - // as a final resort, transform the source to a stream, and read from that - ByteArrayOutputStream os = new ByteArrayOutputStream(); - transform(source, new StreamResult(os)); - ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray()); - eventReader = getInputFactory().createXMLEventReader(is); - } - return eventReader; - } - - private XMLEventWriter getEventWriter(Result result) { - XMLEventWriter eventWriter = null; - if (StaxUtils.isStaxResult(result)) { - eventWriter = StaxUtils.getXMLEventWriter(result); - } - if (eventWriter == null) { - try { - eventWriter = getOutputFactory().createXMLEventWriter(result); - } - catch (XMLStreamException ex) { - // ignore - } - } - return eventWriter; - } - - /** - * Template method. Subclasses must implement this. Offers the request payload as a - * {@code XMLEventReader}, and a {@code XMLEventWriter} to write the response payload - * to. - * @param eventReader the reader to read the payload events from - * @param eventWriter the writer to write payload events to - * @param eventFactory an {@code XMLEventFactory} that can be used to create events - */ - protected abstract void invokeInternal(XMLEventReader eventReader, XMLEventConsumer eventWriter, - XMLEventFactory eventFactory) throws Exception; - - /** - * Implementation of the {@code XMLEventWriter} interface that creates a response - * {@code WebServiceMessage} as soon as any method is called, thus lazily creating the - * response. - */ - private final class ResponseCreatingEventWriter implements XMLEventWriter { - - private XMLEventWriter eventWriter; - - private MessageContext messageContext; - - private ByteArrayOutputStream os; - - ResponseCreatingEventWriter(MessageContext messageContext) { - this.messageContext = messageContext; - } - - @Override - public NamespaceContext getNamespaceContext() { - return this.eventWriter.getNamespaceContext(); - } - - @Override - public void setNamespaceContext(NamespaceContext context) throws XMLStreamException { - createEventWriter(); - this.eventWriter.setNamespaceContext(context); - } - - @Override - public void add(XMLEventReader reader) throws XMLStreamException { - createEventWriter(); - while (reader.hasNext()) { - add(reader.nextEvent()); - } - } - - @Override - public void add(XMLEvent event) throws XMLStreamException { - createEventWriter(); - this.eventWriter.add(event); - if (event.isEndDocument()) { - if (this.os != null) { - this.eventWriter.flush(); - // if we used an output stream cache, we have to transform it to the - // response again - try { - ByteArrayInputStream is = new ByteArrayInputStream(this.os.toByteArray()); - transform(new StreamSource(is), this.messageContext.getResponse().getPayloadResult()); - } - catch (TransformerException ex) { - throw new XMLStreamException(ex); - } - } - } - } - - @Override - public void close() throws XMLStreamException { - if (this.eventWriter != null) { - this.eventWriter.close(); - } - } - - @Override - public void flush() throws XMLStreamException { - if (this.eventWriter != null) { - this.eventWriter.flush(); - } - } - - @Override - public String getPrefix(String uri) throws XMLStreamException { - createEventWriter(); - return this.eventWriter.getPrefix(uri); - } - - @Override - public void setDefaultNamespace(String uri) throws XMLStreamException { - createEventWriter(); - this.eventWriter.setDefaultNamespace(uri); - } - - @Override - public void setPrefix(String prefix, String uri) throws XMLStreamException { - createEventWriter(); - this.eventWriter.setPrefix(prefix, uri); - } - - private void createEventWriter() throws XMLStreamException { - if (this.eventWriter == null) { - WebServiceMessage response = this.messageContext.getResponse(); - this.eventWriter = getEventWriter(response.getPayloadResult()); - if (this.eventWriter == null) { - // as a final resort, use a stream, and transform that at - // endDocument() - this.os = new ByteArrayOutputStream(); - this.eventWriter = getOutputFactory().createXMLEventWriter(this.os); - } - } - } - - } - -} diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractStaxPayloadEndpoint.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractStaxPayloadEndpoint.java deleted file mode 100644 index 65e544e4..00000000 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractStaxPayloadEndpoint.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2005-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://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, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.ws.server.endpoint; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; - -import org.springframework.xml.XMLInputFactoryUtils; -import org.springframework.xml.transform.TransformerObjectSupport; - -/** - * Abstract base class for endpoints use StAX. Provides an {@code XMLInputFactory} and an - * {@code XMLOutputFactory}. - * - * @author Arjen Poutsma - * @since 1.0.0 - * @see XMLInputFactory - * @see XMLOutputFactory - * @deprecated as of Spring Web Services 2.0, in favor of annotated endpoints - */ -@Deprecated -@SuppressWarnings("Since15") -public abstract class AbstractStaxPayloadEndpoint extends TransformerObjectSupport { - - private XMLInputFactory inputFactory; - - private XMLOutputFactory outputFactory; - - /** Returns an {@code XMLInputFactory} to read XML from. */ - protected final XMLInputFactory getInputFactory() { - if (this.inputFactory == null) { - this.inputFactory = createXmlInputFactory(); - } - return this.inputFactory; - } - - /** Returns an {@code XMLOutputFactory} to write XML to. */ - protected final XMLOutputFactory getOutputFactory() { - if (this.outputFactory == null) { - this.outputFactory = createXmlOutputFactory(); - } - return this.outputFactory; - } - - /** - * Create a {@code XMLInputFactory} that this endpoint will use to create - * {@code XMLStreamReader}s or {@code XMLEventReader}. Can be overridden in - * subclasses, adding further initialization of the factory. The resulting - * {@code XMLInputFactory} is cached, so this method will only be called once. - * @return the created {@code XMLInputFactory} - */ - protected XMLInputFactory createXmlInputFactory() { - return XMLInputFactoryUtils.newInstance(); - } - - /** - * Create a {@code XMLOutputFactory} that this endpoint will use to create - * {@code XMLStreamWriters}s or {@code XMLEventWriters}. Can be overridden in - * subclasses, adding further initialization of the factory. The resulting - * {@code XMLOutputFactory} is cached, so this method will only be called once. - * @return the created {@code XMLOutputFactory} - */ - protected XMLOutputFactory createXmlOutputFactory() { - return XMLOutputFactory.newInstance(); - } - -} diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractStaxStreamPayloadEndpoint.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractStaxStreamPayloadEndpoint.java deleted file mode 100644 index edbf5a91..00000000 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractStaxStreamPayloadEndpoint.java +++ /dev/null @@ -1,364 +0,0 @@ -/* - * Copyright 2005-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://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, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.ws.server.endpoint; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; - -import javax.xml.namespace.NamespaceContext; -import javax.xml.stream.XMLEventReader; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.TransformerException; -import javax.xml.transform.stream.StreamResult; -import javax.xml.transform.stream.StreamSource; - -import org.springframework.util.xml.StaxUtils; -import org.springframework.ws.WebServiceMessage; -import org.springframework.ws.context.MessageContext; - -/** - * Abstract base class for endpoints that handle the message payload with streaming StAX. - * Allows subclasses to read the request with a {@code XMLStreamReader}, and to create a - * response using a {@code XMLStreamWriter}. - * - * @author Arjen Poutsma - * @since 1.0.0 - * @see #invokeInternal(javax.xml.stream.XMLStreamReader,javax.xml.stream.XMLStreamWriter) - * @see XMLStreamReader - * @see XMLStreamWriter - * @deprecated as of Spring Web Services 2.0, in favor of annotated endpoints - */ -@Deprecated -@SuppressWarnings("Since15") -public abstract class AbstractStaxStreamPayloadEndpoint extends AbstractStaxPayloadEndpoint implements MessageEndpoint { - - @Override - public final void invoke(MessageContext messageContext) throws Exception { - XMLStreamReader streamReader = getStreamReader(messageContext.getRequest().getPayloadSource()); - XMLStreamWriter streamWriter = new ResponseCreatingStreamWriter(messageContext); - invokeInternal(streamReader, streamWriter); - streamWriter.close(); - } - - private XMLStreamReader getStreamReader(Source source) throws XMLStreamException, TransformerException { - if (source == null) { - return null; - } - XMLStreamReader streamReader = null; - if (StaxUtils.isStaxSource(source)) { - streamReader = StaxUtils.getXMLStreamReader(source); - if (streamReader == null) { - XMLEventReader eventReader = StaxUtils.getXMLEventReader(source); - if (eventReader != null) { - try { - streamReader = StaxUtils.createEventStreamReader(eventReader); - } - catch (XMLStreamException ex) { - streamReader = null; - } - } - } - - } - if (streamReader == null) { - try { - streamReader = getInputFactory().createXMLStreamReader(source); - } - catch (XMLStreamException | UnsupportedOperationException ex) { - // ignore - } - } - if (streamReader == null) { - // as a final resort, transform the source to a stream, and read from that - ByteArrayOutputStream os = new ByteArrayOutputStream(); - transform(source, new StreamResult(os)); - ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray()); - streamReader = getInputFactory().createXMLStreamReader(is); - } - return streamReader; - } - - private XMLStreamWriter getStreamWriter(Result result) { - XMLStreamWriter streamWriter = null; - if (StaxUtils.isStaxResult(result)) { - streamWriter = StaxUtils.getXMLStreamWriter(result); - } - if (streamWriter == null) { - try { - streamWriter = getOutputFactory().createXMLStreamWriter(result); - } - catch (XMLStreamException ex) { - // ignore - } - } - return streamWriter; - } - - /** - * Template method. Subclasses must implement this. Offers the request payload as a - * {@code XMLStreamReader}, and a {@code XMLStreamWriter} to write the response - * payload to. - * @param streamReader the reader to read the payload from - * @param streamWriter the writer to write the payload to - */ - protected abstract void invokeInternal(XMLStreamReader streamReader, XMLStreamWriter streamWriter) throws Exception; - - /** - * Implementation of the {@code XMLStreamWriter} interface that creates a response - * {@code WebServiceMessage} as soon as any method is called, thus lazily creating the - * response. - */ - private final class ResponseCreatingStreamWriter implements XMLStreamWriter { - - private MessageContext messageContext; - - private XMLStreamWriter streamWriter; - - private ByteArrayOutputStream os; - - private ResponseCreatingStreamWriter(MessageContext messageContext) { - this.messageContext = messageContext; - } - - @Override - public NamespaceContext getNamespaceContext() { - return this.streamWriter.getNamespaceContext(); - } - - @Override - public void setNamespaceContext(NamespaceContext context) throws XMLStreamException { - createStreamWriter(); - this.streamWriter.setNamespaceContext(context); - } - - @Override - public void close() throws XMLStreamException { - if (this.streamWriter != null) { - this.streamWriter.close(); - if (this.os != null) { - this.streamWriter.flush(); - // if we used an output stream cache, we have to transform it to the - // response again - try { - ByteArrayInputStream is = new ByteArrayInputStream(this.os.toByteArray()); - transform(new StreamSource(is), this.messageContext.getResponse().getPayloadResult()); - this.os = null; - } - catch (TransformerException ex) { - throw new XMLStreamException(ex); - } - } - this.streamWriter = null; - } - - } - - @Override - public void flush() throws XMLStreamException { - if (this.streamWriter != null) { - this.streamWriter.flush(); - } - } - - @Override - public String getPrefix(String uri) throws XMLStreamException { - createStreamWriter(); - return this.streamWriter.getPrefix(uri); - } - - @Override - public Object getProperty(String name) throws IllegalArgumentException { - return this.streamWriter.getProperty(name); - } - - @Override - public void setDefaultNamespace(String uri) throws XMLStreamException { - createStreamWriter(); - this.streamWriter.setDefaultNamespace(uri); - } - - @Override - public void setPrefix(String prefix, String uri) throws XMLStreamException { - createStreamWriter(); - this.streamWriter.setPrefix(prefix, uri); - } - - @Override - public void writeAttribute(String localName, String value) throws XMLStreamException { - createStreamWriter(); - this.streamWriter.writeAttribute(localName, value); - } - - @Override - public void writeAttribute(String namespaceURI, String localName, String value) throws XMLStreamException { - createStreamWriter(); - this.streamWriter.writeAttribute(namespaceURI, localName, value); - } - - @Override - public void writeAttribute(String prefix, String namespaceURI, String localName, String value) - throws XMLStreamException { - createStreamWriter(); - this.streamWriter.writeAttribute(prefix, namespaceURI, localName, value); - } - - @Override - public void writeCData(String data) throws XMLStreamException { - createStreamWriter(); - this.streamWriter.writeCData(data); - } - - @Override - public void writeCharacters(String text) throws XMLStreamException { - createStreamWriter(); - this.streamWriter.writeCharacters(text); - } - - @Override - public void writeCharacters(char[] text, int start, int len) throws XMLStreamException { - createStreamWriter(); - this.streamWriter.writeCharacters(text, start, len); - } - - @Override - public void writeComment(String data) throws XMLStreamException { - createStreamWriter(); - this.streamWriter.writeComment(data); - } - - @Override - public void writeDTD(String dtd) throws XMLStreamException { - createStreamWriter(); - this.streamWriter.writeDTD(dtd); - } - - @Override - public void writeDefaultNamespace(String namespaceURI) throws XMLStreamException { - createStreamWriter(); - this.streamWriter.writeDefaultNamespace(namespaceURI); - } - - @Override - public void writeEmptyElement(String localName) throws XMLStreamException { - createStreamWriter(); - this.streamWriter.writeEmptyElement(localName); - } - - @Override - public void writeEmptyElement(String namespaceURI, String localName) throws XMLStreamException { - createStreamWriter(); - this.streamWriter.writeEmptyElement(namespaceURI, localName); - } - - @Override - public void writeEmptyElement(String prefix, String localName, String namespaceURI) throws XMLStreamException { - createStreamWriter(); - this.streamWriter.writeEmptyElement(prefix, localName, namespaceURI); - } - - @Override - public void writeEndDocument() throws XMLStreamException { - createStreamWriter(); - this.streamWriter.writeEndDocument(); - } - - @Override - public void writeEndElement() throws XMLStreamException { - createStreamWriter(); - this.streamWriter.writeEndElement(); - } - - @Override - public void writeEntityRef(String name) throws XMLStreamException { - createStreamWriter(); - this.streamWriter.writeEntityRef(name); - } - - @Override - public void writeNamespace(String prefix, String namespaceURI) throws XMLStreamException { - createStreamWriter(); - this.streamWriter.writeNamespace(prefix, namespaceURI); - } - - @Override - public void writeProcessingInstruction(String target) throws XMLStreamException { - createStreamWriter(); - this.streamWriter.writeProcessingInstruction(target); - } - - @Override - public void writeProcessingInstruction(String target, String data) throws XMLStreamException { - createStreamWriter(); - this.streamWriter.writeProcessingInstruction(target, data); - } - - @Override - public void writeStartDocument() throws XMLStreamException { - createStreamWriter(); - this.streamWriter.writeStartDocument(); - } - - @Override - public void writeStartDocument(String version) throws XMLStreamException { - createStreamWriter(); - this.streamWriter.writeStartDocument(version); - } - - @Override - public void writeStartDocument(String encoding, String version) throws XMLStreamException { - createStreamWriter(); - this.streamWriter.writeStartDocument(encoding, version); - } - - @Override - public void writeStartElement(String localName) throws XMLStreamException { - createStreamWriter(); - this.streamWriter.writeStartElement(localName); - } - - @Override - public void writeStartElement(String namespaceURI, String localName) throws XMLStreamException { - createStreamWriter(); - this.streamWriter.writeStartElement(namespaceURI, localName); - } - - @Override - public void writeStartElement(String prefix, String localName, String namespaceURI) throws XMLStreamException { - createStreamWriter(); - this.streamWriter.writeStartElement(prefix, localName, namespaceURI); - } - - private void createStreamWriter() throws XMLStreamException { - if (this.streamWriter == null) { - WebServiceMessage response = this.messageContext.getResponse(); - this.streamWriter = getStreamWriter(response.getPayloadResult()); - if (this.streamWriter == null) { - // as a final resort, use a stream, and transform that at - // endDocument() - this.os = new ByteArrayOutputStream(); - this.streamWriter = getOutputFactory().createXMLStreamWriter(this.os); - } - } - } - - } - -} diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractValidatingMarshallingPayloadEndpoint.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractValidatingMarshallingPayloadEndpoint.java deleted file mode 100644 index 9578a361..00000000 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractValidatingMarshallingPayloadEndpoint.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright 2005-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://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, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.ws.server.endpoint; - -import org.springframework.validation.BindException; -import org.springframework.validation.Errors; -import org.springframework.validation.ValidationUtils; -import org.springframework.validation.Validator; -import org.springframework.ws.context.MessageContext; - -/** - * Extension of the {@link AbstractMarshallingPayloadEndpoint} which validates the request - * payload with {@link Validator}(s). The desired validators can be set using properties, - * and must {@link Validator#supports(Class) support} the request object. - * - * @author Arjen Poutsma - * @since 1.0.2 - * @deprecated as of Spring Web Services 2.0, in favor of annotated endpoints - */ -@Deprecated -public abstract class AbstractValidatingMarshallingPayloadEndpoint extends AbstractMarshallingPayloadEndpoint { - - /** Default request object name used for validating request objects. */ - public static final String DEFAULT_REQUEST_NAME = "request"; - - private String requestName = DEFAULT_REQUEST_NAME; - - private Validator[] validators; - - /** Return the name of the request object for validation error codes. */ - public String getRequestName() { - return this.requestName; - } - - /** Set the name of the request object user for validation errors. */ - public void setRequestName(String requestName) { - this.requestName = requestName; - } - - /** Return the primary Validator for this controller. */ - public Validator getValidator() { - Validator[] validators = getValidators(); - return (validators != null && validators.length > 0) ? validators[0] : null; - } - - /** - * Set the primary {@link Validator} for this endpoint. The {@link Validator} is must - * support the unmarshalled class. If there are one or more existing validators set - * already when this method is called, only the specified validator will be kept. Use - * {@link #setValidators(Validator[])} to set multiple validators. - */ - public void setValidator(Validator validator) { - this.validators = new Validator[] { validator }; - } - - /** Return the Validators for this controller. */ - public Validator[] getValidators() { - return this.validators; - } - - /** - * Set the Validators for this controller. The Validator must support the specified - * command class. - */ - public void setValidators(Validator[] validators) { - this.validators = validators; - } - - @Override - protected boolean onUnmarshalRequest(MessageContext messageContext, Object requestObject) throws Exception { - Validator[] validators = getValidators(); - if (validators != null) { - Errors errors = new BindException(requestObject, getRequestName()); - for (Validator validator : validators) { - ValidationUtils.invokeValidator(validator, requestObject, errors); - } - if (errors.hasErrors()) { - return onValidationErrors(messageContext, requestObject, errors); - } - } - return true; - } - - /** - * Callback for post-processing validation errors. Called when validator(s) have been - * specified, and validation fails. - * @param messageContext the message context - * @param requestObject the object unmarshalled from the - * {@link MessageContext#getRequest() request} - * @param errors validation errors holder - * @return {@code true} to continue and call {@link #invokeInternal(Object)}; - * {@code false} otherwise - */ - protected abstract boolean onValidationErrors(MessageContext messageContext, Object requestObject, Errors errors); - -} diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractXomPayloadEndpoint.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractXomPayloadEndpoint.java deleted file mode 100644 index 8f38c1bc..00000000 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractXomPayloadEndpoint.java +++ /dev/null @@ -1,317 +0,0 @@ -/* - * Copyright 2005-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://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, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.ws.server.endpoint; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.Reader; -import java.util.Locale; - -import javax.xml.stream.XMLEventReader; -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.transform.Source; -import javax.xml.transform.stream.StreamSource; - -import nu.xom.Attribute; -import nu.xom.Builder; -import nu.xom.Document; -import nu.xom.Element; -import nu.xom.NodeFactory; -import nu.xom.ParentNode; -import nu.xom.ParsingException; -import nu.xom.Serializer; -import nu.xom.converters.DOMConverter; -import org.w3c.dom.Node; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; - -import org.springframework.core.NestedRuntimeException; -import org.springframework.xml.namespace.QNameUtils; -import org.springframework.xml.transform.TransformerObjectSupport; -import org.springframework.xml.transform.TraxUtils; - -/** - * Abstract base class for endpoints that handle the message payload as XOM elements. - * Offers the message payload as a XOM {@code Element}, and allows subclasses to create a - * response by returning an {@code Element}. - *
- * An {@code AbstractXomPayloadEndpoint} only accept one payload element. Multiple payload - * elements are not in accordance with WS-I. - * - * @author Arjen Poutsma - * @since 1.0.0 - * @see Element - * @deprecated as of Spring Web Services 2.0, in favor of annotated endpoints - */ -@Deprecated -@SuppressWarnings("Since15") -public abstract class AbstractXomPayloadEndpoint extends TransformerObjectSupport implements PayloadEndpoint { - - @Override - public final Source invoke(Source request) throws Exception { - Element requestElement = null; - if (request != null) { - XomSourceCallback sourceCallback = new XomSourceCallback(); - try { - TraxUtils.doWithSource(request, sourceCallback); - } - catch (XomParsingException ex) { - throw (ParsingException) ex.getCause(); - } - requestElement = sourceCallback.element; - } - Element responseElement = invokeInternal(requestElement); - return (responseElement != null) ? convertResponse(responseElement) : null; - } - - private Source convertResponse(Element responseElement) throws IOException { - ByteArrayOutputStream os = new ByteArrayOutputStream(); - Serializer serializer = createSerializer(os); - Document document = responseElement.getDocument(); - if (document == null) { - document = new Document(responseElement); - } - serializer.write(document); - byte[] bytes = os.toByteArray(); - return new StreamSource(new ByteArrayInputStream(bytes)); - } - - /** - * Creates a {@link Serializer} to be used for writing the response to. - *
- * Default implementation uses the UTF-8 encoding and does not set any options, but - * this may be changed in subclasses. - * @param outputStream the output stream to serialize to - * @return the serializer - */ - protected Serializer createSerializer(OutputStream outputStream) { - return new Serializer(outputStream); - } - - /** - * Template method. Subclasses must implement this. Offers the request payload as a - * XOM {@code Element}, and allows subclasses to return a response {@code Element}. - * @param requestElement the contents of the SOAP message as XOM element - * @return the response element. Can be {@code null} to specify no response. - */ - protected abstract Element invokeInternal(Element requestElement) throws Exception; - - private static final class XomSourceCallback implements TraxUtils.SourceCallback { - - private Element element; - - @Override - public void domSource(Node node) { - if (node.getNodeType() == Node.ELEMENT_NODE) { - this.element = DOMConverter.convert((org.w3c.dom.Element) node); - } - else if (node.getNodeType() == Node.DOCUMENT_NODE) { - Document document = DOMConverter.convert((org.w3c.dom.Document) node); - this.element = document.getRootElement(); - } - else { - throw new IllegalArgumentException("DOMSource contains neither Document nor Element"); - } - } - - @Override - public void saxSource(XMLReader reader, InputSource inputSource) throws IOException, SAXException { - try { - Builder builder = new Builder(reader); - Document document; - if (inputSource.getByteStream() != null) { - document = builder.build(inputSource.getByteStream()); - } - else if (inputSource.getCharacterStream() != null) { - document = builder.build(inputSource.getCharacterStream()); - } - else { - throw new IllegalArgumentException( - "InputSource in SAXSource contains neither byte stream nor character stream"); - } - this.element = document.getRootElement(); - } - catch (ParsingException ex) { - throw new XomParsingException(ex); - } - } - - @Override - public void staxSource(XMLEventReader eventReader) throws XMLStreamException { - throw new IllegalArgumentException("XMLEventReader not supported"); - } - - @Override - public void staxSource(XMLStreamReader streamReader) throws XMLStreamException { - Document document = StaxStreamConverter.convert(streamReader); - this.element = document.getRootElement(); - } - - @Override - public void streamSource(InputStream inputStream) throws IOException { - try { - Builder builder = new Builder(); - Document document = builder.build(inputStream); - this.element = document.getRootElement(); - } - catch (ParsingException ex) { - throw new XomParsingException(ex); - } - } - - @Override - public void streamSource(Reader reader) throws IOException { - try { - Builder builder = new Builder(); - Document document = builder.build(reader); - this.element = document.getRootElement(); - } - catch (ParsingException ex) { - throw new XomParsingException(ex); - } - } - - @Override - public void source(String systemId) throws Exception { - try { - Builder builder = new Builder(); - Document document = builder.build(systemId); - this.element = document.getRootElement(); - } - catch (ParsingException ex) { - throw new XomParsingException(ex); - } - } - - } - - @SuppressWarnings("serial") - private static final class XomParsingException extends NestedRuntimeException { - - private XomParsingException(ParsingException ex) { - super(ex.getMessage(), ex); - } - - } - - private static final class StaxStreamConverter { - - private static Document convert(XMLStreamReader streamReader) throws XMLStreamException { - NodeFactory nodeFactory = new NodeFactory(); - Document document = null; - Element element = null; - ParentNode parent = null; - boolean documentFinished = false; - while (streamReader.hasNext()) { - int event = streamReader.next(); - switch (event) { - case XMLStreamConstants.START_DOCUMENT: - document = nodeFactory.startMakingDocument(); - parent = document; - break; - case XMLStreamConstants.END_DOCUMENT: - nodeFactory.finishMakingDocument(document); - documentFinished = true; - break; - case XMLStreamConstants.START_ELEMENT: - if (document == null) { - document = nodeFactory.startMakingDocument(); - parent = document; - } - String name = QNameUtils.toQualifiedName(streamReader.getName()); - if (element == null) { - element = nodeFactory.makeRootElement(name, streamReader.getNamespaceURI()); - document.setRootElement(element); - } - else { - element = nodeFactory.startMakingElement(name, streamReader.getNamespaceURI()); - parent.appendChild(element); - } - convertNamespaces(streamReader, element); - convertAttributes(streamReader, nodeFactory); - parent = element; - break; - case XMLStreamConstants.END_ELEMENT: - nodeFactory.finishMakingElement(element); - parent = parent.getParent(); - break; - case XMLStreamConstants.ATTRIBUTE: - convertAttributes(streamReader, nodeFactory); - break; - case XMLStreamConstants.CHARACTERS: - nodeFactory.makeText(streamReader.getText()); - break; - case XMLStreamConstants.COMMENT: - nodeFactory.makeComment(streamReader.getText()); - break; - default: - break; - } - } - if (!documentFinished) { - nodeFactory.finishMakingDocument(document); - } - return document; - } - - private static void convertNamespaces(XMLStreamReader streamReader, Element element) { - for (int i = 0; i < streamReader.getNamespaceCount(); i++) { - String uri = streamReader.getNamespaceURI(i); - String prefix = streamReader.getNamespacePrefix(i); - - element.addNamespaceDeclaration(prefix, uri); - } - - } - - private static void convertAttributes(XMLStreamReader streamReader, NodeFactory nodeFactory) { - for (int i = 0; i < streamReader.getAttributeCount(); i++) { - String name = QNameUtils.toQualifiedName(streamReader.getAttributeName(i)); - String uri = streamReader.getAttributeNamespace(i); - String value = streamReader.getAttributeValue(i); - Attribute.Type type = convertAttributeType(streamReader.getAttributeType(i)); - - nodeFactory.makeAttribute(name, uri, value, type); - } - } - - private static Attribute.Type convertAttributeType(String type) { - type = type.toUpperCase(Locale.ENGLISH); - return switch (type) { - case "CDATA" -> Attribute.Type.CDATA; - case "ENTITIES" -> Attribute.Type.ENTITIES; - case "ENTITY" -> Attribute.Type.ENTITY; - case "ENUMERATION" -> Attribute.Type.ENUMERATION; - case "ID" -> Attribute.Type.ID; - case "IDREF" -> Attribute.Type.IDREF; - case "IDREFS" -> Attribute.Type.IDREFS; - case "NMTOKEN" -> Attribute.Type.NMTOKEN; - case "NMTOKENS" -> Attribute.Type.NMTOKENS; - case "NOTATION" -> Attribute.Type.NOTATION; - default -> Attribute.Type.UNDECLARED; - }; - } - - } - -} diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/GenericMarshallingMethodEndpointAdapter.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/GenericMarshallingMethodEndpointAdapter.java deleted file mode 100644 index f84fc00c..00000000 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/GenericMarshallingMethodEndpointAdapter.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright 2005-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://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, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.ws.server.endpoint.adapter; - -import java.lang.reflect.Method; - -import org.springframework.oxm.GenericMarshaller; -import org.springframework.oxm.GenericUnmarshaller; -import org.springframework.oxm.Marshaller; -import org.springframework.oxm.Unmarshaller; -import org.springframework.oxm.jaxb.Jaxb2Marshaller; -import org.springframework.ws.server.endpoint.MethodEndpoint; - -/** - * Subclass of {@link MarshallingMethodEndpointAdapter} that supports - * {@link GenericMarshaller} and {@link GenericUnmarshaller}. More specifically, this - * adapter is aware of the {@link Method#getGenericParameterTypes()} and - * {@link Method#getGenericReturnType()}. - *
- * Prefer to use this adapter rather than the plain - * {@link MarshallingMethodEndpointAdapter} in combination with Java 5 marshallers, such - * as the {@link Jaxb2Marshaller}. - * - * @author Arjen Poutsma - * @since 1.0.2 - * @deprecated as of Spring Web Services 2.0, in favor of - * {@link DefaultMethodEndpointAdapter} and - * {@link org.springframework.ws.server.endpoint.adapter.method.MarshallingPayloadMethodProcessor - * MarshallingPayloadMethodProcessor}. - */ -@Deprecated -public class GenericMarshallingMethodEndpointAdapter extends MarshallingMethodEndpointAdapter { - - /** - * Creates a new {@code GenericMarshallingMethodEndpointAdapter}. The - * {@link Marshaller} and {@link Unmarshaller} must be injected using properties. - * @see #setMarshaller(org.springframework.oxm.Marshaller) - * @see #setUnmarshaller(org.springframework.oxm.Unmarshaller) - */ - public GenericMarshallingMethodEndpointAdapter() { - } - - /** - * Creates a new {@code GenericMarshallingMethodEndpointAdapter} with the given - * marshaller. If the given {@link Marshaller} also implements the - * {@link Unmarshaller} interface, it is used for both marshalling and unmarshalling. - * Otherwise, an exception is thrown. - *
- * Note that all {@link Marshaller} implementations in Spring-WS also implement the - * {@link Unmarshaller} interface, so that you can safely use this constructor. - * @param marshaller object used as marshaller and unmarshaller - * @throws IllegalArgumentException when {@code marshaller} does not implement the - * {@link Unmarshaller} interface - */ - public GenericMarshallingMethodEndpointAdapter(Marshaller marshaller) { - super(marshaller); - } - - /** - * Creates a new {@code GenericMarshallingMethodEndpointAdapter} with the given - * marshaller and unmarshaller. - * @param marshaller the marshaller to use - * @param unmarshaller the unmarshaller to use - */ - public GenericMarshallingMethodEndpointAdapter(Marshaller marshaller, Unmarshaller unmarshaller) { - super(marshaller, unmarshaller); - } - - @Override - protected boolean supportsInternal(MethodEndpoint methodEndpoint) { - Method method = methodEndpoint.getMethod(); - return supportsReturnType(method) && supportsParameters(method); - } - - private boolean supportsReturnType(Method method) { - if (Void.TYPE.equals(method.getReturnType())) { - return true; - } - else { - if (getMarshaller() instanceof GenericMarshaller) { - return ((GenericMarshaller) getMarshaller()).supports(method.getGenericReturnType()); - } - else { - return getMarshaller().supports(method.getReturnType()); - } - } - } - - private boolean supportsParameters(Method method) { - if (method.getParameterTypes().length != 1) { - return false; - } - else if (getUnmarshaller() instanceof GenericUnmarshaller genericUnmarshaller) { - return genericUnmarshaller.supports(method.getGenericParameterTypes()[0]); - } - else { - return getUnmarshaller().supports(method.getParameterTypes()[0]); - } - } - -} diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/MarshallingMethodEndpointAdapter.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/MarshallingMethodEndpointAdapter.java deleted file mode 100644 index a7cd1f18..00000000 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/MarshallingMethodEndpointAdapter.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright 2005-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://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, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.ws.server.endpoint.adapter; - -import java.io.IOException; -import java.lang.reflect.Method; - -import org.springframework.beans.factory.InitializingBean; -import org.springframework.oxm.Marshaller; -import org.springframework.oxm.Unmarshaller; -import org.springframework.util.Assert; -import org.springframework.ws.WebServiceMessage; -import org.springframework.ws.context.MessageContext; -import org.springframework.ws.server.EndpointMapping; -import org.springframework.ws.server.endpoint.MethodEndpoint; -import org.springframework.ws.support.MarshallingUtils; - -/** - * Adapter that supports endpoint methods that use marshalling. Supports methods with the - * following signature: - * - *
- * void handleMyMessage(MyUnmarshalledType request); or
- *
- * MyMarshalledType handleMyMessage(MyUnmarshalledType request);
- *
- * I.e. methods that take a single parameter that {@link Unmarshaller#supports(Class) is
- * supported} by the {@link Unmarshaller}, and return either {@code void} or a type
- * {@link Marshaller#supports(Class) supported} by the {@link Marshaller}. The method can
- * have any name, as long as it is mapped by an {@link EndpointMapping}.
- * - * This endpoint needs a {@code Marshaller} and {@code Unmarshaller}, both of which can be - * set using properties. - * - * @author Arjen Poutsma - * @since 1.0.0 - * @see #setMarshaller(org.springframework.oxm.Marshaller) - * @see #setUnmarshaller(org.springframework.oxm.Unmarshaller) - * @deprecated as of Spring Web Services 2.0, in favor of - * {@link DefaultMethodEndpointAdapter} and - * {@link org.springframework.ws.server.endpoint.adapter.method.MarshallingPayloadMethodProcessor - * MarshallingPayloadMethodProcessor}. - */ -@Deprecated -public class MarshallingMethodEndpointAdapter extends AbstractMethodEndpointAdapter implements InitializingBean { - - private Marshaller marshaller; - - private Unmarshaller unmarshaller; - - /** - * Creates a new {@code MarshallingMethodEndpointAdapter}. The {@link Marshaller} and - * {@link Unmarshaller} must be injected using properties. - * @see #setMarshaller(org.springframework.oxm.Marshaller) - * @see #setUnmarshaller(org.springframework.oxm.Unmarshaller) - */ - public MarshallingMethodEndpointAdapter() { - } - - /** - * Creates a new {@code MarshallingMethodEndpointAdapter} with the given marshaller. - * If the given {@link Marshaller} also implements the {@link Unmarshaller} interface, - * it is used for both marshalling and unmarshalling. Otherwise, an exception is - * thrown. - *
- * Note that all {@link Marshaller} implementations in Spring also implement the - * {@link Unmarshaller} interface, so that you can safely use this constructor. - * @param marshaller object used as marshaller and unmarshaller - * @throws IllegalArgumentException when {@code marshaller} does not implement the - * {@link Unmarshaller} interface - */ - public MarshallingMethodEndpointAdapter(Marshaller marshaller) { - Assert.notNull(marshaller, "marshaller must not be null"); - if (!(marshaller instanceof Unmarshaller)) { - throw new IllegalArgumentException("Marshaller [" + marshaller + "] does not implement the Unmarshaller " - + "interface. Please set an Unmarshaller explicitly by using the " - + "MarshallingMethodEndpointAdapter(Marshaller, Unmarshaller) constructor."); - } - else { - this.setMarshaller(marshaller); - this.setUnmarshaller((Unmarshaller) marshaller); - } - } - - /** - * Creates a new {@code MarshallingMethodEndpointAdapter} with the given marshaller - * and unmarshaller. - * @param marshaller the marshaller to use - * @param unmarshaller the unmarshaller to use - */ - public MarshallingMethodEndpointAdapter(Marshaller marshaller, Unmarshaller unmarshaller) { - Assert.notNull(marshaller, "marshaller must not be null"); - Assert.notNull(unmarshaller, "unmarshaller must not be null"); - this.setMarshaller(marshaller); - this.setUnmarshaller(unmarshaller); - } - - /** Returns the marshaller used for transforming objects into XML. */ - public Marshaller getMarshaller() { - return this.marshaller; - } - - /** Sets the marshaller used for transforming objects into XML. */ - public final void setMarshaller(Marshaller marshaller) { - this.marshaller = marshaller; - } - - /** Returns the unmarshaller used for transforming XML into objects. */ - public Unmarshaller getUnmarshaller() { - return this.unmarshaller; - } - - /** Sets the unmarshaller used for transforming XML into objects. */ - public final void setUnmarshaller(Unmarshaller unmarshaller) { - this.unmarshaller = unmarshaller; - } - - @Override - public void afterPropertiesSet() throws Exception { - Assert.notNull(getMarshaller(), "marshaller is required"); - Assert.notNull(getUnmarshaller(), "unmarshaller is required"); - } - - @Override - protected void invokeInternal(MessageContext messageContext, MethodEndpoint methodEndpoint) throws Exception { - WebServiceMessage request = messageContext.getRequest(); - Object requestObject = unmarshalRequest(request); - Object responseObject = methodEndpoint.invoke(requestObject); - if (responseObject != null) { - WebServiceMessage response = messageContext.getResponse(); - marshalResponse(responseObject, response); - } - } - - private Object unmarshalRequest(WebServiceMessage request) throws IOException { - Object requestObject = MarshallingUtils.unmarshal(getUnmarshaller(), request); - if (this.logger.isDebugEnabled()) { - this.logger.debug("Unmarshalled payload request to [" + requestObject + "]"); - } - return requestObject; - } - - private void marshalResponse(Object responseObject, WebServiceMessage response) throws IOException { - if (this.logger.isDebugEnabled()) { - this.logger.debug("Marshalling [" + responseObject + "] to response payload"); - } - MarshallingUtils.marshal(getMarshaller(), responseObject, response); - } - - /** - * Supports a method with a single, unmarshallable parameter, and that return - * {@code void} or a marshallable type. - * @see Marshaller#supports(Class) - * @see Unmarshaller#supports(Class) - */ - @Override - protected boolean supportsInternal(MethodEndpoint methodEndpoint) { - Method method = methodEndpoint.getMethod(); - return supportsReturnType(method) && supportsParameters(method); - } - - private boolean supportsReturnType(Method method) { - return (Void.TYPE.equals(method.getReturnType()) || getMarshaller().supports(method.getReturnType())); - } - - private boolean supportsParameters(Method method) { - if (method.getParameterTypes().length != 1) { - return false; - } - else { - return getUnmarshaller().supports(method.getParameterTypes()[0]); - } - } - -} diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/MessageMethodEndpointAdapter.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/MessageMethodEndpointAdapter.java deleted file mode 100644 index 42a26d4c..00000000 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/MessageMethodEndpointAdapter.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2005-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://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, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.ws.server.endpoint.adapter; - -import java.lang.reflect.Method; - -import org.springframework.ws.context.MessageContext; -import org.springframework.ws.server.MessageDispatcher; -import org.springframework.ws.server.endpoint.MethodEndpoint; -import org.springframework.ws.soap.server.SoapMessageDispatcher; - -/** - * Adapter that supports endpoint methods with message contexts. Supports methods with the - * following signature: - * - *
- * void handleMyMessage(MessageContext request);
- *
- * I.e. methods that take a single {@link MessageContext} parameter, and return
- * {@code void}. The method can have any name, as long as it is mapped by an
- * {@link org.springframework.ws.server.EndpointMapping}.
- * - * This adapter is registered by default by the {@link MessageDispatcher} and - * {@link SoapMessageDispatcher}. - * - * @author Arjen Poutsma - * @since 1.0.0 - * @deprecated as of Spring Web Services 2.0, in favor of - * {@link DefaultMethodEndpointAdapter} and - * {@link org.springframework.ws.server.endpoint.adapter.method.MessageContextMethodArgumentResolver - * MessageContextMethodArgumentResolver}. - */ -@Deprecated -public class MessageMethodEndpointAdapter extends AbstractMethodEndpointAdapter { - - @Override - protected boolean supportsInternal(MethodEndpoint methodEndpoint) { - Method method = methodEndpoint.getMethod(); - return Void.TYPE.isAssignableFrom(method.getReturnType()) && method.getParameterTypes().length == 1 - && MessageContext.class.isAssignableFrom(method.getParameterTypes()[0]); - } - - @Override - protected void invokeInternal(MessageContext messageContext, MethodEndpoint methodEndpoint) throws Exception { - methodEndpoint.invoke(messageContext); - } - -} diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/PayloadMethodEndpointAdapter.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/PayloadMethodEndpointAdapter.java deleted file mode 100644 index fee4e354..00000000 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/PayloadMethodEndpointAdapter.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2005-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://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, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.ws.server.endpoint.adapter; - -import java.lang.reflect.Method; - -import javax.xml.transform.Source; - -import org.springframework.ws.WebServiceMessage; -import org.springframework.ws.context.MessageContext; -import org.springframework.ws.server.MessageDispatcher; -import org.springframework.ws.server.endpoint.MethodEndpoint; -import org.springframework.ws.soap.server.SoapMessageDispatcher; - -/** - * Adapter that supports endpoint methods that use marshalling. Supports methods with the - * following signature:
- * void handleMyMessage(Source request); or
- * Source handleMyMessage(Source request); I.e. methods that take a single
- * {@link Source} parameter, and return either {@code void} or a {@link Source}. The
- * method can have any name, as long as it is mapped by an
- * {@link org.springframework.ws.server.EndpointMapping}.
- * - * This adapter is registered by default by the {@link MessageDispatcher} and - * {@link SoapMessageDispatcher}. - * - * @author Arjen Poutsma - * @since 1.0.0 - * @deprecated as of Spring Web Services 2.0, in favor of - * {@link DefaultMethodEndpointAdapter} and - * {@link org.springframework.ws.server.endpoint.adapter.method.SourcePayloadMethodProcessor - * SourcePayloadMethodProcessor}. - */ -@Deprecated -public class PayloadMethodEndpointAdapter extends AbstractMethodEndpointAdapter { - - @Override - protected boolean supportsInternal(MethodEndpoint methodEndpoint) { - Method method = methodEndpoint.getMethod(); - return (Void.TYPE.isAssignableFrom(method.getReturnType()) - || Source.class.isAssignableFrom(method.getReturnType())) && method.getParameterTypes().length == 1 - && Source.class.isAssignableFrom(method.getParameterTypes()[0]); - - } - - @Override - protected void invokeInternal(MessageContext messageContext, MethodEndpoint methodEndpoint) throws Exception { - Source requestSource = messageContext.getRequest().getPayloadSource(); - Object result = methodEndpoint.invoke(requestSource); - if (result != null) { - Source responseSource = (Source) result; - WebServiceMessage response = messageContext.getResponse(); - transform(responseSource, response.getPayloadResult()); - } - } - -} diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/XPathParamAnnotationMethodEndpointAdapter.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/XPathParamAnnotationMethodEndpointAdapter.java deleted file mode 100644 index 7603c750..00000000 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/XPathParamAnnotationMethodEndpointAdapter.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright 2005-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://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, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.ws.server.endpoint.adapter; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; -import java.util.Map; - -import javax.xml.namespace.QName; -import javax.xml.transform.Source; -import javax.xml.transform.TransformerException; -import javax.xml.transform.dom.DOMResult; -import javax.xml.xpath.XPath; -import javax.xml.xpath.XPathConstants; -import javax.xml.xpath.XPathExpressionException; -import javax.xml.xpath.XPathFactory; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -import org.springframework.beans.factory.InitializingBean; -import org.springframework.ws.WebServiceMessage; -import org.springframework.ws.context.MessageContext; -import org.springframework.ws.server.endpoint.MethodEndpoint; -import org.springframework.ws.server.endpoint.annotation.XPathParam; -import org.springframework.xml.namespace.SimpleNamespaceContext; - -/** - * Adapter that supports endpoint methods that use XPath expressions. Supports methods - * with the following signature: - * - *
- * void handleMyMessage(@XPathParam("/root/child/text") String param); or
- *
- * Source handleMyMessage(@XPathParam("/root/child/text") String param1,
- * @XPathParam("/root/child/number") double param2); I.e. methods
- * that return either {@code void} or a {@link Source}, and have parameters annotated with
- * {@link XPathParam} that specify the XPath expression that should be bound to that
- * parameter. The parameter can be of the following types:
- *
- * The contents of the SOAP Fault can be specified by setting the
- * {@link #setAddValidationErrorDetail(boolean) addValidationErrorDetail},
- * {@link #setFaultStringOrReason(String) faultStringOrReason}, or
- * {@link #setDetailElementName(QName) detailElementName} properties.
- *
- * @author Arjen Poutsma
- * @since 1.0.2
- * @deprecated as of Spring Web Services 2.0, in favor of annotated endpoints
- */
-@Deprecated
-public abstract class AbstractFaultCreatingValidatingMarshallingPayloadEndpoint
- extends org.springframework.ws.server.endpoint.AbstractValidatingMarshallingPayloadEndpoint
- implements MessageSourceAware {
-
- /**
- * Default SOAP Fault Detail name used when a global validation error occur on the
- * request.
- * @see #setDetailElementName(javax.xml.namespace.QName)
- */
- public static final QName DEFAULT_DETAIL_ELEMENT_NAME = new QName("http://springframework.org/spring-ws",
- "ValidationError", "spring-ws");
-
- /**
- * Default SOAP Fault string used when a validation errors occur on the request.
- * @see #setFaultStringOrReason(String)
- */
- public static final String DEFAULT_FAULTSTRING_OR_REASON = "Validation error";
-
- private boolean addValidationErrorDetail = true;
-
- private QName detailElementName = DEFAULT_DETAIL_ELEMENT_NAME;
-
- private String faultStringOrReason = DEFAULT_FAULTSTRING_OR_REASON;
-
- private Locale faultStringOrReasonLocale = Locale.ENGLISH;
-
- private MessageSource messageSource;
-
- /**
- * Returns whether a SOAP Fault detail element should be created when a validation
- * error occurs. This detail element will contain the exact validation errors. It is
- * only added when the underlying message is a {@code SoapMessage}. Defaults to
- * {@code true}.
- * @see org.springframework.ws.soap.SoapFault#addFaultDetail()
- */
- public boolean getAddValidationErrorDetail() {
- return this.addValidationErrorDetail;
- }
-
- /**
- * Indicates whether a SOAP Fault detail element should be created when a validation
- * error occurs. This detail element will contain the exact validation errors. It is
- * only added when the underlying message is a {@code SoapMessage}. Defaults to
- * {@code true}.
- * @see org.springframework.ws.soap.SoapFault#addFaultDetail()
- */
- public void setAddValidationErrorDetail(boolean addValidationErrorDetail) {
- this.addValidationErrorDetail = addValidationErrorDetail;
- }
-
- /**
- * Returns the fault detail element name when validation errors occur on the request.
- */
- public QName getDetailElementName() {
- return this.detailElementName;
- }
-
- /**
- * Sets the fault detail element name when validation errors occur on the request.
- * Defaults to {@code DEFAULT_DETAIL_ELEMENT_NAME}.
- * @see #DEFAULT_DETAIL_ELEMENT_NAME
- */
- public void setDetailElementName(QName detailElementName) {
- this.detailElementName = detailElementName;
- }
-
- /**
- * Sets the SOAP {@code faultstring} or {@code Reason} used when validation errors
- * occur on the request.
- */
- public String getFaultStringOrReason() {
- return this.faultStringOrReason;
- }
-
- /**
- * Sets the SOAP {@code faultstring} or {@code Reason} used when validation errors
- * occur on the request. It is only added when the underlying message is a
- * {@code SoapMessage}. Defaults to {@code DEFAULT_FAULTSTRING_OR_REASON}.
- * @see #DEFAULT_FAULTSTRING_OR_REASON
- */
- public void setFaultStringOrReason(String faultStringOrReason) {
- this.faultStringOrReason = faultStringOrReason;
- }
-
- /** Returns the locale for SOAP fault reason and validation message resolution. */
- public Locale getFaultLocale() {
- return this.faultStringOrReasonLocale;
- }
-
- /**
- * Sets the locale for SOAP fault reason and validation messages. It is only added
- * when the underlying message is a {@code SoapMessage}. Defaults to English.
- * @see java.util.Locale#ENGLISH
- */
- public void setFaultStringOrReasonLocale(Locale faultStringOrReasonLocale) {
- this.faultStringOrReasonLocale = faultStringOrReasonLocale;
- }
-
- @Override
- public final void setMessageSource(MessageSource messageSource) {
- this.messageSource = messageSource;
- }
-
- /**
- * This implementation logs all errors, returns {@code false}, and creates a
- * {@link SoapBody#addClientOrSenderFault(String,Locale) client or sender}
- * {@link SoapFault}, adding a {@link SoapFaultDetail} with all errors if the
- * {@code addValidationErrorDetail} property is {@code true}.
- * @param messageContext the message context
- * @param errors the validation errors
- * @return {@code true} to continue processing the request, {@code false} (the
- * default) otherwise
- * @see Errors#getAllErrors()
- */
- @Override
- protected final boolean onValidationErrors(MessageContext messageContext, Object requestObject, Errors errors) {
- for (ObjectError objectError : errors.getAllErrors()) {
- String msg = this.messageSource.getMessage(objectError, getFaultLocale());
- this.logger.warn("Validation error on request object[" + requestObject + "]: " + msg);
- }
- if (messageContext.getResponse() instanceof SoapMessage response) {
- SoapBody body = response.getSoapBody();
- SoapFault fault = body.addClientOrSenderFault(getFaultStringOrReason(), getFaultLocale());
- if (getAddValidationErrorDetail()) {
- SoapFaultDetail detail = fault.addFaultDetail();
- for (ObjectError objectError : errors.getAllErrors()) {
- String msg = this.messageSource.getMessage(objectError, getFaultLocale());
- SoapFaultDetailElement detailElement = detail.addFaultDetailElement(getDetailElementName());
- detailElement.addText(msg);
- }
- }
- }
- return false;
- }
-
-}
diff --git a/spring-ws-core/src/main/resources/org/springframework/ws/server/MessageDispatcher.properties b/spring-ws-core/src/main/resources/org/springframework/ws/server/MessageDispatcher.properties
index 5c2fa95e..6cf1c1fa 100644
--- a/spring-ws-core/src/main/resources/org/springframework/ws/server/MessageDispatcher.properties
+++ b/spring-ws-core/src/main/resources/org/springframework/ws/server/MessageDispatcher.properties
@@ -4,6 +4,4 @@
org.springframework.ws.server.EndpointAdapter=\
org.springframework.ws.server.endpoint.adapter.MessageEndpointAdapter,\
org.springframework.ws.server.endpoint.adapter.PayloadEndpointAdapter,\
-org.springframework.ws.server.endpoint.adapter.MessageMethodEndpointAdapter,\
-org.springframework.ws.server.endpoint.adapter.PayloadMethodEndpointAdapter,\
org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter
diff --git a/spring-ws-core/src/main/resources/org/springframework/ws/soap/server/SoapMessageDispatcher.properties b/spring-ws-core/src/main/resources/org/springframework/ws/soap/server/SoapMessageDispatcher.properties
index b7644da0..95eb6dd1 100644
--- a/spring-ws-core/src/main/resources/org/springframework/ws/soap/server/SoapMessageDispatcher.properties
+++ b/spring-ws-core/src/main/resources/org/springframework/ws/soap/server/SoapMessageDispatcher.properties
@@ -4,8 +4,6 @@
org.springframework.ws.server.EndpointAdapter=\
org.springframework.ws.server.endpoint.adapter.MessageEndpointAdapter,\
org.springframework.ws.server.endpoint.adapter.PayloadEndpointAdapter,\
-org.springframework.ws.server.endpoint.adapter.MessageMethodEndpointAdapter,\
-org.springframework.ws.server.endpoint.adapter.PayloadMethodEndpointAdapter,\
org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter
org.springframework.ws.server.EndpointExceptionResolver=\
diff --git a/spring-ws-core/src/test/java/org/springframework/ws/config/WebServiceNamespaceHandlerTest.java b/spring-ws-core/src/test/java/org/springframework/ws/config/WebServiceNamespaceHandlerTest.java
deleted file mode 100644
index aa5d79e0..00000000
--- a/spring-ws-core/src/test/java/org/springframework/ws/config/WebServiceNamespaceHandlerTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2005-2025 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://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,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.ws.config;
-
-import java.util.Map;
-
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-import org.springframework.ws.server.endpoint.adapter.MarshallingMethodEndpointAdapter;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-@Deprecated
-public class WebServiceNamespaceHandlerTest {
-
- private ApplicationContext applicationContext;
-
- @BeforeEach
- public void setUp() throws Exception {
- this.applicationContext = new ClassPathXmlApplicationContext("webServiceNamespaceHandlerTest.xml", getClass());
- }
-
- @Test
- public void testMarshallingMethods() throws Exception {
-
- Map