Format code with spring-javaformat

This commit configures the build to use spring-javaformat and makes a
first pass to format the code of the project. As part of this, imports
have been optimized, and the license header has been harmonized.

Closes gh-1458
This commit is contained in:
Stéphane Nicoll
2025-02-19 13:32:37 +01:00
parent ac71c3017b
commit fdede99aa0
679 changed files with 10401 additions and 7621 deletions

16
pom.xml
View File

@@ -40,6 +40,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-asciidoctor-backends.version>0.0.5</spring-asciidoctor-backends.version>
<spring-javaformat.version>0.0.43</spring-javaformat.version>
<activemq.version>2.33.0</activemq.version>
<aspectj.version>1.9.22</aspectj.version>
@@ -117,6 +118,21 @@
</modules>
<build>
<plugins>
<plugin>
<groupId>io.spring.javaformat</groupId>
<artifactId>spring-javaformat-maven-plugin</artifactId>
<version>${spring-javaformat.version}</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>validate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -19,8 +19,9 @@ package org.springframework.ws;
import javax.xml.namespace.QName;
/**
* Sub-interface of {@link WebServiceMessage} that can contain special Fault messages. Fault messages (such as
* {@link org.springframework.ws.soap.SoapFault} SOAP Faults) often require different processing rules.
* Sub-interface of {@link WebServiceMessage} that can contain special Fault messages.
* Fault messages (such as {@link org.springframework.ws.soap.SoapFault} SOAP Faults)
* often require different processing rules.
*
* @author Arjen Poutsma
* @see org.springframework.ws.soap.SoapMessage
@@ -30,7 +31,6 @@ public interface FaultAwareWebServiceMessage extends WebServiceMessage {
/**
* Does this message have a fault?
*
* @return {@code true} if the message has a fault.
* @see #getFaultReason()
*/
@@ -43,9 +43,10 @@ public interface FaultAwareWebServiceMessage extends WebServiceMessage {
/**
* Returns the fault reason message.
*
* @return the fault reason message, if any; returns {@code null} when no fault is present.
* @return the fault reason message, if any; returns {@code null} when no fault is
* present.
* @see #hasFault()
*/
String getFaultReason();
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -17,8 +17,8 @@
package org.springframework.ws;
/**
* Exception thrown when a {@link WebServiceMessageFactory} cannot parse the XML passed on to
* {@link WebServiceMessageFactory#createWebServiceMessage(java.io.InputStream)}.
* Exception thrown when a {@link WebServiceMessageFactory} cannot parse the XML passed on
* to {@link WebServiceMessageFactory#createWebServiceMessage(java.io.InputStream)}.
*
* @author Arjen Poutsma
* @since 2.0.4
@@ -29,4 +29,5 @@ public final class InvalidXmlException extends WebServiceException {
public InvalidXmlException(String msg, Throwable ex) {
super(msg, ex);
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -28,4 +28,5 @@ public final class NoEndpointFoundException extends WebServiceException {
public NoEndpointFoundException(WebServiceMessage request) {
super("No endpoint can be found for request [" + request + "]");
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -29,7 +29,6 @@ public abstract class WebServiceException extends NestedRuntimeException {
/**
* Create a new instance of the {@code WebServiceException} class.
*
* @param msg the detail message
*/
public WebServiceException(String msg) {
@@ -38,7 +37,6 @@ public abstract class WebServiceException extends NestedRuntimeException {
/**
* Create a new instance of the {@code WebServiceException} class.
*
* @param msg the detail message
* @param ex the root {@link Throwable exception}
*/

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -37,8 +37,8 @@ public interface WebServiceMessage {
/**
* Returns the contents of the message as a {@link Source}.
* <p>
* Depending on the implementation, this can be retrieved multiple times, or just a single time.
*
* Depending on the implementation, this can be retrieved multiple times, or just a
* single time.
* @return the message contents
*/
Source getPayloadSource();
@@ -48,8 +48,8 @@ public interface WebServiceMessage {
* <p>
* Calling this method removes the current payload.
* <p>
* Implementations that are read-only will throw an {@link UnsupportedOperationException}.
*
* Implementations that are read-only will throw an
* {@link UnsupportedOperationException}.
* @return the message contents
* @throws UnsupportedOperationException if the message is read-only
*/
@@ -58,9 +58,9 @@ public interface WebServiceMessage {
/**
* Writes the entire message to the given output stream.
* <p>
* If the given stream is an instance of {@link org.springframework.ws.transport.TransportOutputStream}, the
* corresponding headers will be written as well.
*
* If the given stream is an instance of
* {@link org.springframework.ws.transport.TransportOutputStream}, the corresponding
* headers will be written as well.
* @param outputStream the stream to write to
* @throws IOException if an I/O exception occurs
*/

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -34,4 +34,5 @@ public abstract class WebServiceMessageException extends WebServiceException {
public WebServiceMessageException(String msg, Throwable ex) {
super(msg, ex);
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -20,8 +20,8 @@ import java.io.IOException;
import java.io.InputStream;
/**
* The {@code WebServiceMessageFactory} serves as a factory for {@link org.springframework.ws.WebServiceMessage
* WebServiceMessages}.
* The {@code WebServiceMessageFactory} serves as a factory for
* {@link org.springframework.ws.WebServiceMessage WebServiceMessages}.
* <p>
* Allows the creation of empty messages, or messages based on {@code InputStream}s.
*
@@ -33,7 +33,6 @@ public interface WebServiceMessageFactory {
/**
* Creates a new, empty {@code WebServiceMessage}.
*
* @return the empty message
*/
WebServiceMessage createWebServiceMessage();
@@ -41,9 +40,9 @@ public interface WebServiceMessageFactory {
/**
* Reads a {@link WebServiceMessage} from the given input stream.
* <p>
* If the given stream is an instance of {@link org.springframework.ws.transport.TransportInputStream
* TransportInputStream}, the headers will be read from the request.
*
* If the given stream is an instance of
* {@link org.springframework.ws.transport.TransportInputStream TransportInputStream},
* the headers will be read from the request.
* @param inputStream the input stream to read the message from
* @return the created message
* @throws InvalidXmlException if the XML read from the input stream is invalid

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -29,7 +29,6 @@ public abstract class WebServiceClientException extends WebServiceException {
/**
* Create a new instance of the {@code WebServiceClientException} class.
*
* @param msg the detail message
*/
public WebServiceClientException(String msg) {
@@ -38,7 +37,6 @@ public abstract class WebServiceClientException extends WebServiceException {
/**
* Create a new instance of the {@code WebServiceClientException} class.
*
* @param msg the detail message
* @param ex the root {@link Throwable exception}
*/

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -37,7 +37,6 @@ public class WebServiceFaultException extends WebServiceClientException {
/**
* Create a new instance of the {@code WebServiceFaultException} class.
*
* @param faultMessage the fault message
*/
public WebServiceFaultException(FaultAwareWebServiceMessage faultMessage) {
@@ -49,4 +48,5 @@ public class WebServiceFaultException extends WebServiceClientException {
public FaultAwareWebServiceMessage getWebServiceMessage() {
return faultMessage;
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -29,7 +29,6 @@ public class WebServiceIOException extends WebServiceClientException {
/**
* Create a new instance of the {@code WebServiceIOException} class.
*
* @param msg the detail message
*/
public WebServiceIOException(String msg) {
@@ -38,7 +37,6 @@ public class WebServiceIOException extends WebServiceClientException {
/**
* Create a new instance of the {@code WebServiceIOException} class.
*
* @param msg the detail message
* @param ex the root {@link IOException}
*/

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -29,7 +29,6 @@ public class WebServiceTransformerException extends WebServiceClientException {
/**
* Create a new instance of the {@code WebServiceTransformerException} class.
*
* @param msg the detail message
*/
public WebServiceTransformerException(String msg) {
@@ -38,7 +37,6 @@ public class WebServiceTransformerException extends WebServiceClientException {
/**
* Create a new instance of the {@code WebServiceTransformerException} class.
*
* @param msg the detail message
* @param ex the root {@link Throwable exception}
*/

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -29,7 +29,6 @@ public class WebServiceTransportException extends WebServiceIOException {
/**
* Create a new instance of the {@code WebServiceTransportException} class.
*
* @param msg the detail message
*/
public WebServiceTransportException(String msg) {
@@ -38,7 +37,6 @@ public class WebServiceTransportException extends WebServiceIOException {
/**
* Create a new instance of the {@code WebServiceTransportException} class.
*
* @param msg the detail message
* @param ex the root {@link TransportException}
*/

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -30,7 +30,6 @@ public interface FaultMessageResolver {
/**
* Try to resolve the given fault message that got received.
*
* @param message the fault message
*/
void resolveFault(WebServiceMessage message) throws IOException;

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -21,7 +21,8 @@ import org.springframework.ws.WebServiceMessage;
import org.springframework.ws.client.WebServiceFaultException;
/**
* Simple fault resolver that simply throws a {@link WebServiceFaultException} when a fault occurs.
* Simple fault resolver that simply throws a {@link WebServiceFaultException} when a
* fault occurs.
*
* @author Arjen Poutsma
* @see WebServiceFaultException
@@ -34,8 +35,10 @@ public class SimpleFaultMessageResolver implements FaultMessageResolver {
public void resolveFault(WebServiceMessage message) {
if (message instanceof FaultAwareWebServiceMessage) {
throw new WebServiceFaultException((FaultAwareWebServiceMessage) message);
} else {
}
else {
throw new WebServiceFaultException("Message has unknown fault: " + message);
}
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -22,15 +22,17 @@ import javax.xml.transform.Source;
import javax.xml.transform.TransformerException;
/**
* Callback interface for extracting a result object from a {@link javax.xml.transform.Source} instance.
* Callback interface for extracting a result object from a
* {@link javax.xml.transform.Source} instance.
* <p>
* Used for output object creation in {@link WebServiceTemplate}. Alternatively, output sources can also be returned to
* client code as-is. In case of a source as execution result, you will almost always want to implement a
* {@code SourceExtractor}, to be able to read the message content in a managed fashion, with the connection still open
* while reading the message.
* Used for output object creation in {@link WebServiceTemplate}. Alternatively, output
* sources can also be returned to client code as-is. In case of a source as execution
* result, you will almost always want to implement a {@code SourceExtractor}, to be able
* to read the message content in a managed fashion, with the connection still open while
* reading the message.
* <p>
* Implementations of this interface perform the actual work of extracting results, but don't need to worry about
* exception handling, or resource handling.
* Implementations of this interface perform the actual work of extracting results, but
* don't need to worry about exception handling, or resource handling.
*
* @author Arjen Poutsma
* @see org.springframework.ws.client.core.WebServiceTemplate
@@ -39,11 +41,11 @@ import javax.xml.transform.TransformerException;
public interface SourceExtractor<T> {
/**
* Process the data in the given {@code Source}, creating a corresponding result object.
*
* Process the data in the given {@code Source}, creating a corresponding result
* object.
* @param source the message payload to extract data from
* @return an arbitrary result object, or {@code null} if none (the extractor will typically be stateful in the latter
* case)
* @return an arbitrary result object, or {@code null} if none (the extractor will
* typically be stateful in the latter case)
* @throws IOException in case of I/O errors
*/
T extractData(Source source) throws IOException, TransformerException;

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -25,8 +25,8 @@ import org.springframework.ws.WebServiceMessage;
/**
* Generic callback interface for code that operates on a {@link WebServiceMessage}.
* <p>
* Implementations can execute any number of operations on the message, such as set the contents of the message, or set
* the {@code SOAPAction} header.
* Implementations can execute any number of operations on the message, such as set the
* contents of the message, or set the {@code SOAPAction} header.
*
* @author Arjen Poutsma
* @since 1.0.0
@@ -35,7 +35,6 @@ public interface WebServiceMessageCallback {
/**
* Execute any number of operations on the supplied {@code message}.
*
* @param message the message
* @throws IOException in case of I/O errors
* @throws TransformerException in case of transformation errors

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -23,15 +23,17 @@ import javax.xml.transform.TransformerException;
import org.springframework.ws.WebServiceMessage;
/**
* Callback interface for extracting a result object from a {@link WebServiceMessage} instance.
* Callback interface for extracting a result object from a {@link WebServiceMessage}
* instance.
* <p>
* Used for output object creation in {@link WebServiceTemplate}. Alternatively, output messages can also be returned to
* client code as-is. In case of a message as execution result, you will almost always want to implement a
* {@code WebServiceMessageExtractor}, to be able to read the message in a managed fashion, with the connection still
* open while reading the message.
* Used for output object creation in {@link WebServiceTemplate}. Alternatively, output
* messages can also be returned to client code as-is. In case of a message as execution
* result, you will almost always want to implement a {@code WebServiceMessageExtractor},
* to be able to read the message in a managed fashion, with the connection still open
* while reading the message.
* <p>
* Implementations of this interface perform the actual work of extracting results, but don't need to worry about
* exception handling, or resource handling.
* Implementations of this interface perform the actual work of extracting results, but
* don't need to worry about exception handling, or resource handling.
*
* @author Arjen Poutsma
* @since 1.0.0
@@ -39,11 +41,11 @@ import org.springframework.ws.WebServiceMessage;
public interface WebServiceMessageExtractor<T> {
/**
* Process the data in the given {@code WebServiceMessage}, creating a corresponding result object.
*
* Process the data in the given {@code WebServiceMessage}, creating a corresponding
* result object.
* @param message the message to extract data from (possibly a {@code SoapMessage})
* @return an arbitrary result object, or {@code null} if none (the extractor will typically be stateful in the latter
* case)
* @return an arbitrary result object, or {@code null} if none (the extractor will
* typically be stateful in the latter case)
* @throws IOException in case of I/O errors
* @throws TransformerException in case of transformation errors
*/

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -23,8 +23,9 @@ import org.springframework.oxm.XmlMappingException;
import org.springframework.ws.client.WebServiceClientException;
/**
* Specifies a basic set of Web service operations. Implemented by {@link WebServiceTemplate}. Not often used directly,
* but a useful option to enhance testability, as it can easily be mocked or stubbed.
* Specifies a basic set of Web service operations. Implemented by
* {@link WebServiceTemplate}. Not often used directly, but a useful option to enhance
* testability, as it can easily be mocked or stubbed.
*
* @author Arjen Poutsma
* @see WebServiceTemplate
@@ -33,55 +34,61 @@ import org.springframework.ws.client.WebServiceClientException;
public interface WebServiceOperations {
/**
* Sends a web service message that can be manipulated with the given callback, reading the result with a
* {@code WebServiceMessageExtractor}.
* Sends a web service message that can be manipulated with the given callback,
* reading the result with a {@code WebServiceMessageExtractor}.
* <p>
* This will only work with a default uri specified!
*
* @param requestCallback the requestCallback to be used for manipulating the request message
* @param requestCallback the requestCallback to be used for manipulating the request
* message
* @param responseExtractor object that will extract results
* @return an arbitrary result object, as returned by the {@code WebServiceMessageExtractor}
* @throws WebServiceClientException if there is a problem sending or receiving the message
* @return an arbitrary result object, as returned by the
* {@code WebServiceMessageExtractor}
* @throws WebServiceClientException if there is a problem sending or receiving the
* message
*/
<T> T sendAndReceive(WebServiceMessageCallback requestCallback, WebServiceMessageExtractor<T> responseExtractor)
throws WebServiceClientException;
/**
* Sends a web service message that can be manipulated with the given callback, reading the result with a
* {@code WebServiceMessageExtractor}.
*
* Sends a web service message that can be manipulated with the given callback,
* reading the result with a {@code WebServiceMessageExtractor}.
* @param uri the URI to send the message to
* @param requestCallback the requestCallback to be used for manipulating the request message
* @param requestCallback the requestCallback to be used for manipulating the request
* message
* @param responseExtractor object that will extract results
* @return an arbitrary result object, as returned by the {@code WebServiceMessageExtractor}
* @throws WebServiceClientException if there is a problem sending or receiving the message
* @return an arbitrary result object, as returned by the
* {@code WebServiceMessageExtractor}
* @throws WebServiceClientException if there is a problem sending or receiving the
* message
*/
<T> T sendAndReceive(String uri, WebServiceMessageCallback requestCallback,
WebServiceMessageExtractor<T> responseExtractor) throws WebServiceClientException;
/**
* Sends a web service message that can be manipulated with the given request callback, handling the response with a
* response callback.
* Sends a web service message that can be manipulated with the given request
* callback, handling the response with a response callback.
* <p>
* This will only work with a default uri specified!
*
* @param requestCallback the callback to be used for manipulating the request message
* @param responseCallback the callback to be used for manipulating the response message
* @param responseCallback the callback to be used for manipulating the response
* message
* @return {@code true} if a response was received; {@code false} otherwise
* @throws WebServiceClientException if there is a problem sending or receiving the message
* @throws WebServiceClientException if there is a problem sending or receiving the
* message
*/
boolean sendAndReceive(WebServiceMessageCallback requestCallback, WebServiceMessageCallback responseCallback)
throws WebServiceClientException;
/**
* Sends a web service message that can be manipulated with the given request callback, handling the response with a
* response callback.
*
* Sends a web service message that can be manipulated with the given request
* callback, handling the response with a response callback.
* @param uri the URI to send the message to
* @param requestCallback the callback to be used for manipulating the request message
* @param responseCallback the callback to be used for manipulating the response message
* @param responseCallback the callback to be used for manipulating the response
* message
* @return {@code true} if a response was received; {@code false} otherwise
* @throws WebServiceClientException if there is a problem sending or receiving the message
* @throws WebServiceClientException if there is a problem sending or receiving the
* message
*/
boolean sendAndReceive(String uri, WebServiceMessageCallback requestCallback,
WebServiceMessageCallback responseCallback) throws WebServiceClientException;
@@ -91,46 +98,53 @@ public interface WebServiceOperations {
// -----------------------------------------------------------------------------------------------------------------
/**
* Sends a web service message that contains the given payload, marshalled by the configured {@code Marshaller}.
* Returns the unmarshalled payload of the response message, if any.
* Sends a web service message that contains the given payload, marshalled by the
* configured {@code Marshaller}. Returns the unmarshalled payload of the response
* message, if any.
* <p>
* This will only work with a default uri specified!
*
* @param requestPayload the object to marshal into the request message payload
* @return the unmarshalled payload of the response message, or {@code null} if no response is given
* @return the unmarshalled payload of the response message, or {@code null} if no
* response is given
* @throws XmlMappingException if there is a problem marshalling or unmarshalling
* @throws WebServiceClientException if there is a problem sending or receiving the message
* @throws WebServiceClientException if there is a problem sending or receiving the
* message
* @see WebServiceTemplate#setMarshaller(org.springframework.oxm.Marshaller)
* @see WebServiceTemplate#setUnmarshaller(org.springframework.oxm.Unmarshaller)
*/
Object marshalSendAndReceive(Object requestPayload) throws XmlMappingException, WebServiceClientException;
/**
* Sends a web service message that contains the given payload, marshalled by the configured {@code Marshaller}.
* Returns the unmarshalled payload of the response message, if any.
*
* Sends a web service message that contains the given payload, marshalled by the
* configured {@code Marshaller}. Returns the unmarshalled payload of the response
* message, if any.
* @param uri the URI to send the message to
* @param requestPayload the object to marshal into the request message payload
* @return the unmarshalled payload of the response message, or {@code null} if no response is given
* @return the unmarshalled payload of the response message, or {@code null} if no
* response is given
* @throws XmlMappingException if there is a problem marshalling or unmarshalling
* @throws WebServiceClientException if there is a problem sending or receiving the message
* @throws WebServiceClientException if there is a problem sending or receiving the
* message
* @see WebServiceTemplate#setMarshaller(org.springframework.oxm.Marshaller)
* @see WebServiceTemplate#setUnmarshaller(org.springframework.oxm.Unmarshaller)
*/
Object marshalSendAndReceive(String uri, Object requestPayload) throws XmlMappingException, WebServiceClientException;
Object marshalSendAndReceive(String uri, Object requestPayload)
throws XmlMappingException, WebServiceClientException;
/**
* Sends a web service message that contains the given payload, marshalled by the configured {@code Marshaller}.
* Returns the unmarshalled payload of the response message, if any. The given callback allows changing of the request
* message after the payload has been marshalled to it.
* Sends a web service message that contains the given payload, marshalled by the
* configured {@code Marshaller}. Returns the unmarshalled payload of the response
* message, if any. The given callback allows changing of the request message after
* the payload has been marshalled to it.
* <p>
* This will only work with a default uri specified!
*
* @param requestPayload the object to marshal into the request message payload
* @param requestCallback callback to change message, can be {@code null}
* @return the unmarshalled payload of the response message, or {@code null} if no response is given
* @return the unmarshalled payload of the response message, or {@code null} if no
* response is given
* @throws XmlMappingException if there is a problem marshalling or unmarshalling
* @throws WebServiceClientException if there is a problem sending or receiving the message
* @throws WebServiceClientException if there is a problem sending or receiving the
* message
* @see WebServiceTemplate#setMarshaller(org.springframework.oxm.Marshaller)
* @see WebServiceTemplate#setUnmarshaller(org.springframework.oxm.Unmarshaller)
*/
@@ -138,16 +152,18 @@ public interface WebServiceOperations {
throws XmlMappingException, WebServiceClientException;
/**
* Sends a web service message that contains the given payload, marshalled by the configured {@code Marshaller}.
* Returns the unmarshalled payload of the response message, if any. The given callback allows changing of the request
* message after the payload has been marshalled to it.
*
* Sends a web service message that contains the given payload, marshalled by the
* configured {@code Marshaller}. Returns the unmarshalled payload of the response
* message, if any. The given callback allows changing of the request message after
* the payload has been marshalled to it.
* @param uri the URI to send the message to
* @param requestPayload the object to marshal into the request message payload
* @param requestCallback callback to change message, can be {@code null}
* @return the unmarshalled payload of the response message, or {@code null} if no response is given
* @return the unmarshalled payload of the response message, or {@code null} if no
* response is given
* @throws XmlMappingException if there is a problem marshalling or unmarshalling
* @throws WebServiceClientException if there is a problem sending or receiving the message
* @throws WebServiceClientException if there is a problem sending or receiving the
* message
* @see WebServiceTemplate#setMarshaller(org.springframework.oxm.Marshaller)
* @see WebServiceTemplate#setUnmarshaller(org.springframework.oxm.Unmarshaller)
*/
@@ -159,57 +175,63 @@ public interface WebServiceOperations {
// -----------------------------------------------------------------------------------------------------------------
/**
* Sends a web service message that contains the given payload, reading the result with a {@code SourceExtractor}.
* Sends a web service message that contains the given payload, reading the result
* with a {@code SourceExtractor}.
* <p>
* This will only work with a default uri specified!
*
* @param requestPayload the payload of the request message
* @param responseExtractor object that will extract results
* @return an arbitrary result object, as returned by the {@code SourceExtractor}
* @throws WebServiceClientException if there is a problem sending or receiving the message
* @throws WebServiceClientException if there is a problem sending or receiving the
* message
*/
<T> T sendSourceAndReceive(Source requestPayload, SourceExtractor<T> responseExtractor)
throws WebServiceClientException;
/**
* Sends a web service message that contains the given payload, reading the result with a {@code SourceExtractor}.
*
* Sends a web service message that contains the given payload, reading the result
* with a {@code SourceExtractor}.
* @param uri the URI to send the message to
* @param requestPayload the payload of the request message
* @param responseExtractor object that will extract results
* @return an arbitrary result object, as returned by the {@code SourceExtractor}
* @throws WebServiceClientException if there is a problem sending or receiving the message
* @throws WebServiceClientException if there is a problem sending or receiving the
* message
*/
<T> T sendSourceAndReceive(String uri, Source requestPayload, SourceExtractor<T> responseExtractor)
throws WebServiceClientException;
/**
* Sends a web service message that contains the given payload, reading the result with a {@code SourceExtractor}.
* Sends a web service message that contains the given payload, reading the result
* with a {@code SourceExtractor}.
* <p>
* The given callback allows changing of the request message after the payload has been written to it.
* The given callback allows changing of the request message after the payload has
* been written to it.
* <p>
* This will only work with a default uri specified!
*
* @param requestPayload the payload of the request message
* @param requestCallback callback to change message, can be {@code null}
* @param responseExtractor object that will extract results
* @return an arbitrary result object, as returned by the {@code SourceExtractor}
* @throws WebServiceClientException if there is a problem sending or receiving the message
* @throws WebServiceClientException if there is a problem sending or receiving the
* message
*/
<T> T sendSourceAndReceive(Source requestPayload, WebServiceMessageCallback requestCallback,
SourceExtractor<T> responseExtractor) throws WebServiceClientException;
/**
* Sends a web service message that contains the given payload, reading the result with a {@code SourceExtractor}.
* Sends a web service message that contains the given payload, reading the result
* with a {@code SourceExtractor}.
* <p>
* The given callback allows changing of the request message after the payload has been written to it.
*
* The given callback allows changing of the request message after the payload has
* been written to it.
* @param uri the URI to send the message to
* @param requestPayload the payload of the request message
* @param requestCallback callback to change message, can be {@code null}
* @param responseExtractor object that will extract results
* @return an arbitrary result object, as returned by the {@code SourceExtractor}
* @throws WebServiceClientException if there is a problem sending or receiving the message
* @throws WebServiceClientException if there is a problem sending or receiving the
* message
*/
<T> T sendSourceAndReceive(String uri, Source requestPayload, WebServiceMessageCallback requestCallback,
SourceExtractor<T> responseExtractor) throws WebServiceClientException;
@@ -219,60 +241,62 @@ public interface WebServiceOperations {
// -----------------------------------------------------------------------------------------------------------------
/**
* Sends a web service message that contains the given payload. Writes the response, if any, to the given
* {@code Result}.
* Sends a web service message that contains the given payload. Writes the response,
* if any, to the given {@code Result}.
* <p>
* This will only work with a default uri specified!
*
* @param requestPayload the payload of the request message
* @param responseResult the result to write the response payload to
* @return {@code true} if a response was received; {@code false} otherwise
* @throws WebServiceClientException if there is a problem sending or receiving the message
* @throws WebServiceClientException if there is a problem sending or receiving the
* message
*/
boolean sendSourceAndReceiveToResult(Source requestPayload, Result responseResult) throws WebServiceClientException;
/**
* Sends a web service message that contains the given payload. Writes the response, if any, to the given
* {@code Result}.
*
* Sends a web service message that contains the given payload. Writes the response,
* if any, to the given {@code Result}.
* @param uri the URI to send the message to
* @param requestPayload the payload of the request message
* @param responseResult the result to write the response payload to
* @return {@code true} if a response was received; {@code false} otherwise
* @throws WebServiceClientException if there is a problem sending or receiving the message
* @throws WebServiceClientException if there is a problem sending or receiving the
* message
*/
boolean sendSourceAndReceiveToResult(String uri, Source requestPayload, Result responseResult)
throws WebServiceClientException;
/**
* Sends a web service message that contains the given payload. Writes the response, if any, to the given
* {@code Result}.
* Sends a web service message that contains the given payload. Writes the response,
* if any, to the given {@code Result}.
* <p>
* The given callback allows changing of the request message after the payload has been written to it.
* The given callback allows changing of the request message after the payload has
* been written to it.
* <p>
* This will only work with a default uri specified!
*
* @param requestPayload the payload of the request message
* @param requestCallback callback to change message, can be {@code null}
* @param responseResult the result to write the response payload to
* @return {@code true} if a response was received; {@code false} otherwise
* @throws WebServiceClientException if there is a problem sending or receiving the message
* @throws WebServiceClientException if there is a problem sending or receiving the
* message
*/
boolean sendSourceAndReceiveToResult(Source requestPayload, WebServiceMessageCallback requestCallback,
Result responseResult) throws WebServiceClientException;
/**
* Sends a web service message that contains the given payload. Writes the response, if any, to the given
* {@code Result}.
* Sends a web service message that contains the given payload. Writes the response,
* if any, to the given {@code Result}.
* <p>
* The given callback allows changing of the request message after the payload has been written to it.
*
* The given callback allows changing of the request message after the payload has
* been written to it.
* @param uri the URI to send the message to
* @param requestPayload the payload of the request message
* @param requestCallback callback to change message, can be {@code null}
* @param responseResult the result to write the response payload to
* @return {@code true} if a response was received; {@code false} otherwise
* @throws WebServiceClientException if there is a problem sending or receiving the message
* @throws WebServiceClientException if there is a problem sending or receiving the
* message
*/
boolean sendSourceAndReceiveToResult(String uri, Source requestPayload, WebServiceMessageCallback requestCallback,
Result responseResult) throws WebServiceClientException;

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -22,10 +22,15 @@ import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.util.List;
import javax.xml.transform.*;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.BeanInitializationException;
import org.springframework.oxm.Marshaller;
import org.springframework.oxm.Unmarshaller;
@@ -57,47 +62,57 @@ import org.springframework.ws.transport.http.HttpUrlConnectionMessageSender;
import org.springframework.ws.transport.support.TransportUtils;
/**
* <strong>The central class for client-side Web services.</strong> It provides a message-driven approach to sending and
* receiving {@link WebServiceMessage} instances.
* <strong>The central class for client-side Web services.</strong> It provides a
* message-driven approach to sending and receiving {@link WebServiceMessage} instances.
* <p>
* Code using this class need only implement callback interfaces, provide {@link Source} objects to read data from, or
* use the pluggable {@link Marshaller} support. For invoking the {@link #marshalSendAndReceive marshalling methods},
* the {@link #setMarshaller(Marshaller) marshaller} and {@link #setUnmarshaller(Unmarshaller) unmarshaller} properties
* must be set.
* Code using this class need only implement callback interfaces, provide {@link Source}
* objects to read data from, or use the pluggable {@link Marshaller} support. For
* invoking the {@link #marshalSendAndReceive marshalling methods}, the
* {@link #setMarshaller(Marshaller) marshaller} and {@link #setUnmarshaller(Unmarshaller)
* unmarshaller} properties must be set.
* <p>
* This template uses a {@link SoapFaultMessageResolver} to handle fault response messages. Another
* {@link FaultMessageResolver} can be defined with with {@link #setFaultMessageResolver(FaultMessageResolver)
* faultMessageResolver} property. If this property is set to {@code null}, no fault resolving is performed.
* This template uses a {@link SoapFaultMessageResolver} to handle fault response
* messages. Another {@link FaultMessageResolver} can be defined with with
* {@link #setFaultMessageResolver(FaultMessageResolver) faultMessageResolver} property.
* If this property is set to {@code null}, no fault resolving is performed.
* <p>
* This template uses the following algorithm for sending and receiving.
* <ol>
* <li>Call {@link #createConnection(URI) createConnection()}.</li>
* <li>Call {@link WebServiceMessageFactory#createWebServiceMessage() createWebServiceMessage()} on the registered
* message factory to create a request message.</li>
* <li>Invoke {@link WebServiceMessageCallback#doWithMessage(WebServiceMessage) doWithMessage()} on the request
* callback, if any. This step stores content in the request message, based on {@code Source}, marshalling, etc.</li>
* <li>Invoke {@link ClientInterceptor#handleRequest(MessageContext) handleRequest()} on the registered
* {@link #setInterceptors(ClientInterceptor[]) interceptors}. Interceptors are executed in order. If any of the
* interceptors creates a response message in the message context, skip to step 7.</li>
* <li>Call {@link WebServiceConnection#send(WebServiceMessage) send()} on the connection.</li>
* <li>Call {@link #hasError(WebServiceConnection,WebServiceMessage) hasError()} to check if the connection has an
* error. For an HTTP transport, a status code other than {@code 2xx} indicates an error. However, since a status code
* of 500 can also indicate a SOAP fault, the template verifies whether the error is not a fault.</li>
* <li>Call {@link WebServiceMessageFactory#createWebServiceMessage()
* createWebServiceMessage()} on the registered message factory to create a request
* message.</li>
* <li>Invoke {@link WebServiceMessageCallback#doWithMessage(WebServiceMessage)
* doWithMessage()} on the request callback, if any. This step stores content in the
* request message, based on {@code Source}, marshalling, etc.</li>
* <li>Invoke {@link ClientInterceptor#handleRequest(MessageContext) handleRequest()} on
* the registered {@link #setInterceptors(ClientInterceptor[]) interceptors}. Interceptors
* are executed in order. If any of the interceptors creates a response message in the
* message context, skip to step 7.</li>
* <li>Call {@link WebServiceConnection#send(WebServiceMessage) send()} on the
* connection.</li>
* <li>Call {@link #hasError(WebServiceConnection,WebServiceMessage) hasError()} to check
* if the connection has an error. For an HTTP transport, a status code other than
* {@code 2xx} indicates an error. However, since a status code of 500 can also indicate a
* SOAP fault, the template verifies whether the error is not a fault.</li>
* <ul>
* <li>If the connection has an error, call the {@link #handleError handleError()} method, which by default throws a
* {@link WebServiceTransportException}.</li>
* <li>If the connection has an error, call the {@link #handleError handleError()} method,
* which by default throws a {@link WebServiceTransportException}.</li>
* <li>If the connection has no error, continue with the next step.</li>
* </ul>
* <li>Invoke {@link WebServiceConnection#receive(WebServiceMessageFactory) receive} on the connection to read the
* response message, if any.</li>
* <li>Invoke {@link WebServiceConnection#receive(WebServiceMessageFactory) receive} on
* the connection to read the response message, if any.</li>
* <ul>
* <li>If no response was received, return {@code null} or {@code false}</li>
* <li>Call {@link #hasFault(WebServiceConnection,WebServiceMessage) hasFault()} to determine whether the response has a
* fault. If it has, call {@link ClientInterceptor#handleFault(MessageContext)} and the {@link #handleFault
* <li>Call {@link #hasFault(WebServiceConnection,WebServiceMessage) hasFault()} to
* determine whether the response has a fault. If it has, call
* {@link ClientInterceptor#handleFault(MessageContext)} and the {@link #handleFault
* handleFault()} method.</li>
* <li>Otherwise, invoke {@link ClientInterceptor#handleResponse(MessageContext)} and
* {@link WebServiceMessageExtractor#extractData(WebServiceMessage) extractData()} on the response extractor, or
* {@link WebServiceMessageCallback#doWithMessage(WebServiceMessage) doWithMessage} on the response callback.</li>
* {@link WebServiceMessageExtractor#extractData(WebServiceMessage) extractData()} on the
* response extractor, or
* {@link WebServiceMessageCallback#doWithMessage(WebServiceMessage) doWithMessage} on the
* response callback.</li>
* </ul>
* <li>Call to {@link WebServiceConnection#close() close} on the connection.</li>
* </ol>
@@ -112,11 +127,11 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService
/** Additional logger to use for sent message tracing. */
protected static final Log sentMessageTracingLogger = LogFactory
.getLog(WebServiceTemplate.MESSAGE_TRACING_LOG_CATEGORY + ".sent");
.getLog(WebServiceTemplate.MESSAGE_TRACING_LOG_CATEGORY + ".sent");
/** Additional logger to use for received message tracing. */
protected static final Log receivedMessageTracingLogger = LogFactory
.getLog(WebServiceTemplate.MESSAGE_TRACING_LOG_CATEGORY + ".received");
.getLog(WebServiceTemplate.MESSAGE_TRACING_LOG_CATEGORY + ".received");
private Marshaller marshaller;
@@ -139,7 +154,6 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService
/**
* Creates a new {@code WebServiceTemplate} based on the given message factory.
*
* @param messageFactory the message factory to use
*/
public WebServiceTemplate(WebServiceMessageFactory messageFactory) {
@@ -148,15 +162,15 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService
}
/**
* Creates a new {@code WebServiceTemplate} 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.
* Creates a new {@code WebServiceTemplate} 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.
* <p>
* Note that all {@link Marshaller} implementations in Spring also implement the {@link Unmarshaller} interface, so
* that you can safely use this constructor.
*
* 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
* @throws IllegalArgumentException when {@code marshaller} does not implement the
* {@link Unmarshaller} interface
* @since 2.0.3
*/
public WebServiceTemplate(Marshaller marshaller) {
@@ -165,7 +179,8 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService
throw new IllegalArgumentException("Marshaller [" + marshaller + "] does not implement the Unmarshaller "
+ "interface. Please set an Unmarshaller explicitly by using the "
+ "WebServiceTemplate(Marshaller, Unmarshaller) constructor.");
} else {
}
else {
this.setMarshaller(marshaller);
this.setUnmarshaller((Unmarshaller) marshaller);
}
@@ -173,8 +188,8 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService
}
/**
* Creates a new {@code MarshallingMethodEndpointAdapter} with the given marshaller and unmarshaller.
*
* Creates a new {@code MarshallingMethodEndpointAdapter} with the given marshaller
* and unmarshaller.
* @param marshaller the marshaller to use
* @param unmarshaller the unmarshaller to use
* @since 2.0.3
@@ -187,12 +202,15 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService
initDefaultStrategies();
}
/** Returns the default URI to be used on operations that do not have a URI parameter. */
/**
* Returns the default URI to be used on operations that do not have a URI parameter.
*/
public String getDefaultUri() {
if (destinationProvider != null) {
URI uri = destinationProvider.getDestination();
return uri != null ? uri.toString() : null;
} else {
}
else {
return null;
}
}
@@ -200,8 +218,8 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService
/**
* Set the default URI to be used on operations that do not have a URI parameter.
* <p>
* Typically, either this property is set, or {@link #setDestinationProvider(DestinationProvider)}, but not both.
*
* Typically, either this property is set, or
* {@link #setDestinationProvider(DestinationProvider)}, but not both.
* @see #marshalSendAndReceive(Object)
* @see #marshalSendAndReceive(Object,WebServiceMessageCallback)
* @see #sendSourceAndReceiveToResult(Source,Result)
@@ -219,16 +237,20 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService
};
}
/** Returns the destination provider used on operations that do not have a URI parameter. */
/**
* Returns the destination provider used on operations that do not have a URI
* parameter.
*/
public DestinationProvider getDestinationProvider() {
return destinationProvider;
}
/**
* Set the destination provider URI to be used on operations that do not have a URI parameter.
* Set the destination provider URI to be used on operations that do not have a URI
* parameter.
* <p>
* Typically, either this property is set, or {@link #setDefaultUri(String)}, but not both.
*
* Typically, either this property is set, or {@link #setDefaultUri(String)}, but not
* both.
* @see #marshalSendAndReceive(Object)
* @see #marshalSendAndReceive(Object,WebServiceMessageCallback)
* @see #sendSourceAndReceiveToResult(Source,Result)
@@ -268,52 +290,60 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService
/**
* Sets the fault resolver for this template. Default is the
* {@link org.springframework.ws.soap.client.core.SoapFaultMessageResolver SoapFaultMessageResolver}, but may be set
* to {@code null} to disable fault handling.
* {@link org.springframework.ws.soap.client.core.SoapFaultMessageResolver
* SoapFaultMessageResolver}, but may be set to {@code null} to disable fault
* handling.
*/
public void setFaultMessageResolver(FaultMessageResolver faultMessageResolver) {
this.faultMessageResolver = faultMessageResolver;
}
/**
* Indicates whether the {@linkplain WebServiceConnection#hasError() connection} should be checked for error
* indicators ({@code true}), or whether these should be ignored ({@code false}). The default is {@code true}.
* Indicates whether the {@linkplain WebServiceConnection#hasError() connection}
* should be checked for error indicators ({@code true}), or whether these should be
* ignored ({@code false}). The default is {@code true}.
* <p>
* When using an HTTP transport, this property defines whether to check the HTTP response status code is in the 2xx
* Successful range. Both the SOAP specification and the WS-I Basic Profile define that a Web service must return a
* "200 OK" or "202 Accepted" HTTP status code for a normal response. Setting this property to {@code false} allows
* this template to deal with non-conforming services.
*
* When using an HTTP transport, this property defines whether to check the HTTP
* response status code is in the 2xx Successful range. Both the SOAP specification
* and the WS-I Basic Profile define that a Web service must return a "200 OK" or "202
* Accepted" HTTP status code for a normal response. Setting this property to
* {@code false} allows this template to deal with non-conforming services.
* @see #hasError(WebServiceConnection, WebServiceMessage)
* @see <a href="http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383529">SOAP 1.1 specification</a>
* @see <a href="http://www.ws-i.org/Profiles/BasicProfile-1.1.html#HTTP_Success_Status_Codes">WS-I Basic Profile</a>
* @see <a href="http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383529">SOAP 1.1
* specification</a>
* @see <a href=
* "http://www.ws-i.org/Profiles/BasicProfile-1.1.html#HTTP_Success_Status_Codes">WS-I
* Basic Profile</a>
*/
public void setCheckConnectionForError(boolean checkConnectionForError) {
this.checkConnectionForError = checkConnectionForError;
}
/**
* Indicates whether the {@linkplain FaultAwareWebServiceConnection#hasFault() connection} should be checked for fault
* indicators ({@code true}), or whether we should rely on the {@link FaultAwareWebServiceMessage#hasFault() message}
* only ({@code false}). The default is {@code true}.
* Indicates whether the {@linkplain FaultAwareWebServiceConnection#hasFault()
* connection} should be checked for fault indicators ({@code true}), or whether we
* should rely on the {@link FaultAwareWebServiceMessage#hasFault() message} only
* ({@code false}). The default is {@code true}.
* <p>
* When using an HTTP transport, this property defines whether to check the HTTP response status code for fault
* indicators. Both the SOAP specification and the WS-I Basic Profile define that a Web service must return a "500
* Internal Server Error" HTTP status code if the response envelope is a Fault. Setting this property to {@code false}
* allows this template to deal with non-conforming services.
*
* When using an HTTP transport, this property defines whether to check the HTTP
* response status code for fault indicators. Both the SOAP specification and the WS-I
* Basic Profile define that a Web service must return a "500 Internal Server Error"
* HTTP status code if the response envelope is a Fault. Setting this property to
* {@code false} allows this template to deal with non-conforming services.
* @see #hasFault(WebServiceConnection,WebServiceMessage)
* @see <a href="http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383529">SOAP 1.1 specification</a>
* @see <a href="http://www.ws-i.org/Profiles/BasicProfile-1.1.html#HTTP_Server_Error_Status_Codes">WS-I Basic
* Profile</a>
* @see <a href="http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383529">SOAP 1.1
* specification</a>
* @see <a href=
* "http://www.ws-i.org/Profiles/BasicProfile-1.1.html#HTTP_Server_Error_Status_Codes">WS-I
* Basic Profile</a>
*/
public void setCheckConnectionForFault(boolean checkConnectionForFault) {
this.checkConnectionForFault = checkConnectionForFault;
}
/**
* Returns the client interceptors to apply to all web service invocations made by this template.
*
* Returns the client interceptors to apply to all web service invocations made by
* this template.
* @return array of endpoint interceptors, or {@code null} if none
*/
public ClientInterceptor[] getInterceptors() {
@@ -321,8 +351,8 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService
}
/**
* Sets the client interceptors to apply to all web service invocations made by this template.
*
* Sets the client interceptors to apply to all web service invocations made by this
* template.
* @param interceptors array of endpoint interceptors, or {@code null} if none
*/
public final void setInterceptors(ClientInterceptor[] interceptors) {
@@ -330,9 +360,10 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService
}
/**
* Initialize the default implementations for the template's strategies: {@link SoapFaultMessageResolver},
* {@link org.springframework.ws.soap.saaj.SaajSoapMessageFactory}, and {@link HttpUrlConnectionMessageSender}.
*
* Initialize the default implementations for the template's strategies:
* {@link SoapFaultMessageResolver},
* {@link org.springframework.ws.soap.saaj.SaajSoapMessageFactory}, and
* {@link HttpUrlConnectionMessageSender}.
* @throws BeanInitializationException in case of initalization errors
* @see #setFaultMessageResolver(FaultMessageResolver)
* @see #setMessageFactory(WebServiceMessageFactory)
@@ -394,7 +425,8 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService
if (requestPayload != null) {
Marshaller marshaller = getMarshaller();
if (marshaller == null) {
throw new IllegalStateException("No marshaller registered. Check configuration of WebServiceTemplate.");
throw new IllegalStateException(
"No marshaller registered. Check configuration of WebServiceTemplate.");
}
MarshallingUtils.marshal(marshaller, requestPayload, request);
if (requestCallback != null) {
@@ -407,7 +439,8 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService
public Object extractData(WebServiceMessage response) throws IOException {
Unmarshaller unmarshaller = getUnmarshaller();
if (unmarshaller == null) {
throw new IllegalStateException("No unmarshaller registered. Check configuration of WebServiceTemplate.");
throw new IllegalStateException(
"No unmarshaller registered. Check configuration of WebServiceTemplate.");
}
return MarshallingUtils.unmarshal(unmarshaller, response);
}
@@ -450,7 +483,8 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService
}
});
return retVal != null && retVal;
} catch (TransformerConfigurationException ex) {
}
catch (TransformerConfigurationException ex) {
throw new WebServiceTransformerException("Could not create transformer", ex);
}
}
@@ -482,7 +516,8 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService
try {
return doSendAndReceive(uri, createTransformer(), requestPayload, requestCallback, responseExtractor);
} catch (TransformerConfigurationException ex) {
}
catch (TransformerConfigurationException ex) {
throw new WebServiceTransformerException("Could not create transformer", ex);
}
}
@@ -505,7 +540,8 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService
//
@Override
public boolean sendAndReceive(WebServiceMessageCallback requestCallback, WebServiceMessageCallback responseCallback) {
public boolean sendAndReceive(WebServiceMessageCallback requestCallback,
WebServiceMessageCallback responseCallback) {
return sendAndReceive(getDefaultUri(), requestCallback, responseCallback);
}
@@ -537,32 +573,39 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService
MessageContext messageContext = new DefaultMessageContext(getMessageFactory());
return doSendAndReceive(messageContext, connection, requestCallback, responseExtractor);
} catch (TransportException ex) {
}
catch (TransportException ex) {
throw new WebServiceTransportException("Could not use transport: " + ex.getMessage(), ex);
} catch (IOException ex) {
}
catch (IOException ex) {
throw new WebServiceIOException("I/O error: " + ex.getMessage(), ex);
} finally {
}
finally {
TransportUtils.closeConnection(connection);
TransportContextHolder.setTransportContext(previousTransportContext);
}
}
/**
* Sends and receives a {@link MessageContext}. Sends the {@link MessageContext#getRequest() request message}, and
* received to the {@link MessageContext#getResponse() repsonse message}. Invocates the defined
* Sends and receives a {@link MessageContext}. Sends the
* {@link MessageContext#getRequest() request message}, and received to the
* {@link MessageContext#getResponse() repsonse message}. Invocates the defined
* {@link #setInterceptors(ClientInterceptor[]) interceptors} as part of the process.
*
* @param messageContext the message context
* @param connection the connection to use
* @param requestCallback the requestCallback to be used for manipulating the request message
* @param requestCallback the requestCallback to be used for manipulating the request
* message
* @param responseExtractor object that will extract results
* @return an arbitrary result object, as returned by the {@code WebServiceMessageExtractor}
* @throws WebServiceClientException if there is a problem sending or receiving the message
* @return an arbitrary result object, as returned by the
* {@code WebServiceMessageExtractor}
* @throws WebServiceClientException if there is a problem sending or receiving the
* message
* @throws IOException in case of I/O errors
*/
@SuppressWarnings("unchecked")
protected <T> T doSendAndReceive(MessageContext messageContext, WebServiceConnection connection,
WebServiceMessageCallback requestCallback, WebServiceMessageExtractor<T> responseExtractor) throws IOException {
WebServiceMessageCallback requestCallback, WebServiceMessageExtractor<T> responseExtractor)
throws IOException {
int interceptorIndex = -1;
try {
if (requestCallback != null) {
@@ -596,19 +639,23 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService
triggerHandleResponse(interceptorIndex, messageContext);
triggerAfterCompletion(interceptorIndex, messageContext, null);
return responseExtractor.extractData(messageContext.getResponse());
} else {
}
else {
triggerHandleFault(interceptorIndex, messageContext);
triggerAfterCompletion(interceptorIndex, messageContext, null);
return (T) handleFault(connection, messageContext);
}
} else {
}
else {
triggerAfterCompletion(interceptorIndex, messageContext, null);
return null;
}
} catch (TransformerException ex) {
}
catch (TransformerException ex) {
triggerAfterCompletion(interceptorIndex, messageContext, ex);
throw new WebServiceTransformerException("Transformation error: " + ex.getMessage(), ex);
} catch (RuntimeException | IOException ex) {
}
catch (RuntimeException | IOException ex) {
// Trigger after-completion for thrown exception.
triggerAfterCompletion(interceptorIndex, messageContext, ex);
throw ex;
@@ -621,7 +668,8 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService
ByteArrayOutputStream os = new ByteArrayOutputStream();
request.writeTo(os);
sentMessageTracingLogger.trace("Sent request [" + os.toString(StandardCharsets.UTF_8) + "]");
} else if (sentMessageTracingLogger.isDebugEnabled()) {
}
else if (sentMessageTracingLogger.isDebugEnabled()) {
sentMessageTracingLogger.debug("Sent request [" + request + "]");
}
connection.send(request);
@@ -630,9 +678,9 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService
/**
* Determines whether the given connection or message context has an error.
* <p>
* This implementation checks the {@link WebServiceConnection#hasError() connection} first. If it indicates an error,
* it makes sure that it is not a {@link FaultAwareWebServiceConnection#hasFault() fault}.
*
* This implementation checks the {@link WebServiceConnection#hasError() connection}
* first. If it indicates an error, it makes sure that it is not a
* {@link FaultAwareWebServiceConnection#hasFault() fault}.
* @param connection the connection (possibly a {@link FaultAwareWebServiceConnection}
* @param request the response message (possibly a {@link FaultAwareWebServiceMessage}
* @return {@code true} if the connection has an error; {@code false} otherwise
@@ -644,7 +692,8 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService
if (checkConnectionForFault && connection instanceof FaultAwareWebServiceConnection) {
FaultAwareWebServiceConnection faultConnection = (FaultAwareWebServiceConnection) connection;
return !(faultConnection.hasFault() && request instanceof FaultAwareWebServiceMessage);
} else {
}
else {
return true;
}
}
@@ -652,12 +701,13 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService
}
/**
* Handles an error on the given connection. The default implementation throws a {@link WebServiceTransportException}.
*
* Handles an error on the given connection. The default implementation throws a
* {@link WebServiceTransportException}.
* @param connection the erroneous connection
* @param request the corresponding request message
* @return the object to be returned from
* {@link #sendAndReceive(String,WebServiceMessageCallback, WebServiceMessageExtractor)}, if any
* {@link #sendAndReceive(String,WebServiceMessageCallback, WebServiceMessageExtractor)},
* if any
*/
protected Object handleError(WebServiceConnection connection, WebServiceMessage request) throws IOException {
if (logger.isDebugEnabled()) {
@@ -673,15 +723,19 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService
messageContext.getRequest().writeTo(requestStream);
ByteArrayOutputStream responseStream = new ByteArrayOutputStream();
messageContext.getResponse().writeTo(responseStream);
receivedMessageTracingLogger.trace("Received response [" + responseStream.toString(StandardCharsets.UTF_8) + "] for request ["
+ requestStream.toString(StandardCharsets.UTF_8) + "]");
} else if (receivedMessageTracingLogger.isDebugEnabled()) {
receivedMessageTracingLogger.debug("Received response [" + messageContext.getResponse() + "] for request ["
+ messageContext.getRequest() + "]");
receivedMessageTracingLogger
.trace("Received response [" + responseStream.toString(StandardCharsets.UTF_8) + "] for request ["
+ requestStream.toString(StandardCharsets.UTF_8) + "]");
}
} else {
else if (receivedMessageTracingLogger.isDebugEnabled()) {
receivedMessageTracingLogger.debug("Received response [" + messageContext.getResponse()
+ "] for request [" + messageContext.getRequest() + "]");
}
}
else {
if (receivedMessageTracingLogger.isDebugEnabled()) {
receivedMessageTracingLogger.debug("Received no response for request [" + messageContext.getRequest() + "]");
receivedMessageTracingLogger
.debug("Received no response for request [" + messageContext.getRequest() + "]");
}
}
}
@@ -689,13 +743,15 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService
/**
* Determines whether the given connection or message has a fault.
* <p>
* This implementation checks the {@link FaultAwareWebServiceConnection#hasFault() connection} if the
* {@link #setCheckConnectionForFault(boolean) checkConnectionForFault} property is true, and defaults to the
* This implementation checks the {@link FaultAwareWebServiceConnection#hasFault()
* connection} if the {@link #setCheckConnectionForFault(boolean)
* checkConnectionForFault} property is true, and defaults to the
* {@link FaultAwareWebServiceMessage#hasFault() message} otherwise.
*
* @param connection the connection (possibly a {@link FaultAwareWebServiceConnection}
* @param response the response message (possibly a {@link FaultAwareWebServiceMessage}
* @return {@code true} if either the connection or the message has a fault; {@code false} otherwise
* @param response the response message (possibly a
* {@link FaultAwareWebServiceMessage}
* @return {@code true} if either the connection or the message has a fault;
* {@code false} otherwise
* @throws IOException in case of I/O errors
*/
protected boolean hasFault(WebServiceConnection connection, WebServiceMessage response) throws IOException {
@@ -707,7 +763,8 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService
}
}
if (response instanceof FaultAwareWebServiceMessage) {
// either the connection has a fault, or checkConnectionForFault is false: let's verify the fault
// either the connection has a fault, or checkConnectionForFault is false:
// let's verify the fault
FaultAwareWebServiceMessage faultMessage = (FaultAwareWebServiceMessage) response;
return faultMessage.hasFault();
}
@@ -715,9 +772,9 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService
}
/**
* Trigger handleResponse on the defined ClientInterceptors. Will just invoke said method on all interceptors whose
* handleRequest invocation returned {@code true}, in addition to the last interceptor who returned {@code false}.
*
* Trigger handleResponse on the defined ClientInterceptors. Will just invoke said
* method on all interceptors whose handleRequest invocation returned {@code true}, in
* addition to the last interceptor who returned {@code false}.
* @param interceptorIndex index of last interceptor that was called
* @param messageContext the message context, whose request and response are filled
* @see ClientInterceptor#handleResponse(MessageContext)
@@ -734,9 +791,9 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService
}
/**
* Trigger handleFault on the defined ClientInterceptors. Will just invoke said method on all interceptors whose
* handleRequest invocation returned {@code true}, in addition to the last interceptor who returned {@code false}.
*
* Trigger handleFault on the defined ClientInterceptors. Will just invoke said method
* on all interceptors whose handleRequest invocation returned {@code true}, in
* addition to the last interceptor who returned {@code false}.
* @param interceptorIndex index of last interceptor that was called
* @param messageContext the message context, whose request and response are filled
* @see ClientInterceptor#handleResponse(MessageContext)
@@ -753,10 +810,10 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService
}
/**
* Trigger afterCompletion callbacks on the mapped ClientInterceptors. Will just invoke afterCompletion for all
* interceptors whose handleRequest invocation has successfully completed and returned true, in addition to the last
* interceptor who returned {@code false}.
*
* Trigger afterCompletion callbacks on the mapped ClientInterceptors. Will just
* invoke afterCompletion for all interceptors whose handleRequest invocation has
* successfully completed and returned true, in addition to the last interceptor who
* returned {@code false}.
* @param interceptorIndex index of last interceptor that successfully completed
* @param messageContext the message context
* @param ex Exception thrown on handler execution, or {@code null} if none
@@ -772,13 +829,14 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService
}
/**
* Handles an fault in the given response message. The default implementation invokes the {@link FaultMessageResolver
* fault resolver} if registered, or invokes {@link #handleError(WebServiceConnection, WebServiceMessage)} otherwise.
*
* Handles an fault in the given response message. The default implementation invokes
* the {@link FaultMessageResolver fault resolver} if registered, or invokes
* {@link #handleError(WebServiceConnection, WebServiceMessage)} otherwise.
* @param connection the faulty connection
* @param messageContext the message context
* @return the object to be returned from
* {@link #sendAndReceive(String,WebServiceMessageCallback, WebServiceMessageExtractor)}, if any
* {@link #sendAndReceive(String,WebServiceMessageCallback, WebServiceMessageExtractor)},
* if any
*/
protected Object handleFault(WebServiceConnection connection, MessageContext messageContext) throws IOException {
if (logger.isDebugEnabled()) {
@@ -787,12 +845,16 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService
if (getFaultMessageResolver() != null) {
getFaultMessageResolver().resolveFault(messageContext.getResponse());
return null;
} else {
}
else {
return handleError(connection, messageContext.getRequest());
}
}
/** Adapter to enable use of a WebServiceMessageCallback inside a WebServiceMessageExtractor. */
/**
* Adapter to enable use of a WebServiceMessageCallback inside a
* WebServiceMessageExtractor.
*/
private static class WebServiceMessageCallbackMessageExtractor implements WebServiceMessageExtractor<Boolean> {
private final WebServiceMessageCallback callback;
@@ -806,6 +868,7 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService
callback.doWithMessage(message);
return Boolean.TRUE;
}
}
/** Adapter to enable use of a SourceExtractor inside a WebServiceMessageExtractor. */
@@ -821,6 +884,7 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService
public T extractData(WebServiceMessage message) throws IOException, TransformerException {
return sourceExtractor.extractData(message.getPayloadSource());
}
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -31,17 +31,22 @@ import org.springframework.ws.transport.WebServiceMessageSender;
/**
* Convenient super class for application classes that need Web service access.
* <p>
* Requires a {@link WebServiceMessageFactory} or a {@link WebServiceTemplate} instance to be set. It will create its
* own {@code WebServiceTemplate} if {@code WebServiceMessageFactory} is passed in.
* Requires a {@link WebServiceMessageFactory} or a {@link WebServiceTemplate} instance to
* be set. It will create its own {@code WebServiceTemplate} if
* {@code WebServiceMessageFactory} is passed in.
* <p>
* In addition to the message factory property, this gateway offers {@link Marshaller} and {@link Unmarshaller}
* properties. Setting these is required when the {@link WebServiceTemplate#marshalSendAndReceive(Object) marshalling
* methods} of the template are to be used.
* In addition to the message factory property, this gateway offers {@link Marshaller} and
* {@link Unmarshaller} properties. Setting these is required when the
* {@link WebServiceTemplate#marshalSendAndReceive(Object) marshalling methods} of the
* template are to be used.
* <p>
* Note that when {@link #setWebServiceTemplate(WebServiceTemplate) injecting a {@code WebServiceTemplate}} directly,
* the convenience setters ({@link #setMarshaller(Marshaller)}, {@link #setUnmarshaller(Unmarshaller)},
* {@link #setMessageSender(WebServiceMessageSender)}, {@link #setMessageSenders(WebServiceMessageSender[])}, and
* {@link #setDefaultUri(String)}) should not be used on this class, but on the template directly.
* Note that when {@link #setWebServiceTemplate(WebServiceTemplate) injecting a
* {@code WebServiceTemplate}} directly, the convenience setters
* ({@link #setMarshaller(Marshaller)}, {@link #setUnmarshaller(Unmarshaller)},
* {@link #setMessageSender(WebServiceMessageSender)},
* {@link #setMessageSenders(WebServiceMessageSender[])}, and
* {@link #setDefaultUri(String)}) should not be used on this class, but on the template
* directly.
*
* @author Arjen Poutsma
* @see #setMessageFactory(WebServiceMessageFactory)
@@ -57,15 +62,16 @@ public abstract class WebServiceGatewaySupport implements InitializingBean {
private WebServiceTemplate webServiceTemplate;
/**
* Creates a new instance of the {@code WebServiceGatewaySupport} class, with a default {@code WebServiceTemplate}.
* Creates a new instance of the {@code WebServiceGatewaySupport} class, with a
* default {@code WebServiceTemplate}.
*/
protected WebServiceGatewaySupport() {
webServiceTemplate = new WebServiceTemplate();
}
/**
* Creates a new {@code WebServiceGatewaySupport} instance based on the given message factory.
*
* Creates a new {@code WebServiceGatewaySupport} instance based on the given message
* factory.
* @param messageFactory the message factory to use
*/
protected WebServiceGatewaySupport(WebServiceMessageFactory messageFactory) {
@@ -125,10 +131,12 @@ public abstract class WebServiceGatewaySupport implements InitializingBean {
/**
* Sets the {@code WebServiceTemplate} to be used by the gateway.
* <p>
* When using this property, the convenience setters ({@link #setMarshaller(Marshaller)},
* {@link #setUnmarshaller(Unmarshaller)}, {@link #setMessageSender(WebServiceMessageSender)},
* {@link #setMessageSenders(WebServiceMessageSender[])}, and {@link #setDefaultUri(String)}) should not be set on
* this class, but on the template directly.
* When using this property, the convenience setters
* ({@link #setMarshaller(Marshaller)}, {@link #setUnmarshaller(Unmarshaller)},
* {@link #setMessageSender(WebServiceMessageSender)},
* {@link #setMessageSenders(WebServiceMessageSender[])}, and
* {@link #setDefaultUri(String)}) should not be set on this class, but on the
* template directly.
*/
public final void setWebServiceTemplate(WebServiceTemplate webServiceTemplate) {
Assert.notNull(webServiceTemplate, "'webServiceTemplate' must not be null");
@@ -141,9 +149,9 @@ public abstract class WebServiceGatewaySupport implements InitializingBean {
}
/**
* Sets the {@code Marshaller} used by the gateway. Setting this property is only required if the marshalling
* functionality of {@code WebServiceTemplate} is to be used.
*
* Sets the {@code Marshaller} used by the gateway. Setting this property is only
* required if the marshalling functionality of {@code WebServiceTemplate} is to be
* used.
* @see WebServiceTemplate#marshalSendAndReceive
*/
public final void setMarshaller(Marshaller marshaller) {
@@ -156,9 +164,9 @@ public abstract class WebServiceGatewaySupport implements InitializingBean {
}
/**
* Sets the {@code Unmarshaller} used by the gateway. Setting this property is only required if the marshalling
* functionality of {@code WebServiceTemplate} is to be used.
*
* Sets the {@code Unmarshaller} used by the gateway. Setting this property is only
* required if the marshalling functionality of {@code WebServiceTemplate} is to be
* used.
* @see WebServiceTemplate#marshalSendAndReceive
*/
public final void setUnmarshaller(Unmarshaller unmarshaller) {
@@ -182,11 +190,11 @@ public abstract class WebServiceGatewaySupport implements InitializingBean {
}
/**
* Subclasses can override this for custom initialization behavior. Gets called after population of this instance's
* bean properties.
*
* Subclasses can override this for custom initialization behavior. Gets called after
* population of this instance's bean properties.
* @throws java.lang.Exception if initialization fails
*/
protected void initGateway() throws Exception {}
protected void initGateway() throws Exception {
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -28,10 +28,12 @@ import org.springframework.ws.transport.WebServiceMessageSender;
import org.springframework.xml.transform.TransformerObjectSupport;
/**
* Base class for {@code WebServiceTemplate} and other WS-accessing helpers. Defines common properties like the
* {@link WebServiceMessageFactory} and {@link WebServiceMessageSender}.
* Base class for {@code WebServiceTemplate} and other WS-accessing helpers. Defines
* common properties like the {@link WebServiceMessageFactory} and
* {@link WebServiceMessageSender}.
* <p>
* Not intended to be used directly. See {@link org.springframework.ws.client.core.WebServiceTemplate}.
* Not intended to be used directly. See
* {@link org.springframework.ws.client.core.WebServiceTemplate}.
*
* @author Arjen Poutsma
* @see org.springframework.ws.client.core.WebServiceTemplate
@@ -61,8 +63,8 @@ public abstract class WebServiceAccessor extends TransformerObjectSupport implem
/**
* Sets the single message sender used for sending messages.
* <p>
* This message sender will be used to resolve an URI to a {@link WebServiceConnection}.
*
* This message sender will be used to resolve an URI to a
* {@link WebServiceConnection}.
* @see #createConnection(URI)
*/
public void setMessageSender(WebServiceMessageSender messageSender) {
@@ -73,8 +75,8 @@ public abstract class WebServiceAccessor extends TransformerObjectSupport implem
/**
* Sets the message senders used for sending messages.
* <p>
* These message senders will be used to resolve an URI to a {@link WebServiceConnection}.
*
* These message senders will be used to resolve an URI to a
* {@link WebServiceConnection}.
* @see #createConnection(URI)
*/
public void setMessageSenders(WebServiceMessageSender[] messageSenders) {
@@ -89,12 +91,13 @@ public abstract class WebServiceAccessor extends TransformerObjectSupport implem
}
/**
* Creates a connection to the given URI, or throws an exception when it cannot be resolved.
* Creates a connection to the given URI, or throws an exception when it cannot be
* resolved.
* <p>
* Default implementation iterates over all configured {@link WebServiceMessageSender} objects, and calls
* {@link WebServiceMessageSender#supports(URI)} for each of them. If the sender supports the parameter URI, it
* creates a connection using {@link WebServiceMessageSender#createConnection(URI)} .
*
* Default implementation iterates over all configured {@link WebServiceMessageSender}
* objects, and calls {@link WebServiceMessageSender#supports(URI)} for each of them.
* If the sender supports the parameter URI, it creates a connection using
* {@link WebServiceMessageSender#createConnection(URI)} .
* @param uri the URI to open a connection to
* @return the created connection
* @throws IllegalArgumentException when the uri cannot be resolved
@@ -109,7 +112,8 @@ public abstract class WebServiceAccessor extends TransformerObjectSupport implem
if (logger.isDebugEnabled()) {
try {
logger.debug("Opening [" + connection + "] to [" + connection.getUri() + "]");
} catch (URISyntaxException e) {
}
catch (URISyntaxException e) {
// ignore
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -22,10 +22,11 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Abstract base class for {@link DestinationProvider} implementations that cache destination URI.
* Abstract base class for {@link DestinationProvider} implementations that cache
* destination URI.
* <p>
* Caching can be disabled by setting the {@link #setCache(boolean) cache} property to {@code false}; forcing a
* destination lookup for every call.
* Caching can be disabled by setting the {@link #setCache(boolean) cache} property to
* {@code false}; forcing a destination lookup for every call.
*
* @author Arjen Poutsma
* @since 1.5.4
@@ -40,9 +41,9 @@ public abstract class AbstractCachingDestinationProvider implements DestinationP
private boolean cache = true;
/**
* Set whether to cache resolved destinations. Default is {@code true}. This flag can be turned off to re-lookup a
* destination for each operation, which allows for hot restarting of destinations. This is mainly useful during
* development.
* Set whether to cache resolved destinations. Default is {@code true}. This flag can
* be turned off to re-lookup a destination for each operation, which allows for hot
* restarting of destinations. This is mainly useful during development.
*/
public void setCache(boolean cache) {
this.cache = cache;
@@ -55,7 +56,8 @@ public abstract class AbstractCachingDestinationProvider implements DestinationP
cachedUri = lookupDestination();
}
return cachedUri;
} else {
}
else {
return lookupDestination();
}
}
@@ -63,9 +65,10 @@ public abstract class AbstractCachingDestinationProvider implements DestinationP
/**
* Abstract template method that looks up the URI.
* <p>
* If {@linkplain #setCache(boolean) caching} is enabled, this method will only be called once.
*
* If {@linkplain #setCache(boolean) caching} is enabled, this method will only be
* called once.
* @return the destination URI
*/
protected abstract URI lookupDestination();
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -19,11 +19,12 @@ package org.springframework.ws.client.support.destination;
import java.net.URI;
/**
* Strategy interface for providing a {@link org.springframework.ws.client.core.WebServiceTemplate} destination URI at
* Strategy interface for providing a
* {@link org.springframework.ws.client.core.WebServiceTemplate} destination URI at
* runtime.
* <p>
* Typically implemented by providers that use WSDL, a UDDI registry, or some other form to determine the destination
* URI.
* Typically implemented by providers that use WSDL, a UDDI registry, or some other form
* to determine the destination URI.
*
* @author Arjen Poutsma
* @see org.springframework.ws.client.core.WebServiceTemplate#setDestinationProvider(DestinationProvider)
@@ -33,7 +34,6 @@ public interface DestinationProvider {
/**
* Return the destination URI.
*
* @return the destination URI
*/
URI getDestination();

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -34,4 +34,5 @@ public class DestinationProvisionException extends WebServiceClientException {
public DestinationProvisionException(String msg, Throwable ex) {
super(msg, ex);
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -26,6 +26,8 @@ import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMResult;
import org.w3c.dom.Document;
import org.springframework.core.io.Resource;
import org.springframework.util.Assert;
import org.springframework.ws.client.WebServiceIOException;
@@ -34,14 +36,15 @@ import org.springframework.xml.transform.ResourceSource;
import org.springframework.xml.transform.TransformerFactoryUtils;
import org.springframework.xml.xpath.XPathExpression;
import org.springframework.xml.xpath.XPathExpressionFactory;
import org.w3c.dom.Document;
/**
* Implementation of the {@link DestinationProvider} that resolves a destination URI from a WSDL file.
* Implementation of the {@link DestinationProvider} that resolves a destination URI from
* a WSDL file.
* <p>
* The extraction relies on an XPath expression to locate the URI. By default, the
* {@link #DEFAULT_WSDL_LOCATION_EXPRESSION} will be used, but this expression can be overridden by setting the
* {@link #setLocationExpression(String) locationExpression} property.
* {@link #DEFAULT_WSDL_LOCATION_EXPRESSION} will be used, but this expression can be
* overridden by setting the {@link #setLocationExpression(String) locationExpression}
* property.
*
* @author Tareq Abed Rabbo
* @author Arjen Poutsma
@@ -49,7 +52,10 @@ import org.w3c.dom.Document;
*/
public class Wsdl11DestinationProvider extends AbstractCachingDestinationProvider {
/** Default XPath expression used for extracting all {@code location} attributes from the WSDL definition. */
/**
* Default XPath expression used for extracting all {@code location} attributes from
* the WSDL definition.
*/
public static final String DEFAULT_WSDL_LOCATION_EXPRESSION = "/wsdl:definitions/wsdl:service/wsdl:port/soap:address/@location";
private static TransformerFactory transformerFactory = TransformerFactoryUtils.newInstance();
@@ -69,7 +75,10 @@ public class Wsdl11DestinationProvider extends AbstractCachingDestinationProvide
expressionNamespaces);
}
/** Sets a WSDL location from which the service destination {@code URI} will be resolved. */
/**
* Sets a WSDL location from which the service destination {@code URI} will be
* resolved.
*/
public void setWsdl(Resource wsdlResource) {
Assert.notNull(wsdlResource, "'wsdl' must not be null");
Assert.isTrue(wsdlResource.exists(), wsdlResource + " does not exist");
@@ -77,7 +86,8 @@ public class Wsdl11DestinationProvider extends AbstractCachingDestinationProvide
}
/**
* Sets the XPath expression to use when extracting the service location {@code URI} from a WSDL.
* Sets the XPath expression to use when extracting the service location {@code URI}
* from a WSDL.
* <p>
* The expression can use the following bound prefixes: <blockquote>
* <table>
@@ -119,9 +129,11 @@ public class Wsdl11DestinationProvider extends AbstractCachingDestinationProvide
logger.debug("Found location [" + location + "] in " + wsdlResource);
}
return location != null ? URI.create(location) : null;
} catch (IOException ex) {
}
catch (IOException ex) {
throw new WebServiceIOException("Error extracting location from WSDL [" + wsdlResource + "]", ex);
} catch (TransformerException ex) {
}
catch (TransformerException ex) {
throw new WebServiceTransformerException("Error extracting location from WSDL [" + wsdlResource + "]", ex);
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -20,6 +20,8 @@ import java.io.IOException;
import javax.xml.transform.Source;
import org.xml.sax.SAXParseException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.io.Resource;
import org.springframework.util.Assert;
@@ -34,15 +36,15 @@ import org.springframework.xml.validation.XmlValidator;
import org.springframework.xml.validation.XmlValidatorFactory;
import org.springframework.xml.xsd.XsdSchema;
import org.springframework.xml.xsd.XsdSchemaCollection;
import org.xml.sax.SAXParseException;
/**
* Abstract base class for {@link ClientInterceptor} implementations that validate part of the message using a schema.
* The exact message part is determined by the {@link #getValidationRequestSource(WebServiceMessage)} and
* Abstract base class for {@link ClientInterceptor} implementations that validate part of
* the message using a schema. The exact message part is determined by the
* {@link #getValidationRequestSource(WebServiceMessage)} and
* {@link #getValidationResponseSource(WebServiceMessage)} template methods.
* <p>
* By default, only the request message is validated, but this behaviour can be changed using the
* {@code validateRequest} and {@code validateResponse} properties.
* By default, only the request message is validated, but this behaviour can be changed
* using the {@code validateRequest} and {@code validateResponse} properties.
*
* @author Arjen Poutsma
* @see #getValidationRequestSource(WebServiceMessage)
@@ -67,8 +69,8 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup
}
/**
* Sets the schema language. Default is the W3C XML Schema: {@code http://www.w3.org/2001/XMLSchema"}.
*
* Sets the schema language. Default is the W3C XML Schema:
* {@code http://www.w3.org/2001/XMLSchema"}.
* @see XmlValidatorFactory#SCHEMA_W3C_XML
* @see XmlValidatorFactory#SCHEMA_RELAX_NG
*/
@@ -83,8 +85,9 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup
/**
* Sets the schema resource to use for validation. Setting this property,
* {@link #setXsdSchemaCollection(XsdSchemaCollection) xsdSchemaCollection}, {@link #setSchema(Resource) schema}, or
* {@link #setSchemas(Resource[]) schemas} is required.
* {@link #setXsdSchemaCollection(XsdSchemaCollection) xsdSchemaCollection},
* {@link #setSchema(Resource) schema}, or {@link #setSchemas(Resource[]) schemas} is
* required.
*/
public void setSchema(Resource schema) {
setSchemas(schema);
@@ -92,8 +95,9 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup
/**
* Sets the schema resources to use for validation. Setting this property,
* {@link #setXsdSchemaCollection(XsdSchemaCollection) xsdSchemaCollection}, {@link #setSchema(Resource) schema}, or
* {@link #setSchemas(Resource[]) schemas} is required.
* {@link #setXsdSchemaCollection(XsdSchemaCollection) xsdSchemaCollection},
* {@link #setSchema(Resource) schema}, or {@link #setSchemas(Resource[]) schemas} is
* required.
*/
public void setSchemas(Resource... schemas) {
Assert.notEmpty(schemas, "schemas must not be empty or null");
@@ -106,9 +110,9 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup
/**
* Sets the {@link XsdSchema} to use for validation. Setting this property,
* {@link #setXsdSchemaCollection(XsdSchemaCollection) xsdSchemaCollection}, {@link #setSchema(Resource) schema}, or
* {@link #setSchemas(Resource[]) schemas} is required.
*
* {@link #setXsdSchemaCollection(XsdSchemaCollection) xsdSchemaCollection},
* {@link #setSchema(Resource) schema}, or {@link #setSchemas(Resource[]) schemas} is
* required.
* @param schema the xsd schema to use
* @throws java.io.IOException in case of I/O errors
*/
@@ -117,9 +121,9 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup
}
/**
* Sets the {@link XsdSchemaCollection} to use for validation. Setting this property, {@link #setXsdSchema(XsdSchema)
* xsdSchema}, {@link #setSchema(Resource) schema}, or {@link #setSchemas(Resource[]) schemas} is required.
*
* Sets the {@link XsdSchemaCollection} to use for validation. Setting this property,
* {@link #setXsdSchema(XsdSchema) xsdSchema}, {@link #setSchema(Resource) schema}, or
* {@link #setSchemas(Resource[]) schemas} is required.
* @param schemaCollection the xsd schema collection to use
* @throws java.io.IOException in case of I/O errors
*/
@@ -127,12 +131,18 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup
this.validator = schemaCollection.createValidator();
}
/** Indicates whether the request should be validated against the schema. Default is {@code true}. */
/**
* Indicates whether the request should be validated against the schema. Default is
* {@code true}.
*/
public void setValidateRequest(boolean validateRequest) {
this.validateRequest = validateRequest;
}
/** Indicates whether the response should be validated against the schema. Default is {@code false}. */
/**
* Indicates whether the response should be validated against the schema. Default is
* {@code false}.
*/
public void setValidateResponse(boolean validateResponse) {
this.validateResponse = validateResponse;
}
@@ -153,11 +163,11 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup
}
/**
* Validates the request message in the given message context. Validation only occurs if
* {@link #setValidateRequest(boolean) validateRequest} is set to {@code true}, which is the default.
* Validates the request message in the given message context. Validation only occurs
* if {@link #setValidateRequest(boolean) validateRequest} is set to {@code true},
* which is the default.
* <p>
* Returns {@code true} if the request is valid, or {@code false} if it isn't.
*
* @param messageContext the message context
* @return {@code true} if the message is valid; {@code false} otherwise
* @see #setValidateRequest(boolean)
@@ -170,12 +180,14 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup
SAXParseException[] errors;
try {
errors = validator.validate(requestSource);
} catch (IOException e) {
}
catch (IOException e) {
throw new WebServiceIOException("Could not validate response: " + e.getMessage(), e);
}
if (!ObjectUtils.isEmpty(errors)) {
return handleRequestValidationErrors(messageContext, errors);
} else if (logger.isDebugEnabled()) {
}
else if (logger.isDebugEnabled()) {
logger.debug("Request message validated");
}
}
@@ -186,9 +198,9 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup
/**
* Template method that is called when the request message contains validation errors.
* <p>
* Default implementation logs all errors, and throws a {@link WebServiceValidationException}. Subclasses can override
* this method to customize this behavior.
*
* Default implementation logs all errors, and throws a
* {@link WebServiceValidationException}. Subclasses can override this method to
* customize this behavior.
* @param messageContext the message context
* @param errors the validation errors
* @return {@code true} to continue processing the request, {@code false} otherwise
@@ -201,12 +213,11 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup
}
/**
* Validates the response message in the given message context. Validation only occurs if
* {@link #setValidateResponse(boolean) validateResponse} is set to {@code true}, which is <strong>not</strong> the
* default.
* Validates the response message in the given message context. Validation only occurs
* if {@link #setValidateResponse(boolean) validateResponse} is set to {@code true},
* which is <strong>not</strong> the default.
* <p>
* Returns {@code true} if the request is valid, or {@code false} if it isn't.
*
* @param messageContext the message context.
* @return {@code true} if the response is valid; {@code false} otherwise
* @see #setValidateResponse(boolean)
@@ -219,12 +230,14 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup
SAXParseException[] errors;
try {
errors = validator.validate(responseSource);
} catch (IOException e) {
}
catch (IOException e) {
throw new WebServiceIOException("Could not validate response: " + e.getMessage(), e);
}
if (!ObjectUtils.isEmpty(errors)) {
return handleResponseValidationErrors(messageContext, errors);
} else if (logger.isDebugEnabled()) {
}
else if (logger.isDebugEnabled()) {
logger.debug("Response message validated");
}
}
@@ -233,14 +246,15 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup
}
/**
* Template method that is called when the response message contains validation errors.
* Template method that is called when the response message contains validation
* errors.
* <p>
* Default implementation logs all errors, and returns {@code false}, i.e. do not cot continue to process the respone
* interceptor chain.
*
* Default implementation logs all errors, and returns {@code false}, i.e. do not cot
* continue to process the respone interceptor chain.
* @param messageContext the message context
* @param errors the validation errors
* @return {@code true} to continue the reponse interceptor chain, {@code false} (the default) otherwise
* @return {@code true} to continue the reponse interceptor chain, {@code false} (the
* default) otherwise
*/
protected boolean handleResponseValidationErrors(MessageContext messageContext, SAXParseException[] errors)
throws WebServiceValidationException {
@@ -258,21 +272,25 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup
/** Does nothing by default. */
@Override
public void afterCompletion(MessageContext messageContext, Exception ex) throws WebServiceClientException {}
public void afterCompletion(MessageContext messageContext, Exception ex) throws WebServiceClientException {
}
/**
* Abstract template method that returns the part of the request message that is to be validated.
*
* Abstract template method that returns the part of the request message that is to be
* validated.
* @param request the request message
* @return the part of the message that is to validated, or {@code null} not to validate anything
* @return the part of the message that is to validated, or {@code null} not to
* validate anything
*/
protected abstract Source getValidationRequestSource(WebServiceMessage request);
/**
* Abstract template method that returns the part of the response message that is to be validated.
*
* Abstract template method that returns the part of the response message that is to
* be validated.
* @param response the response message
* @return the part of the message that is to validated, or {@code null} not to validate anything
* @return the part of the message that is to validated, or {@code null} not to
* validate anything
*/
protected abstract Source getValidationResponseSource(WebServiceMessage response);
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -22,20 +22,24 @@ import org.springframework.ws.soap.SoapHeader;
import org.springframework.ws.transport.WebServiceConnection;
/**
* Workflow interface that allows for customized client-side message interception. Applications can register any number
* of existing or custom interceptors on a {@link org.springframework.ws.client.core.WebServiceTemplate}, to add common
* pre- and postprocessing behavior without needing to modify payload handling code.
* Workflow interface that allows for customized client-side message interception.
* Applications can register any number of existing or custom interceptors on a
* {@link org.springframework.ws.client.core.WebServiceTemplate}, to add common pre- and
* postprocessing behavior without needing to modify payload handling code.
* <p>
* A {@code ClientInterceptor} gets called after payload creation (using
* {@link org.springframework.ws.client.core.WebServiceTemplate#marshalSendAndReceive(Object)} or similar methods, and
* after {@link org.springframework.ws.client.core.WebServiceMessageCallback callback} invocation, but before the
* message is sent over the {@link WebServiceConnection}. This mechanism can be used for a large field of preprocessing
* aspects, e.g. for authorization checks, or message header checks. Its main purpose is to allow for factoring out
* meta-data (i.e. {@link SoapHeader}) related code.
* {@link org.springframework.ws.client.core.WebServiceTemplate#marshalSendAndReceive(Object)}
* or similar methods, and after
* {@link org.springframework.ws.client.core.WebServiceMessageCallback callback}
* invocation, but before the message is sent over the {@link WebServiceConnection}. This
* mechanism can be used for a large field of preprocessing aspects, e.g. for
* authorization checks, or message header checks. Its main purpose is to allow for
* factoring out meta-data (i.e. {@link SoapHeader}) related code.
* <p>
* Client interceptors are defined on a {@link org.springframework.ws.client.core.WebServiceTemplate}, using the
* {@link org.springframework.ws.client.core.WebServiceTemplate#setInterceptors(ClientInterceptor[]) interceptors}
* property.
* Client interceptors are defined on a
* {@link org.springframework.ws.client.core.WebServiceTemplate}, using the
* {@link org.springframework.ws.client.core.WebServiceTemplate#setInterceptors(ClientInterceptor[])
* interceptors} property.
*
* @author Giovanni Cuccu
* @author Arjen Poutsma
@@ -45,40 +49,41 @@ import org.springframework.ws.transport.WebServiceConnection;
public interface ClientInterceptor {
/**
* Processes the outgoing request message. Called after payload creation and callback invocation, but before the
* message is sent.
*
* Processes the outgoing request message. Called after payload creation and callback
* invocation, but before the message is sent.
* @param messageContext contains the outgoing request message
* @return {@code true} to continue processing of the request interceptors; {@code false} to indicate blocking of the
* request endpoint chain
* @return {@code true} to continue processing of the request interceptors;
* {@code false} to indicate blocking of the request endpoint chain
* @throws WebServiceClientException in case of errors
* @see MessageContext#getRequest()
*/
boolean handleRequest(MessageContext messageContext) throws WebServiceClientException;
/**
* Processes the incoming response message. Called for non-fault response messages before payload handling in the
* Processes the incoming response message. Called for non-fault response messages
* before payload handling in the
* {@link org.springframework.ws.client.core.WebServiceTemplate}.
* <p>
* Note: Will only be called if this interceptor's {@link #handleRequest} method has successfully completed.
*
* Note: Will only be called if this interceptor's {@link #handleRequest} method has
* successfully completed.
* @param messageContext contains the outgoing request message
* @return {@code true} to continue processing of the request interceptors; {@code false} to indicate blocking of the
* response endpoint chain
* @return {@code true} to continue processing of the request interceptors;
* {@code false} to indicate blocking of the response endpoint chain
* @throws WebServiceClientException in case of errors
* @see MessageContext#getResponse()
*/
boolean handleResponse(MessageContext messageContext) throws WebServiceClientException;
/**
* Processes the incoming response fault. Called for response fault messages before payload handling in the
* Processes the incoming response fault. Called for response fault messages before
* payload handling in the
* {@link org.springframework.ws.client.core.WebServiceTemplate}.
* <p>
* Note: Will only be called if this interceptor's {@link #handleRequest} method has successfully completed.
*
* Note: Will only be called if this interceptor's {@link #handleRequest} method has
* successfully completed.
* @param messageContext contains the outgoing request message
* @return {@code true} to continue processing of the request interceptors; {@code false} to indicate blocking of the
* request endpoint chain
* @return {@code true} to continue processing of the request interceptors;
* {@code false} to indicate blocking of the request endpoint chain
* @throws WebServiceClientException in case of errors
* @see MessageContext#getResponse()
* @see org.springframework.ws.FaultAwareWebServiceMessage#hasFault()
@@ -86,12 +91,13 @@ public interface ClientInterceptor {
boolean handleFault(MessageContext messageContext) throws WebServiceClientException;
/**
* Callback after completion of request and response (fault) processing. Will be called on any outcome, thus allows
* for proper resource cleanup.
* Callback after completion of request and response (fault) processing. Will be
* called on any outcome, thus allows for proper resource cleanup.
* <p>
* Note: Will only be called if this interceptor's {@link #handleRequest} method has successfully completed.
*
* @param messageContext contains both request and response messages, the response should contains a Fault
* Note: Will only be called if this interceptor's {@link #handleRequest} method has
* successfully completed.
* @param messageContext contains both request and response messages, the response
* should contains a Fault
* @param ex exception thrown on handler execution, if any
* @throws WebServiceClientException in case of errors
* @since 2.2

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -21,8 +21,8 @@ import org.springframework.ws.client.WebServiceClientException;
import org.springframework.ws.context.MessageContext;
/**
* Default implementation of the {@code ClientInterceptor} interface, for simplified implementation of
* pre-only/post-only interceptors.
* Default implementation of the {@code ClientInterceptor} interface, for simplified
* implementation of pre-only/post-only interceptors.
*
* @author Marten Deinum
* @since 2.2.5
@@ -56,4 +56,5 @@ public abstract class ClientInterceptorAdapter implements ClientInterceptor {
public void afterCompletion(MessageContext messageContext, Exception ex) throws WebServiceClientException {
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -21,14 +21,16 @@ import javax.xml.transform.Source;
import org.springframework.ws.WebServiceMessage;
/**
* Client-side interceptor that validates the contents of {@code WebServiceMessage}s using a schema. Allows for both W3C
* XML and RELAX NG schemas.
* Client-side interceptor that validates the contents of {@code WebServiceMessage}s using
* a schema. Allows for both W3C XML and RELAX NG schemas.
* <p>
* When the payload is invalid, this interceptor stops processing of the interceptor chain.
* When the payload is invalid, this interceptor stops processing of the interceptor
* chain.
* <p>
* The schema to validate against is set with the {@code schema} property or {@code schemas} property. By default, only
* the request message is validated, but this behaviour can be changed using the {@code validateRequest} and
* {@code validateResponse} properties. Responses that contains faults are not validated.
* The schema to validate against is set with the {@code schema} property or
* {@code schemas} property. By default, only the request message is validated, but this
* behaviour can be changed using the {@code validateRequest} and {@code validateResponse}
* properties. Responses that contains faults are not validated.
*
* @author Stefan Schmidt
* @author Arjen Poutsma
@@ -42,9 +44,9 @@ public class PayloadValidatingInterceptor extends AbstractValidatingInterceptor
/**
* Returns the part of the request message that is to be validated. Default
*
* @param request the request message
* @return the part of the message that is to validated, or {@code null} not to validate anything
* @return the part of the message that is to validated, or {@code null} not to
* validate anything
*/
@Override
protected Source getValidationRequestSource(WebServiceMessage request) {
@@ -53,12 +55,13 @@ public class PayloadValidatingInterceptor extends AbstractValidatingInterceptor
/**
* Returns the part of the response message that is to be validated.
*
* @param response the response message
* @return the part of the message that is to validated, or {@code null} not to validate anything
* @return the part of the message that is to validated, or {@code null} not to
* validate anything
*/
@Override
protected Source getValidationResponseSource(WebServiceMessage response) {
return response.getPayloadSource();
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -16,9 +16,10 @@
package org.springframework.ws.client.support.interceptor;
import org.springframework.ws.client.WebServiceClientException;
import org.xml.sax.SAXParseException;
import org.springframework.ws.client.WebServiceClientException;
/**
* Exception thrown whenever a validation error occurs on the client-side.
*
@@ -52,4 +53,5 @@ public class WebServiceValidationException extends WebServiceClientException {
public SAXParseException[] getValidationErrors() {
return validationErrors;
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -16,6 +16,8 @@
package org.springframework.ws.config;
import org.w3c.dom.Element;
import org.springframework.beans.BeanMetadataElement;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.RuntimeBeanReference;
@@ -46,10 +48,10 @@ import org.springframework.ws.soap.server.endpoint.SoapFaultAnnotationExceptionR
import org.springframework.ws.soap.server.endpoint.adapter.method.SoapHeaderElementMethodArgumentResolver;
import org.springframework.ws.soap.server.endpoint.adapter.method.SoapMethodArgumentResolver;
import org.springframework.ws.soap.server.endpoint.mapping.SoapActionAnnotationMethodEndpointMapping;
import org.w3c.dom.Element;
/**
* {@link BeanDefinitionParser} that parses the {@code annotation-driven} element to configure a Spring WS application.
* {@link BeanDefinitionParser} that parses the {@code annotation-driven} element to
* configure a Spring WS application.
*
* @author Arjen Poutsma
* @since 2.0
@@ -90,8 +92,8 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
}
private void registerEndpointMappings(Object source, ParserContext parserContext) {
RootBeanDefinition payloadRootMappingDef = createBeanDefinition(PayloadRootAnnotationMethodEndpointMapping.class,
source);
RootBeanDefinition payloadRootMappingDef = createBeanDefinition(
PayloadRootAnnotationMethodEndpointMapping.class, source);
payloadRootMappingDef.getPropertyValues().add("order", 0);
parserContext.getReaderContext().registerWithGeneratedName(payloadRootMappingDef);
@@ -135,18 +137,19 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
returnValueHandlers.add(dom4jProcessor);
}
if (jaxb2Present) {
RuntimeBeanReference xmlRootElementProcessor = createBeanReference(XmlRootElementPayloadMethodProcessor.class,
source, parserContext);
RuntimeBeanReference xmlRootElementProcessor = createBeanReference(
XmlRootElementPayloadMethodProcessor.class, source, parserContext);
argumentResolvers.add(xmlRootElementProcessor);
returnValueHandlers.add(xmlRootElementProcessor);
RuntimeBeanReference jaxbElementProcessor = createBeanReference(JaxbElementPayloadMethodProcessor.class, source,
parserContext);
RuntimeBeanReference jaxbElementProcessor = createBeanReference(JaxbElementPayloadMethodProcessor.class,
source, parserContext);
argumentResolvers.add(jaxbElementProcessor);
returnValueHandlers.add(jaxbElementProcessor);
}
if (jdomPresent) {
RuntimeBeanReference jdomProcessor = createBeanReference(JDomPayloadMethodProcessor.class, source, parserContext);
RuntimeBeanReference jdomProcessor = createBeanReference(JDomPayloadMethodProcessor.class, source,
parserContext);
argumentResolvers.add(jdomProcessor);
returnValueHandlers.add(jdomProcessor);
}
@@ -154,7 +157,8 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
argumentResolvers.add(createBeanDefinition(StaxPayloadMethodArgumentResolver.class, source));
}
if (xomPresent) {
RuntimeBeanReference xomProcessor = createBeanReference(XomPayloadMethodProcessor.class, source, parserContext);
RuntimeBeanReference xomProcessor = createBeanReference(XomPayloadMethodProcessor.class, source,
parserContext);
argumentResolvers.add(xomProcessor);
returnValueHandlers.add(xomProcessor);
}
@@ -163,7 +167,8 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
RuntimeBeanReference unmarshallerReference;
if (element.hasAttribute("unmarshaller")) {
unmarshallerReference = new RuntimeBeanReference(element.getAttribute("unmarshaller"));
} else {
}
else {
unmarshallerReference = marshallerReference;
}
@@ -182,7 +187,8 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
}
private void registerEndpointExceptionResolvers(Object source, ParserContext parserContext) {
RootBeanDefinition annotationResolverDef = createBeanDefinition(SoapFaultAnnotationExceptionResolver.class, source);
RootBeanDefinition annotationResolverDef = createBeanDefinition(SoapFaultAnnotationExceptionResolver.class,
source);
annotationResolverDef.getPropertyValues().add("order", 0);
parserContext.getReaderContext().registerWithGeneratedName(annotationResolverDef);
@@ -204,4 +210,5 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
return beanDefinition;
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -18,6 +18,8 @@ package org.springframework.ws.config;
import java.util.List;
import org.w3c.dom.Element;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
@@ -31,7 +33,6 @@ import org.springframework.util.xml.DomUtils;
import org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition;
import org.springframework.xml.xsd.SimpleXsdSchema;
import org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection;
import org.w3c.dom.Element;
/**
* Parser for the {@code &lt;sws:dynamic-wsdl/&gt;} element.
@@ -75,10 +76,11 @@ class DynamicWsdlBeanDefinitionParser extends AbstractBeanDefinitionParser {
collectionDef.getPropertyValues().addPropertyValue("xsds", xsds);
String collectionName = parserContext.getReaderContext().registerWithGeneratedName(collectionDef);
wsdlBuilder.addPropertyReference("schemaCollection", collectionName);
} else {
}
else {
if (schemas.size() > 1) {
throw new IllegalArgumentException(
"Multiple <xsd/> elements requires Commons XMLSchema." + "Please put Commons XMLSchema on the classpath.");
throw new IllegalArgumentException("Multiple <xsd/> elements requires Commons XMLSchema."
+ "Please put Commons XMLSchema on the classpath.");
}
RootBeanDefinition schemaDef = createBeanDefinition(SimpleXsdSchema.class, source);
Element schema = schemas.iterator().next();

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -18,6 +18,8 @@ package org.springframework.ws.config;
import java.util.List;
import org.w3c.dom.Element;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanDefinitionHolder;
import org.springframework.beans.factory.config.BeanReference;
@@ -33,7 +35,6 @@ import org.springframework.ws.server.SmartEndpointInterceptor;
import org.springframework.ws.soap.server.endpoint.interceptor.DelegatingSmartSoapEndpointInterceptor;
import org.springframework.ws.soap.server.endpoint.interceptor.PayloadRootSmartSoapEndpointInterceptor;
import org.springframework.ws.soap.server.endpoint.interceptor.SoapActionSmartEndpointInterceptor;
import org.w3c.dom.Element;
/**
* Parser for the {@code &lt;sws:interceptors/&gt;} element.
@@ -59,7 +60,8 @@ class InterceptorsBeanDefinitionParser implements BeanDefinitionParser {
smartInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(0, interceptorDef);
registerSmartInterceptor(parserContext, smartInterceptorDef);
} else if ("ref".equals(childElement.getLocalName())) {
}
else if ("ref".equals(childElement.getLocalName())) {
RootBeanDefinition smartInterceptorDef = createSmartInterceptorDefinition(
DelegatingSmartSoapEndpointInterceptor.class, childElement, parserContext);
@@ -69,13 +71,15 @@ class InterceptorsBeanDefinitionParser implements BeanDefinitionParser {
registerSmartInterceptor(parserContext, smartInterceptorDef);
} else if ("payloadRoot".equals(childElement.getLocalName())) {
}
else if ("payloadRoot".equals(childElement.getLocalName())) {
List<Element> payloadRootChildren = DomUtils.getChildElements(childElement);
for (Element payloadRootChild : payloadRootChildren) {
if ("bean".equals(payloadRootChild.getLocalName())) {
RootBeanDefinition smartInterceptorDef = createSmartInterceptorDefinition(
PayloadRootSmartSoapEndpointInterceptor.class, childElement, parserContext);
BeanDefinitionHolder interceptorDef = createInterceptorDefinition(parserContext, payloadRootChild);
BeanDefinitionHolder interceptorDef = createInterceptorDefinition(parserContext,
payloadRootChild);
String namespaceUri = childElement.getAttribute("namespaceUri");
String localPart = childElement.getAttribute("localPart");
@@ -85,7 +89,8 @@ class InterceptorsBeanDefinitionParser implements BeanDefinitionParser {
smartInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(2, localPart);
registerSmartInterceptor(parserContext, smartInterceptorDef);
} else if ("ref".equals(payloadRootChild.getLocalName())) {
}
else if ("ref".equals(payloadRootChild.getLocalName())) {
RootBeanDefinition smartInterceptorDef = createSmartInterceptorDefinition(
PayloadRootSmartSoapEndpointInterceptor.class, childElement, parserContext);
BeanReference interceptorRef = createInterceptorReference(parserContext, payloadRootChild);
@@ -100,13 +105,15 @@ class InterceptorsBeanDefinitionParser implements BeanDefinitionParser {
registerSmartInterceptor(parserContext, smartInterceptorDef);
}
}
} else if ("soapAction".equals(childElement.getLocalName())) {
}
else if ("soapAction".equals(childElement.getLocalName())) {
List<Element> soapActionChildren = DomUtils.getChildElements(childElement);
for (Element soapActionChild : soapActionChildren) {
if ("bean".equals(soapActionChild.getLocalName())) {
RootBeanDefinition smartInterceptorDef = createSmartInterceptorDefinition(
SoapActionSmartEndpointInterceptor.class, childElement, parserContext);
BeanDefinitionHolder interceptorDef = createInterceptorDefinition(parserContext, soapActionChild);
BeanDefinitionHolder interceptorDef = createInterceptorDefinition(parserContext,
soapActionChild);
String soapAction = childElement.getAttribute("value");
@@ -114,7 +121,8 @@ class InterceptorsBeanDefinitionParser implements BeanDefinitionParser {
smartInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(1, soapAction);
registerSmartInterceptor(parserContext, smartInterceptorDef);
} else if ("ref".equals(soapActionChild.getLocalName())) {
}
else if ("ref".equals(soapActionChild.getLocalName())) {
RootBeanDefinition smartInterceptorDef = createSmartInterceptorDefinition(
SoapActionSmartEndpointInterceptor.class, childElement, parserContext);
BeanReference interceptorRef = createInterceptorReference(parserContext, soapActionChild);
@@ -176,4 +184,5 @@ class InterceptorsBeanDefinitionParser implements BeanDefinitionParser {
private void error(ParserContext parserContext, String message, Object source) {
parserContext.getDelegate().getReaderContext().error(message, source);
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -16,19 +16,21 @@
package org.springframework.ws.config;
import org.w3c.dom.Element;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
import org.w3c.dom.Element;
/**
* Parser for the <code>&lt;sws:marshalling-endpoints/&gt; element.
*
* @author Arjen Poutsma
* @since 1.5.0
* @deprecated as of Spring Web Services 2.0, in favor of {@link AnnotationDrivenBeanDefinitionParser}
* @deprecated as of Spring Web Services 2.0, in favor of
* {@link AnnotationDrivenBeanDefinitionParser}
*/
@Deprecated
class MarshallingEndpointsBeanDefinitionParser extends AbstractSimpleBeanDefinitionParser {

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -37,4 +37,5 @@ public class WebServicesNamespaceHandler extends NamespaceHandlerSupport {
registerBeanDefinitionParser("marshalling-endpoints", new MarshallingEndpointsBeanDefinitionParser());
registerBeanDefinitionParser("xpath-endpoints", new XPathEndpointsBeanDefinitionParser());
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -19,18 +19,20 @@ package org.springframework.ws.config;
import java.util.List;
import java.util.Properties;
import org.w3c.dom.Element;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.util.xml.DomUtils;
import org.w3c.dom.Element;
/**
* Parser for the <code>&lt;sws:xpath-endpoints/&gt; element.
*
* @author Arjen Poutsma
* @since 1.5.0
* @deprecated as of Spring Web Services 2.0, in favor of {@link AnnotationDrivenBeanDefinitionParser}
* @deprecated as of Spring Web Services 2.0, in favor of
* {@link AnnotationDrivenBeanDefinitionParser}
*/
@Deprecated
class XPathEndpointsBeanDefinitionParser extends AbstractSimpleBeanDefinitionParser {

View File

@@ -1,3 +1,19 @@
/*
* 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.annotation;
import java.util.List;
@@ -9,9 +25,10 @@ import org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResol
import org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler;
/**
* A sub-class of {@code WsConfigurationSupport} that detects and delegates to all beans of type {@link WsConfigurer}
* allowing them to customize the configuration provided by {@code WsConfigurationSupport}. This is the class actually
* imported by {@link EnableWs @EnableWs}.
* A sub-class of {@code WsConfigurationSupport} that detects and delegates to all beans
* of type {@link WsConfigurer} allowing them to customize the configuration provided by
* {@code WsConfigurationSupport}. This is the class actually imported by
* {@link EnableWs @EnableWs}.
*
* @author Arjen Poutsma
* @since 2.2
@@ -42,4 +59,5 @@ public class DelegatingWsConfiguration extends WsConfigurationSupport {
protected void addReturnValueHandlers(List<MethodReturnValueHandler> returnValueHandlers) {
this.configurers.addReturnValueHandlers(returnValueHandlers);
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -26,8 +26,9 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
/**
* Add this annotation to an {@link Configuration @Configuration} class to have the Spring Web Services configuration
* defined in {@link WsConfigurationSupport} imported. For instance:
* Add this annotation to an {@link Configuration @Configuration} class to have the Spring
* Web Services configuration defined in {@link WsConfigurationSupport} imported. For
* instance:
*
* <pre class="code">
* &#064;Configuration
@@ -38,8 +39,9 @@ import org.springframework.context.annotation.Import;
* }
* </pre>
* <p>
* Customize the imported configuration by implementing the {@link WsConfigurer} interface or more likely by extending
* the {@link WsConfigurerAdapter} base class and overriding individual methods:
* Customize the imported configuration by implementing the {@link WsConfigurer} interface
* or more likely by extending the {@link WsConfigurerAdapter} base class and overriding
* individual methods:
*
* <pre class="code">
* &#064;Configuration
@@ -61,9 +63,9 @@ import org.springframework.context.annotation.Import;
* }
* </pre>
* <p>
* If the customization options of {@link WsConfigurer} do not expose something you need to configure, consider removing
* the {@code @EnableWs} annotation and extending directly from {@link WsConfigurationSupport} overriding selected
* {@code @Bean} methods:
* If the customization options of {@link WsConfigurer} do not expose something you need
* to configure, consider removing the {@code @EnableWs} annotation and extending directly
* from {@link WsConfigurationSupport} overriding selected {@code @Bean} methods:
*
* <pre class="code">
* &#064;Configuration

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -40,30 +40,34 @@ import org.springframework.ws.soap.server.endpoint.annotation.SoapFault;
import org.springframework.ws.soap.server.endpoint.mapping.SoapActionAnnotationMethodEndpointMapping;
/**
* This is the main class providing the configuration behind the Spring Web Services Java config. It is typically
* imported by adding {@link EnableWs @EnableWs} to an application {@link Configuration @Configuration} class. An
* alternative, more advanced option is to extend directly from this class and override methods as necessary remembering
* to add {@link Configuration @Configuration} to the subclass and {@link Bean @Bean} to overridden {@link Bean @Bean}
* methods. For more details see the Javadoc of {@link EnableWs @EnableWs}.
* This is the main class providing the configuration behind the Spring Web Services Java
* config. It is typically imported by adding {@link EnableWs @EnableWs} to an application
* {@link Configuration @Configuration} class. An alternative, more advanced option is to
* extend directly from this class and override methods as necessary remembering to add
* {@link Configuration @Configuration} to the subclass and {@link Bean @Bean} to
* overridden {@link Bean @Bean} methods. For more details see the Javadoc of
* {@link EnableWs @EnableWs}.
* <p>
* This class registers the following {@link EndpointMapping}s:
* <ul>
* <li>{@link PayloadRootAnnotationMethodEndpointMapping} ordered at 0 for mapping requests to
* {@link PayloadRoot @PayloadRoot} annotated controller methods.
* <li>{@link SoapActionAnnotationMethodEndpointMapping} ordered at 1 for mapping requests to
* {@link SoapAction @SoapAction} annotated controller methods.
* <li>{@link AnnotationActionEndpointMapping} ordered at 2 for mapping requests to {@link Action @Action} annotated
* controller methods.
* <li>{@link PayloadRootAnnotationMethodEndpointMapping} ordered at 0 for mapping
* requests to {@link PayloadRoot @PayloadRoot} annotated controller methods.
* <li>{@link SoapActionAnnotationMethodEndpointMapping} ordered at 1 for mapping requests
* to {@link SoapAction @SoapAction} annotated controller methods.
* <li>{@link AnnotationActionEndpointMapping} ordered at 2 for mapping requests to
* {@link Action @Action} annotated controller methods.
* </ul>
* <p>
* Registers one {@link EndpointAdapter}:
* <ul>
* <li>{@link DefaultMethodEndpointAdapter} for processing requests with annotated endpoint methods.
* <li>{@link DefaultMethodEndpointAdapter} for processing requests with annotated
* endpoint methods.
* </ul>
* <p>
* Registers the following {@link EndpointExceptionResolver}s:
* <ul>
* <li>{@link SoapFaultAnnotationExceptionResolver} for handling exceptions annotated with {@link SoapFault @SoapFault}.
* <li>{@link SoapFaultAnnotationExceptionResolver} for handling exceptions annotated with
* {@link SoapFault @SoapFault}.
* <li>{@link SimpleSoapExceptionResolver} for creating default exceptions.
* </ul>
*
@@ -78,8 +82,8 @@ public class WsConfigurationSupport {
private List<EndpointInterceptor> interceptors;
/**
* Returns a {@link PayloadRootAnnotationMethodEndpointMapping} ordered at 0 for mapping requests to annotated
* endpoints.
* Returns a {@link PayloadRootAnnotationMethodEndpointMapping} ordered at 0 for
* mapping requests to annotated endpoints.
*/
@Bean
public PayloadRootAnnotationMethodEndpointMapping payloadRootAnnotationMethodEndpointMapping() {
@@ -90,8 +94,8 @@ public class WsConfigurationSupport {
}
/**
* Returns a {@link SoapActionAnnotationMethodEndpointMapping} ordered at 1 for mapping requests to annotated
* endpoints.
* Returns a {@link SoapActionAnnotationMethodEndpointMapping} ordered at 1 for
* mapping requests to annotated endpoints.
*/
@Bean
public SoapActionAnnotationMethodEndpointMapping soapActionAnnotationMethodEndpointMapping() {
@@ -102,7 +106,8 @@ public class WsConfigurationSupport {
}
/**
* Returns a {@link AnnotationActionEndpointMapping} ordered at 2 for mapping requests to annotated endpoints.
* Returns a {@link AnnotationActionEndpointMapping} ordered at 2 for mapping requests
* to annotated endpoints.
*/
@Bean
public AnnotationActionEndpointMapping annotationActionEndpointMapping() {
@@ -113,8 +118,9 @@ public class WsConfigurationSupport {
}
/**
* Provide access to the shared handler interceptors used to configure {@link EndpointMapping} instances with. This
* method cannot be overridden, use {@link #addInterceptors(List)} instead.
* Provide access to the shared handler interceptors used to configure
* {@link EndpointMapping} instances with. This method cannot be overridden, use
* {@link #addInterceptors(List)} instead.
*/
protected final EndpointInterceptor[] getInterceptors() {
if (interceptors == null) {
@@ -125,14 +131,16 @@ public class WsConfigurationSupport {
}
/**
* Template method to add endpoint interceptors. Override this method to add Spring-WS interceptors for pre- and
* post-processing of endpoint invocation.
* Template method to add endpoint interceptors. Override this method to add Spring-WS
* interceptors for pre- and post-processing of endpoint invocation.
*/
protected void addInterceptors(List<EndpointInterceptor> interceptors) {}
protected void addInterceptors(List<EndpointInterceptor> interceptors) {
}
/**
* Returns a {@link DefaultMethodEndpointAdapter} for processing requests through annotated endpoint methods. Consider
* overriding one of these other more fine-grained methods:
* Returns a {@link DefaultMethodEndpointAdapter} for processing requests through
* annotated endpoint methods. Consider overriding one of these other more
* fine-grained methods:
* <ul>
* <li>{@link #addArgumentResolvers(List)} for adding custom argument resolvers.
* <li>{@link #addReturnValueHandlers(List)} for adding custom return value handlers.
@@ -154,21 +162,24 @@ public class WsConfigurationSupport {
}
/**
* Add custom {@link MethodArgumentResolver}s to use in addition to the ones registered by default.
*
* Add custom {@link MethodArgumentResolver}s to use in addition to the ones
* registered by default.
* @param argumentResolvers the list of custom converters; initially an empty list.
*/
protected void addArgumentResolvers(List<MethodArgumentResolver> argumentResolvers) {}
protected void addArgumentResolvers(List<MethodArgumentResolver> argumentResolvers) {
}
/**
* Add custom {@link MethodReturnValueHandler}s in addition to the ones registered by default.
*
* Add custom {@link MethodReturnValueHandler}s in addition to the ones registered by
* default.
* @param returnValueHandlers the list of custom handlers; initially an empty list.
*/
protected void addReturnValueHandlers(List<MethodReturnValueHandler> returnValueHandlers) {}
protected void addReturnValueHandlers(List<MethodReturnValueHandler> returnValueHandlers) {
}
/**
* Returns a {@link SoapFaultAnnotationExceptionResolver} ordered at 0 for handling endpoint exceptions.
* Returns a {@link SoapFaultAnnotationExceptionResolver} ordered at 0 for handling
* endpoint exceptions.
*/
@Bean
public SoapFaultAnnotationExceptionResolver soapFaultAnnotationExceptionResolver() {
@@ -179,8 +190,9 @@ public class WsConfigurationSupport {
}
/**
* Returns a {@link SimpleSoapExceptionResolver} ordered at {@linkplain Ordered#LOWEST_PRECEDENCE lowest precedence}
* for handling endpoint exceptions.
* Returns a {@link SimpleSoapExceptionResolver} ordered at
* {@linkplain Ordered#LOWEST_PRECEDENCE lowest precedence} for handling endpoint
* exceptions.
*/
@Bean
public SimpleSoapExceptionResolver simpleSoapExceptionResolver() {

View File

@@ -1,3 +1,19 @@
/*
* 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.annotation;
import java.util.List;
@@ -7,12 +23,13 @@ import org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResol
import org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler;
/**
* Defines callback methods to customize the Java-based configuration for Spring Web Services enabled via
* {@link EnableWs @EnableWs}.
* Defines callback methods to customize the Java-based configuration for Spring Web
* Services enabled via {@link EnableWs @EnableWs}.
* <p>
* {@code @EnableWs}-annotated configuration classes may implement this interface to be called back and given a chance
* to customize the default configuration. Consider extending {@link WsConfigurerAdapter}, which provides a stub
* implementation of all interface methods.
* {@code @EnableWs}-annotated configuration classes may implement this interface to be
* called back and given a chance to customize the default configuration. Consider
* extending {@link WsConfigurerAdapter}, which provides a stub implementation of all
* interface methods.
*
* @author Arjen Poutsma
* @since 2.2
@@ -20,13 +37,13 @@ import org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHa
public interface WsConfigurer {
/**
* Add {@link EndpointInterceptor}s for pre- and post-processing of endpoint method invocations.
* Add {@link EndpointInterceptor}s for pre- and post-processing of endpoint method
* invocations.
*/
void addInterceptors(List<EndpointInterceptor> interceptors);
/**
* Add resolvers to support custom endpoint method argument types.
*
* @param argumentResolvers initially an empty list
*/
void addArgumentResolvers(List<MethodArgumentResolver> argumentResolvers);
@@ -34,10 +51,11 @@ public interface WsConfigurer {
/**
* Add handlers to support custom controller method return value types.
* <p>
* Using this option does not override the built-in support for handling return values. To customize the built-in
* support for handling return values, configure RequestMappingHandlerAdapter directly.
*
* Using this option does not override the built-in support for handling return
* values. To customize the built-in support for handling return values, configure
* RequestMappingHandlerAdapter directly.
* @param returnValueHandlers initially an empty list
*/
void addReturnValueHandlers(List<MethodReturnValueHandler> returnValueHandlers);
}

View File

@@ -1,3 +1,19 @@
/*
* 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.annotation;
import java.util.List;
@@ -7,8 +23,8 @@ import org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResol
import org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler;
/**
* An default implementation of {@link WsConfigurer} with empty methods allowing sub-classes to override only the
* methods they're interested in.
* An default implementation of {@link WsConfigurer} with empty methods allowing
* sub-classes to override only the methods they're interested in.
*
* @author Arjen Poutsma
* @since 2.2
@@ -21,7 +37,8 @@ public class WsConfigurerAdapter implements WsConfigurer {
* This implementation is empty.
*/
@Override
public void addInterceptors(List<EndpointInterceptor> interceptors) {}
public void addInterceptors(List<EndpointInterceptor> interceptors) {
}
/**
* {@inheritDoc}
@@ -29,7 +46,8 @@ public class WsConfigurerAdapter implements WsConfigurer {
* This implementation is empty.
*/
@Override
public void addArgumentResolvers(List<MethodArgumentResolver> argumentResolvers) {}
public void addArgumentResolvers(List<MethodArgumentResolver> argumentResolvers) {
}
/**
* {@inheritDoc}
@@ -40,4 +58,5 @@ public class WsConfigurerAdapter implements WsConfigurer {
public void addReturnValueHandlers(List<MethodReturnValueHandler> returnValueHandlers) {
}
}

View File

@@ -1,3 +1,19 @@
/*
* 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.annotation;
import java.util.ArrayList;
@@ -8,7 +24,8 @@ import org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResol
import org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler;
/**
* An {@link WsConfigurer} implementation that delegates to other {@link WsConfigurer} instances.
* An {@link WsConfigurer} implementation that delegates to other {@link WsConfigurer}
* instances.
*
* @author Arjen Poutsma
* @since 2.2

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -30,7 +30,8 @@ import org.springframework.util.StringUtils;
public abstract class AbstractMessageContext implements MessageContext {
/**
* Keys are {@code Strings}, values are {@code Objects}. Lazily initialized by {@code getProperties()}.
* Keys are {@code Strings}, values are {@code Objects}. Lazily initialized by
* {@code getProperties()}.
*/
private Map<String, Object> properties;
@@ -65,4 +66,5 @@ public abstract class AbstractMessageContext implements MessageContext {
}
return properties;
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -37,13 +37,17 @@ public class DefaultMessageContext extends AbstractMessageContext {
private WebServiceMessage response;
/** Construct a new, empty instance of the {@code DefaultMessageContext} with the given message factory. */
/**
* Construct a new, empty instance of the {@code DefaultMessageContext} with the given
* message factory.
*/
public DefaultMessageContext(WebServiceMessageFactory messageFactory) {
this(messageFactory.createWebServiceMessage(), messageFactory);
}
/**
* Construct a new instance of the {@code DefaultMessageContext} with the given request message and message factory.
* Construct a new instance of the {@code DefaultMessageContext} with the given
* request message and message factory.
*/
public DefaultMessageContext(WebServiceMessage request, WebServiceMessageFactory messageFactory) {
Assert.notNull(request, "request must not be null");
@@ -96,4 +100,5 @@ public class DefaultMessageContext extends AbstractMessageContext {
throw new IllegalStateException("Response message already created");
}
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -25,11 +25,11 @@ import org.springframework.ws.server.EndpointInterceptor;
/**
* Context holder for message requests.
* <p>
* Contains both the message request as well as the response. Response message are usually lazily created (but do not
* have to be).
* Contains both the message request as well as the response. Response message are usually
* lazily created (but do not have to be).
* <p>
* Also contains properties, which can be used to by {@link EndpointInterceptor interceptors} to pass information on to
* endpoints.
* Also contains properties, which can be used to by {@link EndpointInterceptor
* interceptors} to pass information on to endpoints.
*
* @author Arjen Poutsma
* @since 1.0.0
@@ -38,21 +38,18 @@ public interface MessageContext {
/**
* Returns the request message.
*
* @return the request message
*/
WebServiceMessage getRequest();
/**
* Indicates whether this context has a response.
*
* @return {@code true} if this context has a response; {@code false} otherwise
*/
boolean hasResponse();
/**
* Returns the response message. Creates a new response if no response is present.
*
* @return the response message
* @see #hasResponse()
*/
@@ -60,7 +57,6 @@ public interface MessageContext {
/**
* Sets the response message.
*
* @param response the response message
* @throws IllegalStateException if a response has already been created
* @since 1.5.0
@@ -76,7 +72,6 @@ public interface MessageContext {
/**
* Reads a response message from the given input stream.
*
* @param inputStream the stream to read the response from
* @throws IOException in case of I/O errors
* @throws IllegalStateException if a response has already been created
@@ -84,9 +79,9 @@ public interface MessageContext {
void readResponse(InputStream inputStream) throws IOException;
/**
* Sets the name and value of a property associated with the {@code MessageContext}. If the {@code MessageContext}
* contains a value of the same property, the old value is replaced.
*
* Sets the name and value of a property associated with the {@code MessageContext}.
* If the {@code MessageContext} contains a value of the same property, the old value
* is replaced.
* @param name name of the property associated with the value
* @param value value of the property
*/
@@ -94,7 +89,6 @@ public interface MessageContext {
/**
* Gets the value of a specific property from the {@code MessageContext}.
*
* @param name name of the property whose value is to be retrieved
* @return value of the property
*/
@@ -102,23 +96,22 @@ public interface MessageContext {
/**
* Removes a property from the {@code MessageContext}.
*
* @param name name of the property to be removed
*/
void removeProperty(String name);
/**
* Check if this message context contains a property with the given name.
*
* @param name the name of the property to look for
* @return {@code true} if the {@code MessageContext} contains the property; {@code false} otherwise
* @return {@code true} if the {@code MessageContext} contains the property;
* {@code false} otherwise
*/
boolean containsProperty(String name);
/**
* Return the names of all properties in this {@code MessageContext}.
*
* @return the names of all properties in this context, or an empty array if none defined
* @return the names of all properties in this context, or an empty array if none
* defined
*/
String[] getPropertyNames();

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -16,21 +16,22 @@
package org.springframework.ws.mime;
import jakarta.activation.DataHandler;
import jakarta.activation.DataSource;
import jakarta.activation.FileDataSource;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import jakarta.activation.DataHandler;
import jakarta.activation.DataSource;
import jakarta.activation.FileDataSource;
import org.springframework.core.io.InputStreamSource;
import org.springframework.core.io.Resource;
import org.springframework.util.Assert;
/**
* Abstract implementation of the {@link MimeMessage} interface. Contains convenient default implementations.
* Abstract implementation of the {@link MimeMessage} interface. Contains convenient
* default implementations.
*
* @author Arjen Poutsma
* @since 1.0.0
@@ -58,7 +59,8 @@ public abstract class AbstractMimeMessage implements MimeMessage {
}
/**
* Activation framework {@code DataSource} that wraps a Spring {@code InputStreamSource}.
* Activation framework {@code DataSource} that wraps a Spring
* {@code InputStreamSource}.
*
* @author Arjen Poutsma
* @since 1.0.0
@@ -94,7 +96,8 @@ public abstract class AbstractMimeMessage implements MimeMessage {
if (inputStreamSource instanceof Resource) {
Resource resource = (Resource) inputStreamSource;
return resource.getFilename();
} else {
}
else {
throw new UnsupportedOperationException("DataSource name not available");
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -16,11 +16,11 @@
package org.springframework.ws.mime;
import jakarta.activation.DataHandler;
import java.io.IOException;
import java.io.InputStream;
import jakarta.activation.DataHandler;
/**
* Represents an attachment to a {@link org.springframework.ws.mime.MimeMessage}
*
@@ -33,38 +33,36 @@ public interface Attachment {
/**
* Returns the content identifier of the attachment.
*
* @return the content id, or {@code null} if empty or not defined
*/
String getContentId();
/**
* Returns the content type of the attachment.
*
* @return the content type, or {@code null} if empty or not defined
*/
String getContentType();
/**
* Return an {@code InputStream} to read the contents of the attachment from. The user is responsible for closing the
* stream.
*
* Return an {@code InputStream} to read the contents of the attachment from. The user
* is responsible for closing the stream.
* @return the contents of the file as stream, or an empty stream if empty
* @throws IOException in case of access I/O errors
*/
InputStream getInputStream() throws IOException;
/**
* Returns the size of the attachment in bytes. Returns {@code -1} if the size cannot be determined.
*
* @return the size of the attachment, {@code 0} if empty, or {@code -1} if the size cannot be determined
* Returns the size of the attachment in bytes. Returns {@code -1} if the size cannot
* be determined.
* @return the size of the attachment, {@code 0} if empty, or {@code -1} if the size
* cannot be determined
*/
long getSize();
/**
* Returns the data handler of the attachment.
*
* @return the data handler of the attachment
*/
DataHandler getDataHandler();
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -16,17 +16,17 @@
package org.springframework.ws.mime;
import jakarta.activation.DataHandler;
import java.io.File;
import java.util.Iterator;
import jakarta.activation.DataHandler;
import org.springframework.core.io.InputStreamSource;
import org.springframework.ws.WebServiceMessage;
/**
* Represents a Web service message with MIME attachments. Attachments can be added as a file, an
* {@link InputStreamSource}, or a {@link DataHandler}.
* Represents a Web service message with MIME attachments. Attachments can be added as a
* file, an {@link InputStreamSource}, or a {@link DataHandler}.
*
* @author Arjen Poutsma
* @see Attachment
@@ -36,33 +36,33 @@ public interface MimeMessage extends WebServiceMessage {
/**
* Indicates whether this message is a XOP package.
*
* @return {@code true} when the constraints specified in
* <a href="http://www.w3.org/TR/2005/REC-xop10-20050125/#identifying_xop_documents">Identifying XOP
* Documents</a> are met.
* @see <a href="http://www.w3.org/TR/2005/REC-xop10-20050125/#xop_packages">XOP Packages</a>
* @return {@code true} when the constraints specified in <a href=
* "http://www.w3.org/TR/2005/REC-xop10-20050125/#identifying_xop_documents">Identifying
* XOP Documents</a> are met.
* @see <a href="http://www.w3.org/TR/2005/REC-xop10-20050125/#xop_packages">XOP
* Packages</a>
*/
boolean isXopPackage();
/**
* Turns this message into a XOP package.
*
* @return {@code true} when the message is a XOP package
* @see <a href="http://www.w3.org/TR/2005/REC-xop10-20050125/#xop_packages">XOP Packages</a>
* @see <a href="http://www.w3.org/TR/2005/REC-xop10-20050125/#xop_packages">XOP
* Packages</a>
*/
boolean convertToXopPackage();
/**
* Returns the {@link Attachment} with the specified content Id.
*
* @return the attachment with the specified content id; or {@code null} if it cannot be found
* @return the attachment with the specified content id; or {@code null} if it cannot
* be found
* @throws AttachmentException in case of errors
*/
Attachment getAttachment(String contentId) throws AttachmentException;
/**
* Returns an {@code Iterator} over all {@link Attachment} objects that are part of this message.
*
* Returns an {@code Iterator} over all {@link Attachment} objects that are part of
* this message.
* @return an iterator over all attachments
* @throws AttachmentException in case of errors
* @see Attachment
@@ -72,9 +72,9 @@ public interface MimeMessage extends WebServiceMessage {
/**
* Add an attachment to the message, taking the content from a {@link File}.
* <p>
* The content type will be determined by the name of the given content file. Do not use this for temporary files with
* arbitrary filenames (possibly ending in ".tmp" or the like)!
*
* The content type will be determined by the name of the given content file. Do not
* use this for temporary files with arbitrary filenames (possibly ending in ".tmp" or
* the like)!
* @param contentId the content Id of the attachment
* @param file the file to take the content from
* @return the added attachment
@@ -83,14 +83,15 @@ public interface MimeMessage extends WebServiceMessage {
Attachment addAttachment(String contentId, File file) throws AttachmentException;
/**
* Add an attachment to the message, taking the content from an {@link InputStreamSource}.
* Add an attachment to the message, taking the content from an
* {@link InputStreamSource}.
* <p>
* Note that the stream returned by the source needs to be a <em>fresh one on each call</em>, as underlying
* implementations can invoke {@link InputStreamSource#getInputStream()} multiple times.
*
* Note that the stream returned by the source needs to be a <em>fresh one on each
* call</em>, as underlying implementations can invoke
* {@link InputStreamSource#getInputStream()} multiple times.
* @param contentId the content Id of the attachment
* @param inputStreamSource the resource to take the content from (all of Spring's Resource implementations can be
* passed in here)
* @param inputStreamSource the resource to take the content from (all of Spring's
* Resource implementations can be passed in here)
* @param contentType the content type to use for the element
* @return the added attachment
* @throws AttachmentException in case of errors
@@ -100,10 +101,10 @@ public interface MimeMessage extends WebServiceMessage {
/**
* Add an attachment to the message, taking the content from a {@link DataHandler}.
*
* @param dataHandler the data handler to take the content from
* @return the added attachment
* @throws AttachmentException in case of errors
*/
Attachment addAttachment(String contentId, DataHandler dataHandler);
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -34,4 +34,5 @@ public abstract class PoxMessageException extends WebServiceMessageException {
public PoxMessageException(String msg, Throwable ex) {
super(msg, ex);
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -27,14 +27,15 @@ import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.springframework.util.Assert;
import org.springframework.ws.pox.PoxMessage;
import org.springframework.ws.transport.TransportConstants;
import org.springframework.ws.transport.TransportOutputStream;
import org.springframework.xml.namespace.QNameUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
/**
* Implementation of the {@code PoxMessage} interface that is based on a DOM Document.
@@ -53,7 +54,6 @@ public class DomPoxMessage implements PoxMessage {
/**
* Constructs a new instance of the {@code DomPoxMessage} with the given document.
*
* @param document the document to base the message on
*/
public DomPoxMessage(Document document, Transformer transformer, String contentType) {
@@ -110,8 +110,10 @@ public class DomPoxMessage implements PoxMessage {
transportOutputStream.addHeader(TransportConstants.HEADER_CONTENT_TYPE, contentType);
}
transformer.transform(getPayloadSource(), new StreamResult(outputStream));
} catch (TransformerException ex) {
}
catch (TransformerException ex) {
throw new DomPoxMessageException("Could write document: " + ex.getMessage(), ex);
}
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -34,4 +34,5 @@ public class DomPoxMessageException extends PoxMessageException {
public DomPoxMessageException(String msg, Throwable ex) {
super(msg, ex);
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -24,15 +24,17 @@ import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerConfigurationException;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
import org.springframework.util.Assert;
import org.springframework.ws.WebServiceMessageFactory;
import org.springframework.xml.DocumentBuilderFactoryUtils;
import org.springframework.xml.transform.TransformerObjectSupport;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
/**
* Implementation of the {@link WebServiceMessageFactory} interface that creates a {@link DomPoxMessage}.
* Implementation of the {@link WebServiceMessageFactory} interface that creates a
* {@link DomPoxMessage}.
*
* @author Arjen Poutsma
* @see org.springframework.ws.pox.dom.DomPoxMessage
@@ -56,7 +58,6 @@ public class DomPoxMessageFactory extends TransformerObjectSupport implements We
/**
* Provide your own {@link DocumentBuilderFactory}.
*
* @param documentBuilderFactory
*/
public DomPoxMessageFactory(DocumentBuilderFactory documentBuilderFactory) {
@@ -73,7 +74,10 @@ public class DomPoxMessageFactory extends TransformerObjectSupport implements We
this.contentType = contentType;
}
/** Set whether or not the XML parser should be XML namespace aware. Default is {@code true}. */
/**
* Set whether or not the XML parser should be XML namespace aware. Default is
* {@code true}.
*/
public void setNamespaceAware(boolean namespaceAware) {
documentBuilderFactory.setNamespaceAware(namespaceAware);
}
@@ -84,7 +88,8 @@ public class DomPoxMessageFactory extends TransformerObjectSupport implements We
}
/**
* Set if the XML parser should expand entity reference nodes. Default is {@code false}.
* Set if the XML parser should expand entity reference nodes. Default is
* {@code false}.
*/
public void setExpandEntityReferences(boolean expandEntityRef) {
documentBuilderFactory.setExpandEntityReferences(expandEntityRef);
@@ -96,9 +101,11 @@ public class DomPoxMessageFactory extends TransformerObjectSupport implements We
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document request = documentBuilder.newDocument();
return new DomPoxMessage(request, createTransformer(), contentType);
} catch (ParserConfigurationException ex) {
}
catch (ParserConfigurationException ex) {
throw new DomPoxMessageException("Could not create message context", ex);
} catch (TransformerConfigurationException ex) {
}
catch (TransformerConfigurationException ex) {
throw new DomPoxMessageException("Could not create transformer", ex);
}
}
@@ -109,12 +116,16 @@ public class DomPoxMessageFactory extends TransformerObjectSupport implements We
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document request = documentBuilder.parse(inputStream);
return new DomPoxMessage(request, createTransformer(), contentType);
} catch (ParserConfigurationException ex) {
}
catch (ParserConfigurationException ex) {
throw new DomPoxMessageException("Could not create message context", ex);
} catch (SAXException ex) {
}
catch (SAXException ex) {
throw new DomPoxMessageException("Could not parse request message", ex);
} catch (TransformerConfigurationException ex) {
}
catch (TransformerConfigurationException ex) {
throw new DomPoxMessageException("Could not create transformer", ex);
}
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -19,12 +19,13 @@ package org.springframework.ws.server;
import org.springframework.ws.context.MessageContext;
/**
* Interface that must be implemented for each endpoint type to handle a message request. This interface is used to
* allow the {@code MessageDispatcher} to be indefinitely extensible. It accesses all installed endpoints through this
* interface, meaning that is does not contain code specific to any endpoint type.
* Interface that must be implemented for each endpoint type to handle a message request.
* This interface is used to allow the {@code MessageDispatcher} to be indefinitely
* extensible. It accesses all installed endpoints through this interface, meaning that is
* does not contain code specific to any endpoint type.
* <p>
* This interface is not intended for application developers. It is available for those who want to develop their own
* message flow.
* This interface is not intended for application developers. It is available for those
* who want to develop their own message flow.
*
* @author Arjen Poutsma
* @see MessageDispatcher
@@ -36,19 +37,20 @@ public interface EndpointAdapter {
* Does this {@code EndpointAdapter} support the given {@code endpoint}?
* <p>
* Typical {@code EndpointAdapters} will base the decision on the endpoint type.
*
* @param endpoint endpoint object to check
* @return {@code true} if this {@code EndpointAdapter} supports the supplied {@code endpoint}
* @return {@code true} if this {@code EndpointAdapter} supports the supplied
* {@code endpoint}
*/
boolean supports(Object endpoint);
/**
* Use the given {@code endpoint} to handle the request.
*
* @param messageContext the current message context
* @param endpoint the endpoint to use. This object must have previously been passed to the {@link #supports(Object)}
* method of this interface, which must have returned {@code true}
* @param endpoint the endpoint to use. This object must have previously been passed
* to the {@link #supports(Object)} method of this interface, which must have returned
* {@code true}
* @throws Exception in case of errors
*/
void invoke(MessageContext messageContext, Object endpoint) throws Exception;
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -19,7 +19,8 @@ package org.springframework.ws.server;
import org.springframework.ws.context.MessageContext;
/**
* Defines the interface for objects than can resolve exceptions thrown during endpoint execution.
* Defines the interface for objects than can resolve exceptions thrown during endpoint
* execution.
*
* @author Arjen Poutsma
* @since 1.0.0
@@ -28,11 +29,12 @@ public interface EndpointExceptionResolver {
/**
* Try to resolve the given exception that got thrown during on endpoint execution.
*
* @param messageContext current message context
* @param endpoint the executed endpoint, or null if none chosen at the time of the exception
* @param endpoint the executed endpoint, or null if none chosen at the time of the
* exception
* @param ex the exception that got thrown during endpoint execution
* @return {@code true} if resolved; {@code false} otherwise
*/
boolean resolveException(MessageContext messageContext, Object endpoint, Exception ex);
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -19,18 +19,23 @@ package org.springframework.ws.server;
import org.springframework.ws.context.MessageContext;
/**
* Workflow interface that allows for customized endpoint invocation chains. Applications can register any number of
* existing or custom interceptors for certain groups of endpoints, to add common preprocessing behavior without needing
* to modify each endpoint implementation.
* Workflow interface that allows for customized endpoint invocation chains. Applications
* can register any number of existing or custom interceptors for certain groups of
* endpoints, to add common preprocessing behavior without needing to modify each endpoint
* implementation.
* <p>
* An {@code EndpointInterceptor} gets called before the appropriate {@link EndpointAdapter} triggers the invocation of
* the endpoint itself. This mechanism can be used for a large field of preprocessing aspects, e.g. for authorization
* checks, or message header checks. Its main purpose is to allow for factoring out repetitive endpoint code.
* An {@code EndpointInterceptor} gets called before the appropriate
* {@link EndpointAdapter} triggers the invocation of the endpoint itself. This mechanism
* can be used for a large field of preprocessing aspects, e.g. for authorization checks,
* or message header checks. Its main purpose is to allow for factoring out repetitive
* endpoint code.
* <p>
* Typically an interceptor chain is defined per {@link EndpointMapping} bean, sharing its granularity. To be able to
* apply a certain interceptor chain to a group of handlers, one needs to map the desired handlers via one
* {@code EndpointMapping} bean. The interceptors themselves are defined as beans in the application context, referenced
* by the mapping bean definition via its {@code interceptors} property (in XML: a &lt;list&gt; of &lt;ref&gt;).
* Typically an interceptor chain is defined per {@link EndpointMapping} bean, sharing its
* granularity. To be able to apply a certain interceptor chain to a group of handlers,
* one needs to map the desired handlers via one {@code EndpointMapping} bean. The
* interceptors themselves are defined as beans in the application context, referenced by
* the mapping bean definition via its {@code interceptors} property (in XML: a
* &lt;list&gt; of &lt;ref&gt;).
*
* @author Arjen Poutsma
* @see EndpointInvocationChain#getInterceptors()
@@ -41,36 +46,40 @@ import org.springframework.ws.context.MessageContext;
public interface EndpointInterceptor {
/**
* Processes the incoming request message. Called after {@link EndpointMapping} determined an appropriate endpoint
* object, but before {@link EndpointAdapter} invokes the endpoint.
* Processes the incoming request message. Called after {@link EndpointMapping}
* determined an appropriate endpoint object, but before {@link EndpointAdapter}
* invokes the endpoint.
* <p>
* {@link MessageDispatcher} processes an endpoint in an invocation chain, consisting of any number of interceptors,
* with the endpoint itself at the end. With this method, each interceptor can decide to abort the chain, typically
* creating a custom response.
*
* {@link MessageDispatcher} processes an endpoint in an invocation chain, consisting
* of any number of interceptors, with the endpoint itself at the end. With this
* method, each interceptor can decide to abort the chain, typically creating a custom
* response.
* @param messageContext contains the incoming request message
* @param endpoint chosen endpoint to invoke
* @return {@code true} to continue processing of the request interceptor chain; {@code false} to indicate blocking of
* the request endpoint chain, <em>without invoking the endpoint</em>
* @return {@code true} to continue processing of the request interceptor chain;
* {@code false} to indicate blocking of the request endpoint chain, <em>without
* invoking the endpoint</em>
* @throws Exception in case of errors
* @see MessageContext#getRequest()
*/
boolean handleRequest(MessageContext messageContext, Object endpoint) throws Exception;
/**
* Processes the outgoing response message. Called after {@link EndpointAdapter} actually invoked the endpoint. Can
* manipulate the response, if any, by adding new headers, etc.
* Processes the outgoing response message. Called after {@link EndpointAdapter}
* actually invoked the endpoint. Can manipulate the response, if any, by adding new
* headers, etc.
* <p>
* {@link MessageDispatcher} processes an endpoint in an invocation chain, consisting of any number of interceptors,
* with the endpoint itself at the end. With this method, each interceptor can post-process an invocation, getting
* applied in inverse order of the execution chain.
* {@link MessageDispatcher} processes an endpoint in an invocation chain, consisting
* of any number of interceptors, with the endpoint itself at the end. With this
* method, each interceptor can post-process an invocation, getting applied in inverse
* order of the execution chain.
* <p>
* Note: Will only be called if this interceptor's {@link #handleRequest} method has successfully completed.
*
* Note: Will only be called if this interceptor's {@link #handleRequest} method has
* successfully completed.
* @param messageContext contains both request and response messages
* @param endpoint chosen endpoint to invoke
* @return {@code true} to continue processing of the response interceptor chain; {@code false} to indicate blocking
* of the response endpoint chain.
* @return {@code true} to continue processing of the response interceptor chain;
* {@code false} to indicate blocking of the response endpoint chain.
* @throws Exception in case of errors
* @see MessageContext#getRequest()
* @see MessageContext#hasResponse()
@@ -79,36 +88,43 @@ public interface EndpointInterceptor {
boolean handleResponse(MessageContext messageContext, Object endpoint) throws Exception;
/**
* Processes the outgoing response fault. Called after {@link EndpointAdapter} actually invoked the endpoint. Can
* manipulate the response, if any, by adding new headers, etc.
* Processes the outgoing response fault. Called after {@link EndpointAdapter}
* actually invoked the endpoint. Can manipulate the response, if any, by adding new
* headers, etc.
* <p>
* {@link MessageDispatcher} processes an endpoint in an invocation chain, consisting of any number of interceptors,
* with the endpoint itself at the end. With this method, each interceptor can post-process an invocation, getting
* applied in inverse order of the execution chain.
* {@link MessageDispatcher} processes an endpoint in an invocation chain, consisting
* of any number of interceptors, with the endpoint itself at the end. With this
* method, each interceptor can post-process an invocation, getting applied in inverse
* order of the execution chain.
* <p>
* Note: Will only be called if this interceptor's {@link #handleRequest} method has successfully completed.
*
* @param messageContext contains both request and response messages, the response should contains a Fault
* Note: Will only be called if this interceptor's {@link #handleRequest} method has
* successfully completed.
* @param messageContext contains both request and response messages, the response
* should contains a Fault
* @param endpoint chosen endpoint to invoke
* @return {@code true} to continue processing of the response interceptor chain; {@code false} to indicate blocking
* of the response handler chain.
* @return {@code true} to continue processing of the response interceptor chain;
* {@code false} to indicate blocking of the response handler chain.
*/
boolean handleFault(MessageContext messageContext, Object endpoint) throws Exception;
/**
* Callback after completion of request and response (fault) processing. Will be called on any outcome of endpoint
* invocation, thus allows for proper resource cleanup.
* Callback after completion of request and response (fault) processing. Will be
* called on any outcome of endpoint invocation, thus allows for proper resource
* cleanup.
* <p>
* Note: Will only be called if this interceptor's {@link #handleRequest} method has successfully completed.
* Note: Will only be called if this interceptor's {@link #handleRequest} method has
* successfully completed.
* <p>
* As with the {@link #handleResponse} method, the method will be invoked on each interceptor in the chain in reverse
* order, so the first interceptor will be the last to be invoked.
*
* @param messageContext contains both request and response messages, the response should contains a Fault
* As with the {@link #handleResponse} method, the method will be invoked on each
* interceptor in the chain in reverse order, so the first interceptor will be the
* last to be invoked.
* @param messageContext contains both request and response messages, the response
* should contains a Fault
* @param endpoint chosen endpoint to invoke
* @param ex exception thrown on handler execution, if any
* @throws Exception in case of errors
* @since 2.0.2
*/
void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex) throws Exception;
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -17,7 +17,8 @@
package org.springframework.ws.server;
/**
* Endpoint invocation chain, consisting of an endpoint object and any preprocessing interceptors.
* Endpoint invocation chain, consisting of an endpoint object and any preprocessing
* interceptors.
*
* @author Arjen Poutsma
* @see EndpointInterceptor
@@ -31,7 +32,6 @@ public class EndpointInvocationChain {
/**
* Create new {@code EndpointInvocationChain}.
*
* @param endpoint the endpoint object to invoke
*/
public EndpointInvocationChain(Object endpoint) {
@@ -40,7 +40,6 @@ public class EndpointInvocationChain {
/**
* Create new {@code EndpointInvocationChain}.
*
* @param endpoint the endpoint object to invoke
* @param interceptors the array of interceptors to apply
*/
@@ -51,7 +50,6 @@ public class EndpointInvocationChain {
/**
* Returns the endpoint object to invoke.
*
* @return the endpoint object
*/
public Object getEndpoint() {
@@ -60,7 +58,6 @@ public class EndpointInvocationChain {
/**
* Returns the array of interceptors to apply before the handler executes.
*
* @return the array of interceptors
*/
public EndpointInterceptor[] getInterceptors() {

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -21,13 +21,16 @@ import org.springframework.ws.context.MessageContext;
/**
* Defines a mapping between message requests and endpoint objects.
* <p>
* This class can be implemented by application developers, although this is not always necessary, as
* {@code PayloadRootQNameEndpointMapping} and {@code SoapActionEndpointMapping} are included.
* This class can be implemented by application developers, although this is not always
* necessary, as {@code PayloadRootQNameEndpointMapping} and
* {@code SoapActionEndpointMapping} are included.
* <p>
* HandlerMapping implementations can support mapped interceptors but do not have to. An endpoint will always be wrapped
* in a {@code EndpointExecutionChain} instance, optionally accompanied by some {@code EndpointInterceptor} instances.
* The {@code MessageDispacher} will first call each {@code EndpointInterceptor}'s {@code handlerRequest} method in the
* given order, finally invoking the endpoint itself if all {@code handlerRequest} methods have returned {@code true}.
* HandlerMapping implementations can support mapped interceptors but do not have to. An
* endpoint will always be wrapped in a {@code EndpointExecutionChain} instance,
* optionally accompanied by some {@code EndpointInterceptor} instances. The
* {@code MessageDispacher} will first call each {@code EndpointInterceptor}'s
* {@code handlerRequest} method in the given order, finally invoking the endpoint itself
* if all {@code handlerRequest} methods have returned {@code true}.
*
* @author Arjen Poutsma
* @see org.springframework.ws.server.endpoint.mapping.AbstractEndpointMapping
@@ -38,19 +41,20 @@ import org.springframework.ws.context.MessageContext;
public interface EndpointMapping {
/**
* Returns an endpoint and any interceptors for this message context. The choice may be made on message contents,
* transport request url, a routing table, or any factor the implementing class chooses.
* Returns an endpoint and any interceptors for this message context. The choice may
* be made on message contents, transport request url, a routing table, or any factor
* the implementing class chooses.
* <p>
* The returned {@code EndpointExecutionChain} contains an endpoint Object, rather than even a tag interface, so that
* endpoints are not constrained in any way. For example, a {@code EndpointAdapter} could be written to allow another
* framework's endpoint objects to be used.
* The returned {@code EndpointExecutionChain} contains an endpoint Object, rather
* than even a tag interface, so that endpoints are not constrained in any way. For
* example, a {@code EndpointAdapter} could be written to allow another framework's
* endpoint objects to be used.
* <p>
* Returns {@code null} if no match was found. This is by design. The {@code MessageDispatcher} will query all
* registered {@code EndpointMapping} beans to find a match, and only decide there is an error if none can find an
* endpoint.
*
* @return a HandlerExecutionChain instance containing endpoint object and any interceptors, or {@code null} if no
* mapping is found
* Returns {@code null} if no match was found. This is by design. The
* {@code MessageDispatcher} will query all registered {@code EndpointMapping} beans
* to find a match, and only decide there is an error if none can find an endpoint.
* @return a HandlerExecutionChain instance containing endpoint object and any
* interceptors, or {@code null} if no mapping is found
* @throws Exception if there is an internal error
*/
EndpointInvocationChain getEndpoint(MessageContext messageContext) throws Exception;

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -25,6 +25,7 @@ import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactoryUtils;
import org.springframework.beans.factory.BeanNameAware;
@@ -47,24 +48,29 @@ import org.springframework.ws.support.DefaultStrategiesHelper;
import org.springframework.ws.transport.WebServiceMessageReceiver;
/**
* Central dispatcher for use within Spring-WS, dispatching Web service messages to registered endpoints.
* Central dispatcher for use within Spring-WS, dispatching Web service messages to
* registered endpoints.
* <p>
* This dispatcher is quite similar to Spring MVCs {@link DispatcherServlet}. Just like its counterpart, this dispatcher
* is very flexible. This class is SOAP agnostic; in typical SOAP Web Services, the {@link SoapMessageDispatcher}
* subclass is used.
* This dispatcher is quite similar to Spring MVCs {@link DispatcherServlet}. Just like
* its counterpart, this dispatcher is very flexible. This class is SOAP agnostic; in
* typical SOAP Web Services, the {@link SoapMessageDispatcher} subclass is used.
* <ul>
* <li>It can use any {@link EndpointMapping} implementation - whether standard, or provided as part of an application -
* to control the routing of request messages to endpoint objects. Endpoint mappings can be registered using the
* <li>It can use any {@link EndpointMapping} implementation - whether standard, or
* provided as part of an application - to control the routing of request messages to
* endpoint objects. Endpoint mappings can be registered using the
* {@link #setEndpointMappings(List) endpointMappings} property.</li>
* <li>It can use any {@link EndpointAdapter}; this allows one to use any endpoint interface or form. Defaults to the
* {@link MessageEndpointAdapter} and {@link PayloadEndpointAdapter}, for {@link MessageEndpoint} and
* <li>It can use any {@link EndpointAdapter}; this allows one to use any endpoint
* interface or form. Defaults to the {@link MessageEndpointAdapter} and
* {@link PayloadEndpointAdapter}, for {@link MessageEndpoint} and
* {@link PayloadEndpoint}, respectively, and the
* {@link org.springframework.ws.server.endpoint.adapter.MessageMethodEndpointAdapter MessageMethodEndpointAdapter} and
* {@link org.springframework.ws.server.endpoint.adapter.PayloadMethodEndpointAdapter PayloadMethodEndpointAdapter}.
* Additional endpoint adapters can be added through the {@link #setEndpointAdapters(List) endpointAdapters}
* property.</li>
* <li>Its exception resolution strategy can be specified via a {@link EndpointExceptionResolver}, for example mapping
* certain exceptions to SOAP Faults. Default is none. Additional exception resolvers can be added through the
* {@link org.springframework.ws.server.endpoint.adapter.MessageMethodEndpointAdapter
* MessageMethodEndpointAdapter} and
* {@link org.springframework.ws.server.endpoint.adapter.PayloadMethodEndpointAdapter
* PayloadMethodEndpointAdapter}. Additional endpoint adapters can be added through the
* {@link #setEndpointAdapters(List) endpointAdapters} property.</li>
* <li>Its exception resolution strategy can be specified via a
* {@link EndpointExceptionResolver}, for example mapping certain exceptions to SOAP
* Faults. Default is none. Additional exception resolvers can be added through the
* {@link #setEndpointExceptionResolvers(List) endpointExceptionResolvers} property.</li>
* </ul>
*
@@ -85,18 +91,18 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa
/** Additional logger to use when no mapped endpoint is found for a request. */
protected static final Log endpointNotFoundLogger = LogFactory
.getLog(MessageDispatcher.ENDPOINT_NOT_FOUND_LOG_CATEGORY);
.getLog(MessageDispatcher.ENDPOINT_NOT_FOUND_LOG_CATEGORY);
/** Log category to use for message tracing. */
public static final String MESSAGE_TRACING_LOG_CATEGORY = "org.springframework.ws.server.MessageTracing";
/** Additional logger to use for sent message tracing. */
protected static final Log sentMessageTracingLogger = LogFactory
.getLog(MessageDispatcher.MESSAGE_TRACING_LOG_CATEGORY + ".sent");
.getLog(MessageDispatcher.MESSAGE_TRACING_LOG_CATEGORY + ".sent");
/** Additional logger to use for received message tracing. */
protected static final Log receivedMessageTracingLogger = LogFactory
.getLog(MessageDispatcher.MESSAGE_TRACING_LOG_CATEGORY + ".received");
.getLog(MessageDispatcher.MESSAGE_TRACING_LOG_CATEGORY + ".received");
private final DefaultStrategiesHelper defaultStrategiesHelper;
@@ -127,12 +133,18 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa
this.endpointAdapters = endpointAdapters;
}
/** Returns the {@code EndpointExceptionResolver}s to use by this {@code MessageDispatcher}. */
/**
* Returns the {@code EndpointExceptionResolver}s to use by this
* {@code MessageDispatcher}.
*/
public List<EndpointExceptionResolver> getEndpointExceptionResolvers() {
return endpointExceptionResolvers;
}
/** Sets the {@code EndpointExceptionResolver}s to use by this {@code MessageDispatcher}. */
/**
* Sets the {@code EndpointExceptionResolver}s to use by this
* {@code MessageDispatcher}.
*/
public void setEndpointExceptionResolvers(List<EndpointExceptionResolver> endpointExceptionResolvers) {
this.endpointExceptionResolvers = endpointExceptionResolvers;
}
@@ -161,14 +173,16 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa
@Override
public void receive(MessageContext messageContext) throws Exception {
// Let's keep a reference to the request content as it came in, it might be changed by interceptors in dispatch()
// Let's keep a reference to the request content as it came in, it might be
// changed by interceptors in dispatch()
String requestContent = "";
if (receivedMessageTracingLogger.isTraceEnabled() || sentMessageTracingLogger.isTraceEnabled()) {
requestContent = getMessageContent(messageContext.getRequest());
}
if (receivedMessageTracingLogger.isTraceEnabled()) {
receivedMessageTracingLogger.trace("Received request [" + requestContent + "]");
} else if (receivedMessageTracingLogger.isDebugEnabled()) {
}
else if (receivedMessageTracingLogger.isDebugEnabled()) {
receivedMessageTracingLogger.debug("Received request [" + messageContext.getRequest() + "]");
}
dispatch(messageContext);
@@ -176,14 +190,17 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa
WebServiceMessage response = messageContext.getResponse();
if (sentMessageTracingLogger.isTraceEnabled()) {
String responseContent = getMessageContent(response);
sentMessageTracingLogger.trace("Sent response [" + responseContent + "] for request [" + requestContent + "]");
} else if (sentMessageTracingLogger.isDebugEnabled()) {
sentMessageTracingLogger
.debug("Sent response [" + response + "] for request [" + messageContext.getRequest() + "]");
.trace("Sent response [" + responseContent + "] for request [" + requestContent + "]");
}
} else if (sentMessageTracingLogger.isDebugEnabled()) {
sentMessageTracingLogger.debug("MessageDispatcher with name '" + beanName + "' sends no response for request ["
+ messageContext.getRequest() + "]");
else if (sentMessageTracingLogger.isDebugEnabled()) {
sentMessageTracingLogger
.debug("Sent response [" + response + "] for request [" + messageContext.getRequest() + "]");
}
}
else if (sentMessageTracingLogger.isDebugEnabled()) {
sentMessageTracingLogger.debug("MessageDispatcher with name '" + beanName
+ "' sends no response for request [" + messageContext.getRequest() + "]");
}
}
@@ -195,10 +212,9 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa
/**
* Dispatches the request in the given MessageContext according to the configuration.
*
* @param messageContext the message context
* @throws org.springframework.ws.NoEndpointFoundException thrown when an endpoint cannot be resolved for the incoming
* message
* @throws org.springframework.ws.NoEndpointFoundException thrown when an endpoint
* cannot be resolved for the incoming message
*/
protected final void dispatch(MessageContext messageContext) throws Exception {
EndpointInvocationChain mappedEndpoint = null;
@@ -231,21 +247,25 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa
// Apply handleResponse methods of registered interceptors
triggerHandleResponse(mappedEndpoint, interceptorIndex, messageContext);
} catch (NoEndpointFoundException ex) {
}
catch (NoEndpointFoundException ex) {
// No triggering of interceptors if no endpoint is found
if (endpointNotFoundLogger.isWarnEnabled()) {
endpointNotFoundLogger.warn("No endpoint mapping found for [" + messageContext.getRequest() + "]");
}
throw ex;
} catch (Exception ex) {
}
catch (Exception ex) {
Object endpoint = mappedEndpoint != null ? mappedEndpoint.getEndpoint() : null;
processEndpointException(messageContext, endpoint, ex);
triggerHandleResponse(mappedEndpoint, interceptorIndex, messageContext);
}
triggerAfterCompletion(mappedEndpoint, interceptorIndex, messageContext, null);
} catch (NoEndpointFoundException ex) {
}
catch (NoEndpointFoundException ex) {
throw ex;
} catch (Exception ex) {
}
catch (Exception ex) {
// Trigger after-completion for thrown exception.
triggerAfterCompletion(mappedEndpoint, interceptorIndex, messageContext, ex);
throw ex;
@@ -254,19 +274,20 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa
/**
* Returns the endpoint for this request. All endpoint mappings are tried, in order.
*
* @return the {@code EndpointInvocationChain}, or {@code null} if no endpoint could be found.
* @return the {@code EndpointInvocationChain}, or {@code null} if no endpoint could
* be found.
*/
protected EndpointInvocationChain getEndpoint(MessageContext messageContext) throws Exception {
for (EndpointMapping endpointMapping : getEndpointMappings()) {
EndpointInvocationChain endpoint = endpointMapping.getEndpoint(messageContext);
if (endpoint != null) {
if (logger.isDebugEnabled()) {
logger.debug(
"Endpoint mapping [" + endpointMapping + "] maps request to endpoint [" + endpoint.getEndpoint() + "]");
logger.debug("Endpoint mapping [" + endpointMapping + "] maps request to endpoint ["
+ endpoint.getEndpoint() + "]");
}
return endpoint;
} else if (logger.isDebugEnabled()) {
}
else if (logger.isDebugEnabled()) {
logger.debug("Endpoint mapping [" + endpointMapping + "] has no mapping for request");
}
}
@@ -275,7 +296,6 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa
/**
* Returns the {@code EndpointAdapter} for the given endpoint.
*
* @param endpoint the endpoint to find an adapter for
* @return the adapter
*/
@@ -293,11 +313,10 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa
}
/**
* Callback for pre-processing of given invocation chain and message context. Gets called before invocation of
* {@code handleRequest} on the interceptors.
* Callback for pre-processing of given invocation chain and message context. Gets
* called before invocation of {@code handleRequest} on the interceptors.
* <p>
* Default implementation does nothing, and returns {@code true}.
*
* @param mappedEndpoint the mapped {@code EndpointInvocationChain}
* @param messageContext the message context
* @return {@code true} if processing should continue; {@code false} otherwise
@@ -307,11 +326,12 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa
}
/**
* Determine an error {@code SOAPMessage} response via the registered {@code EndpointExceptionResolvers}. Most likely,
* the response contains a {@code SOAPFault}. If no suitable resolver was found, the exception is rethrown.
*
* Determine an error {@code SOAPMessage} response via the registered
* {@code EndpointExceptionResolvers}. Most likely, the response contains a
* {@code SOAPFault}. If no suitable resolver was found, the exception is rethrown.
* @param messageContext current SOAPMessage request
* @param endpoint the executed endpoint, or null if none chosen at the time of the exception
* @param endpoint the executed endpoint, or null if none chosen at the time of the
* exception
* @param ex the exception that got thrown during handler execution
* @throws Exception if no suitable resolver is found
*/
@@ -332,10 +352,9 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa
}
/**
* Trigger handleResponse or handleFault on the mapped EndpointInterceptors. Will just invoke said method on all
* interceptors whose handleRequest invocation returned {@code true}, in addition to the last interceptor who returned
* {@code false}.
*
* Trigger handleResponse or handleFault on the mapped EndpointInterceptors. Will just
* invoke said method on all interceptors whose handleRequest invocation returned
* {@code true}, in addition to the last interceptor who returned {@code false}.
* @param mappedEndpoint the mapped EndpointInvocationChain
* @param interceptorIndex index of last interceptor that was called
* @param messageContext the message context, whose request and response are filled
@@ -356,7 +375,8 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa
EndpointInterceptor interceptor = mappedEndpoint.getInterceptors()[i];
if (!hasFault) {
resume = interceptor.handleResponse(messageContext, mappedEndpoint.getEndpoint());
} else {
}
else {
resume = interceptor.handleFault(messageContext, mappedEndpoint.getEndpoint());
}
}
@@ -364,10 +384,10 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa
}
/**
* Trigger afterCompletion callbacks on the mapped EndpointInterceptors. Will just invoke afterCompletion for all
* interceptors whose handleRequest invocation has successfully completed and returned true, in addition to the last
* interceptor who returned {@code false}.
*
* Trigger afterCompletion callbacks on the mapped EndpointInterceptors. Will just
* invoke afterCompletion for all interceptors whose handleRequest invocation has
* successfully completed and returned true, in addition to the last interceptor who
* returned {@code false}.
* @param mappedEndpoint the mapped EndpointInvocationChain
* @param interceptorIndex index of last interceptor that successfully completed
* @param ex Exception thrown on handler execution, or {@code null} if none
@@ -384,7 +404,8 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa
EndpointInterceptor interceptor = interceptors[i];
try {
interceptor.afterCompletion(messageContext, mappedEndpoint.getEndpoint(), ex);
} catch (Throwable ex2) {
}
catch (Throwable ex2) {
logger.error("EndpointInterceptor.afterCompletion threw exception", ex2);
}
}
@@ -393,20 +414,22 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa
}
/**
* Initialize the {@code EndpointAdapters} used by this class. If no adapter beans are explicitly set by using the
* {@code endpointAdapters} property, we use the default strategies.
*
* Initialize the {@code EndpointAdapters} used by this class. If no adapter beans are
* explicitly set by using the {@code endpointAdapters} property, we use the default
* strategies.
* @see #setEndpointAdapters(java.util.List)
*/
private void initEndpointAdapters(ApplicationContext applicationContext) throws BeansException {
if (endpointAdapters == null) {
Map<String, EndpointAdapter> matchingBeans = BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext,
EndpointAdapter.class, true, false);
Map<String, EndpointAdapter> matchingBeans = BeanFactoryUtils
.beansOfTypeIncludingAncestors(applicationContext, EndpointAdapter.class, true, false);
if (!matchingBeans.isEmpty()) {
endpointAdapters = new ArrayList<>(matchingBeans.values());
endpointAdapters.sort(new OrderComparator());
} else {
endpointAdapters = defaultStrategiesHelper.getDefaultStrategies(EndpointAdapter.class, applicationContext);
}
else {
endpointAdapters = defaultStrategiesHelper.getDefaultStrategies(EndpointAdapter.class,
applicationContext);
if (logger.isDebugEnabled()) {
logger.debug("No EndpointAdapters found, using defaults");
}
@@ -415,21 +438,22 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa
}
/**
* Initialize the {@code EndpointExceptionResolver} used by this class. If no resolver beans are explicitly set by
* using the {@code endpointExceptionResolvers} property, we use the default strategies.
*
* Initialize the {@code EndpointExceptionResolver} used by this class. If no resolver
* beans are explicitly set by using the {@code endpointExceptionResolvers} property,
* we use the default strategies.
* @see #setEndpointExceptionResolvers(java.util.List)
*/
private void initEndpointExceptionResolvers(ApplicationContext applicationContext) throws BeansException {
if (endpointExceptionResolvers == null) {
Map<String, EndpointExceptionResolver> matchingBeans = BeanFactoryUtils
.beansOfTypeIncludingAncestors(applicationContext, EndpointExceptionResolver.class, true, false);
.beansOfTypeIncludingAncestors(applicationContext, EndpointExceptionResolver.class, true, false);
if (!matchingBeans.isEmpty()) {
endpointExceptionResolvers = new ArrayList<>(matchingBeans.values());
endpointExceptionResolvers.sort(new OrderComparator());
} else {
endpointExceptionResolvers = defaultStrategiesHelper.getDefaultStrategies(EndpointExceptionResolver.class,
applicationContext);
}
else {
endpointExceptionResolvers = defaultStrategiesHelper
.getDefaultStrategies(EndpointExceptionResolver.class, applicationContext);
if (logger.isDebugEnabled()) {
logger.debug("No EndpointExceptionResolvers found, using defaults");
}
@@ -438,24 +462,27 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa
}
/**
* Initialize the {@code EndpointMappings} used by this class. If no mapping beans are explictely set by using the
* {@code endpointMappings} property, we use the default strategies.
*
* Initialize the {@code EndpointMappings} used by this class. If no mapping beans are
* explictely set by using the {@code endpointMappings} property, we use the default
* strategies.
* @see #setEndpointMappings(java.util.List)
*/
private void initEndpointMappings(ApplicationContext applicationContext) throws BeansException {
if (endpointMappings == null) {
Map<String, EndpointMapping> matchingBeans = BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext,
EndpointMapping.class, true, false);
Map<String, EndpointMapping> matchingBeans = BeanFactoryUtils
.beansOfTypeIncludingAncestors(applicationContext, EndpointMapping.class, true, false);
if (!matchingBeans.isEmpty()) {
endpointMappings = new ArrayList<>(matchingBeans.values());
endpointMappings.sort(new OrderComparator());
} else {
endpointMappings = defaultStrategiesHelper.getDefaultStrategies(EndpointMapping.class, applicationContext);
}
else {
endpointMappings = defaultStrategiesHelper.getDefaultStrategies(EndpointMapping.class,
applicationContext);
if (logger.isDebugEnabled()) {
logger.debug("No EndpointMappings found, using defaults");
}
}
}
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -19,8 +19,8 @@ package org.springframework.ws.server;
import org.springframework.ws.context.MessageContext;
/**
* Extension of the {@link EndpointInterceptor} interface that adds a way to decide whether the interceptor should
* intercept a given message context.
* Extension of the {@link EndpointInterceptor} interface that adds a way to decide
* whether the interceptor should intercept a given message context.
*
* @author Arjen Poutsma
* @since 2.0
@@ -29,10 +29,10 @@ public interface SmartEndpointInterceptor extends EndpointInterceptor {
/**
* Indicates whether this interceptor should intercept the given message context.
*
* @param messageContext contains the incoming request message
* @param endpoint chosen endpoint to invoke
* @return {@code true} to indicate that this interceptor applies; {@code false} otherwise
* @return {@code true} to indicate that this interceptor applies; {@code false}
* otherwise
*/
boolean shouldIntercept(MessageContext messageContext, Object endpoint);

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -26,15 +26,17 @@ import org.dom4j.Element;
import org.dom4j.io.DOMReader;
import org.dom4j.io.DocumentResult;
import org.dom4j.io.DocumentSource;
import org.springframework.xml.transform.TransformerObjectSupport;
import org.w3c.dom.Node;
import org.springframework.xml.transform.TransformerObjectSupport;
/**
* Abstract base class for endpoints that handle the message payload as dom4j elements. Offers the message payload as a
* dom4j {@code Element}, and allows subclasses to create a response by returning an {@code Element}.
* Abstract base class for endpoints that handle the message payload as dom4j elements.
* Offers the message payload as a dom4j {@code Element}, and allows subclasses to create
* a response by returning an {@code Element}.
* <p>
* An {@code AbstractDom4JPayloadEndpoint} only accept one payload element. Multiple payload elements are not in
* accordance with WS-I.
* An {@code AbstractDom4JPayloadEndpoint} only accept one payload element. Multiple
* payload elements are not in accordance with WS-I.
*
* @author Arjen Poutsma
* @see org.dom4j.Element
@@ -47,7 +49,8 @@ public abstract class AbstractDom4jPayloadEndpoint extends TransformerObjectSupp
private boolean alwaysTransform = false;
/**
* Set if the request {@link Source} should always be transformed into a new {@link DocumentResult}.
* Set if the request {@link Source} should always be transformed into a new
* {@link DocumentResult}.
* <p>
* Default is {@code false}, which is faster.
*/
@@ -71,12 +74,13 @@ public abstract class AbstractDom4jPayloadEndpoint extends TransformerObjectSupp
/**
* Returns the payload element of the given source.
* <p>
* 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
* 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
@@ -100,14 +104,15 @@ public abstract class AbstractDom4jPayloadEndpoint extends TransformerObjectSupp
}
/**
* Template method. Subclasses must implement this. Offers the request payload as a dom4j {@code Element}, and allows
* subclasses to return a response {@code Element}.
* Template method. Subclasses must implement this. Offers the request payload as a
* dom4j {@code Element}, and allows subclasses to return a response {@code Element}.
* <p>
* The given dom4j {@code Document} is to be used for constructing a response element, by using {@code addElement}.
*
* 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;
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -24,20 +24,21 @@ import javax.xml.transform.TransformerException;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
import org.springframework.xml.DocumentBuilderFactoryUtils;
import org.springframework.xml.transform.TransformerObjectSupport;
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.
* <p>
* Offers the message payload as a DOM {@code Element}, and allows subclasses to create a response by returning an
* {@code Element}.
* Offers the message payload as a DOM {@code Element}, and allows subclasses to create a
* response by returning an {@code Element}.
* <p>
* An {@code AbstractDomPayloadEndpoint} only accept <em>one</em> payload element. Multiple payload elements are not in
* accordance with WS-I.
* An {@code AbstractDomPayloadEndpoint} only accept <em>one</em> payload element.
* Multiple payload elements are not in accordance with WS-I.
*
* @author Arjen Poutsma
* @author Alef Arendsen
@@ -58,7 +59,10 @@ public abstract class AbstractDomPayloadEndpoint extends TransformerObjectSuppor
private boolean alwaysTransform = false;
/** Set whether or not the XML parser should be XML namespace aware. Default is {@code true}. */
/**
* Set whether or not the XML parser should be XML namespace aware. Default is
* {@code true}.
*/
public void setNamespaceAware(boolean namespaceAware) {
this.namespaceAware = namespaceAware;
}
@@ -69,14 +73,16 @@ public abstract class AbstractDomPayloadEndpoint extends TransformerObjectSuppor
}
/**
* Set if the XML parser should expand entity reference nodes. Default is {@code false}.
* Set if the XML parser should expand entity reference nodes. Default is
* {@code false}.
*/
public void setExpandEntityReferences(boolean expandEntityRef) {
documentBuilderFactory.setExpandEntityReferences(expandEntityRef);
}
/**
* Set if the request {@link Source} should always be transformed into a new {@link DOMResult}.
* Set if the request {@link Source} should always be transformed into a new
* {@link DOMResult}.
* <p>
* Default is {@code false}, which is faster.
*/
@@ -97,22 +103,24 @@ public abstract class AbstractDomPayloadEndpoint extends TransformerObjectSuppor
}
/**
* 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
* 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 {
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.
*
* 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
*/
@@ -127,11 +135,11 @@ public abstract class AbstractDomPayloadEndpoint extends TransformerObjectSuppor
/**
* Returns the payload element of the given source.
* <p>
* 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.
*
* 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
@@ -145,7 +153,8 @@ public abstract class AbstractDomPayloadEndpoint extends TransformerObjectSuppor
Node node = ((DOMSource) source).getNode();
if (node.getNodeType() == Node.ELEMENT_NODE) {
return (Element) node;
} else if (node.getNodeType() == Node.DOCUMENT_NODE) {
}
else if (node.getNodeType() == Node.DOCUMENT_NODE) {
return ((Document) node).getDocumentElement();
}
}
@@ -159,11 +168,11 @@ public abstract class AbstractDomPayloadEndpoint extends TransformerObjectSuppor
/**
* Template method that subclasses must implement to process the request.
* <p>
* Offers the request payload as a DOM {@code Element}, and allows subclasses to return a response {@code Element}.
* Offers the request payload as a DOM {@code Element}, and allows subclasses to
* return a response {@code Element}.
* <p>
* The given DOM {@code Document} is to be used for constructing {@code Node}s, by using the various {@code create}
* methods.
*
* 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.

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -20,6 +20,7 @@ import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.core.Ordered;
import org.springframework.ws.context.MessageContext;
import org.springframework.ws.server.EndpointExceptionResolver;
@@ -47,23 +48,26 @@ public abstract class AbstractEndpointExceptionResolver implements EndpointExcep
/**
* Specify the set of endpoints that this exception resolver should map.
* <p>
* The exception mappings and the default fault will only apply to the specified endpoints.
* The exception mappings and the default fault will only apply to the specified
* endpoints.
* <p>
* If no endpoints are set, both the exception mappings and the default fault will apply to all handlers. This means
* that a specified default fault will be used as fallback for all exceptions; any further
* {@code EndpointExceptionResolvers} in the chain will be ignored in this case.
* If no endpoints are set, both the exception mappings and the default fault will
* apply to all handlers. This means that a specified default fault will be used as
* fallback for all exceptions; any further {@code EndpointExceptionResolvers} in the
* chain will be ignored in this case.
*/
public void setMappedEndpoints(Set<?> mappedEndpoints) {
this.mappedEndpoints = mappedEndpoints;
}
/**
* Set the log category for warn logging. The name will be passed to the underlying logger implementation through
* Commons Logging, getting interpreted as log category according to the logger's configuration.
* Set the log category for warn logging. The name will be passed to the underlying
* logger implementation through Commons Logging, getting interpreted as log category
* according to the logger's configuration.
* <p>
* Default is no warn logging. Specify this setting to activate warn logging into a specific category. Alternatively,
* override the {@link #logException} method for custom logging.
*
* Default is no warn logging. Specify this setting to activate warn logging into a
* specific category. Alternatively, override the {@link #logException} method for
* custom logging.
* @see org.apache.commons.logging.LogFactory#getLog(String)
* @see org.apache.log4j.Logger#getLogger(String)
* @see java.util.logging.Logger#getLogger(String)
@@ -76,7 +80,6 @@ public abstract class AbstractEndpointExceptionResolver implements EndpointExcep
* Specify the order value for this mapping.
* <p>
* Default value is {@link Integer#MAX_VALUE}, meaning that it's non-ordered.
*
* @see org.springframework.core.Ordered#getOrder()
*/
public final void setOrder(int order) {
@@ -89,9 +92,8 @@ public abstract class AbstractEndpointExceptionResolver implements EndpointExcep
}
/**
* Default implementation that checks whether the given {@code endpoint} is in the set of {@link #setMappedEndpoints
* mapped endpoints}.
*
* Default implementation that checks whether the given {@code endpoint} is in the set
* of {@link #setMappedEndpoints mapped endpoints}.
* @see #resolveExceptionInternal(MessageContext,Object,Exception)
*/
@Override
@@ -109,12 +111,11 @@ public abstract class AbstractEndpointExceptionResolver implements EndpointExcep
}
/**
* Log the given exception at warn level, provided that warn logging has been activated through the
* {@link #setWarnLogCategory "warnLogCategory"} property.
* Log the given exception at warn level, provided that warn logging has been
* activated through the {@link #setWarnLogCategory "warnLogCategory"} property.
* <p>
* Calls {@link #buildLogMessage} in order to determine the concrete message to log. Always passes the full exception
* to the logger.
*
* Calls {@link #buildLogMessage} in order to determine the concrete message to log.
* Always passes the full exception to the logger.
* @param ex the exception that got thrown during handler execution
* @param messageContext current message context request
* @see #setWarnLogCategory
@@ -128,8 +129,8 @@ public abstract class AbstractEndpointExceptionResolver implements EndpointExcep
}
/**
* Build a log message for the given exception, occured during processing the given message context.
*
* Build a log message for the given exception, occured during processing the given
* message context.
* @param ex the exception that got thrown during handler execution
* @param messageContext the message context
* @return the log message to use
@@ -139,10 +140,11 @@ public abstract class AbstractEndpointExceptionResolver implements EndpointExcep
}
/**
* Template method for resolving exceptions that is called by {@link #resolveException}.
*
* Template method for resolving exceptions that is called by
* {@link #resolveException}.
* @param messageContext current message context
* @param endpoint the executed endpoint, or {@code null} if none chosen at the time of the exception
* @param endpoint the executed endpoint, or {@code null} if none chosen at the time
* of the exception
* @param ex the exception that got thrown during endpoint execution
* @return {@code true} if resolved; {@code false} otherwise
* @see #resolveException(MessageContext,Object,Exception)

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -25,15 +25,17 @@ import org.jdom2.Element;
import org.jdom2.input.DOMBuilder;
import org.jdom2.transform.JDOMResult;
import org.jdom2.transform.JDOMSource;
import org.springframework.xml.transform.TransformerObjectSupport;
import org.w3c.dom.Node;
import org.springframework.xml.transform.TransformerObjectSupport;
/**
* Abstract base class for endpoints that handle the message payload as JDOM elements.
* <p>
* Offers the message payload as a JDOM {@link Element}, and allows subclasses to create a response by returning an
* {@code Element}. <pAn {@code AbstractJDomPayloadEndpoint} can accept only <i>one</i> payload element. Multiple
* payload elements are not in accordance with WS-I.
* Offers the message payload as a JDOM {@link Element}, and allows subclasses to create a
* response by returning an {@code Element}. <pAn {@code AbstractJDomPayloadEndpoint} can
* accept only <i>one</i> payload element. Multiple payload elements are not in accordance
* with WS-I.
*
* @author Arjen Poutsma
* @since 1.0.0
@@ -45,7 +47,8 @@ public abstract class AbstractJDomPayloadEndpoint extends TransformerObjectSuppo
private boolean alwaysTransform = false;
/**
* Set if the request {@link Source} should always be transformed into a new {@link JDOMResult}.
* Set if the request {@link Source} should always be transformed into a new
* {@link JDOMResult}.
* <p>
* Default is {@code false}, which is faster.
*/
@@ -63,11 +66,11 @@ public abstract class AbstractJDomPayloadEndpoint extends TransformerObjectSuppo
/**
* Returns the payload element of the given source.
* <p>
* 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.
*
* 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
@@ -81,7 +84,8 @@ public abstract class AbstractJDomPayloadEndpoint extends TransformerObjectSuppo
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) {
}
else if (node.getNodeType() == Node.DOCUMENT_NODE) {
Document document = domBuilder.build((org.w3c.dom.Document) node);
return document.getRootElement();
}
@@ -93,11 +97,11 @@ public abstract class AbstractJDomPayloadEndpoint extends TransformerObjectSuppo
}
/**
* Template method. Subclasses must implement this. Offers the request payload as a JDOM {@code Element}, and allows
* subclasses to return a response {@code Element}.
*
* 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;
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -27,15 +27,17 @@ import javax.xml.transform.stream.StreamResult;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.ws.WebServiceMessage;
import org.springframework.ws.context.MessageContext;
import org.springframework.ws.server.EndpointInterceptor;
import org.springframework.xml.transform.TransformerObjectSupport;
/**
* Abstract base class for {@code EndpointInterceptor} instances that log a part of a {@code WebServiceMessage}. By
* default, both request and response messages are logged, but this behaviour can be changed using the
* {@code logRequest} and {@code logResponse} properties.
* Abstract base class for {@code EndpointInterceptor} instances that log a part of a
* {@code WebServiceMessage}. By default, both request and response messages are logged,
* but this behaviour can be changed using the {@code logRequest} and {@code logResponse}
* properties.
*
* @author Arjen Poutsma
* @since 1.0.0
@@ -43,8 +45,8 @@ import org.springframework.xml.transform.TransformerObjectSupport;
public abstract class AbstractLoggingInterceptor extends TransformerObjectSupport implements EndpointInterceptor {
/**
* The default {@code Log} instance used to write trace messages. This instance is mapped to the implementing
* {@code Class}.
* The default {@code Log} instance used to write trace messages. This instance is
* mapped to the implementing {@code Class}.
*/
protected transient Log logger = LogFactory.getLog(getClass());
@@ -63,11 +65,12 @@ public abstract class AbstractLoggingInterceptor extends TransformerObjectSuppor
}
/**
* Set the name of the logger to use. The name will be passed to the underlying logger implementation through Commons
* Logging, getting interpreted as log category according to the logger's configuration.
* Set the name of the logger to use. The name will be passed to the underlying logger
* implementation through Commons Logging, getting interpreted as log category
* according to the logger's configuration.
* <p>
* This can be specified to not log into the category of a class but rather into a specific named category.
*
* This can be specified to not log into the category of a class but rather into a
* specific named category.
* @see org.apache.commons.logging.LogFactory#getLog(String)
* @see org.apache.log4j.Logger#getLogger(String)
* @see java.util.logging.Logger#getLogger(String)
@@ -77,9 +80,8 @@ public abstract class AbstractLoggingInterceptor extends TransformerObjectSuppor
}
/**
* Logs the request message payload. Logging only occurs if {@code logRequest} is set to {@code true}, which is the
* default.
*
* Logs the request message payload. Logging only occurs if {@code logRequest} is set
* to {@code true}, which is the default.
* @param messageContext the message context
* @return {@code true}
* @throws TransformerException when the payload cannot be transformed to a string
@@ -93,9 +95,8 @@ public abstract class AbstractLoggingInterceptor extends TransformerObjectSuppor
}
/**
* Logs the response message payload. Logging only occurs if {@code logResponse} is set to {@code true}, which is the
* default.
*
* Logs the response message payload. Logging only occurs if {@code logResponse} is
* set to {@code true}, which is the default.
* @param messageContext the message context
* @return {@code true}
* @throws TransformerException when the payload cannot be transformed to a string
@@ -116,13 +117,14 @@ public abstract class AbstractLoggingInterceptor extends TransformerObjectSuppor
/** Does nothing by default */
@Override
public void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex) {}
public void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex) {
}
/**
* Determine whether the {@link #logger} field is enabled.
* <p>
* Default is {@code true} when the "debug" level is enabled. Subclasses can override this to change the level under
* which logging occurs.
* Default is {@code true} when the "debug" level is enabled. Subclasses can override
* this to change the level under which logging occurs.
*/
protected boolean isLogEnabled() {
return logger.isDebugEnabled();
@@ -136,11 +138,11 @@ public abstract class AbstractLoggingInterceptor extends TransformerObjectSuppor
}
/**
* Logs the given {@link Source source} to the {@link #logger}, using the message as a prefix.
* Logs the given {@link Source source} to the {@link #logger}, using the message as a
* prefix.
* <p>
* By default, this message creates a string representation of the given source, and delegates to
* {@link #logMessage(String)}.
*
* By default, this message creates a string representation of the given source, and
* delegates to {@link #logMessage(String)}.
* @param logMessage the log message
* @param source the source to be logged
* @throws TransformerException in case of errors
@@ -158,9 +160,8 @@ public abstract class AbstractLoggingInterceptor extends TransformerObjectSuppor
/**
* Logs the given string message.
* <p>
* By default, this method uses a "debug" level of logging. Subclasses can override this method to change the level of
* logging used by the logger.
*
* By default, this method uses a "debug" level of logging. Subclasses can override
* this method to change the level of logging used by the logger.
* @param message the message
*/
protected void logMessage(String message) {
@@ -168,10 +169,11 @@ public abstract class AbstractLoggingInterceptor extends TransformerObjectSuppor
}
/**
* Abstract template method that returns the {@code Source} for the given {@code WebServiceMessage}.
*
* Abstract template method that returns the {@code Source} for the given
* {@code WebServiceMessage}.
* @param message the message
* @return the source of the message
*/
protected abstract Source getSource(WebServiceMessage message);
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -20,6 +20,7 @@ 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;
@@ -29,9 +30,10 @@ 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.
* 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
* @see #setMarshaller(org.springframework.oxm.Marshaller)
@@ -53,24 +55,25 @@ public abstract class AbstractMarshallingPayloadEndpoint implements MessageEndpo
private Unmarshaller unmarshaller;
/**
* Creates a new {@code AbstractMarshallingPayloadEndpoint}. The {@link Marshaller} and {@link Unmarshaller} must be
* injected using properties.
*
* 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() {}
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.
* 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.
* <p>
* Note that all {@link Marshaller} implementations in Spring-WS also implement the {@link Unmarshaller} interface, so
* that you can safely use this constructor.
*
* 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
* @throws IllegalArgumentException when {@code marshaller} does not implement the
* {@link Unmarshaller} interface
* @see #AbstractMarshallingPayloadEndpoint(Marshaller,Unmarshaller)
*/
protected AbstractMarshallingPayloadEndpoint(Marshaller marshaller) {
@@ -79,15 +82,16 @@ public abstract class AbstractMarshallingPayloadEndpoint implements MessageEndpo
throw new IllegalArgumentException("Marshaller [" + marshaller + "] does not implement the Unmarshaller "
+ "interface. Please set an Unmarshaller explicitly by using the "
+ "AbstractMarshallingPayloadEndpoint(Marshaller, Unmarshaller) constructor.");
} else {
}
else {
setMarshaller(marshaller);
setUnmarshaller((Unmarshaller) marshaller);
}
}
/**
* Creates a new {@code AbstractMarshallingPayloadEndpoint} with the given marshaller and unmarshaller.
*
* Creates a new {@code AbstractMarshallingPayloadEndpoint} with the given marshaller
* and unmarshaller.
* @param marshaller the marshaller to use
* @param unmarshaller the unmarshaller to use
*/
@@ -148,14 +152,15 @@ public abstract class AbstractMarshallingPayloadEndpoint implements MessageEndpo
}
/**
* Callback for post-processing in terms of unmarshalling. Called on each message request, after standard
* unmarshalling.
* Callback for post-processing in terms of unmarshalling. Called on each message
* request, after standard unmarshalling.
* <p>
* 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
* @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;
@@ -171,36 +176,41 @@ public abstract class AbstractMarshallingPayloadEndpoint implements MessageEndpo
}
/**
* 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.
* 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.
* <p>
* 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}
* @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) {}
protected void onMarshalResponse(MessageContext messageContext, Object requestObject, Object responseObject) {
}
/**
* Template method that gets called after the marshaller and unmarshaller have been set.
* Template method that gets called after the marshaller and unmarshaller have been
* set.
* <p>
* 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 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 {}
public void afterMarshallerSet() throws Exception {
}
/**
* Template method that subclasses must implement to process a request.
* <p>
* 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}.
*
* 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
* @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;
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -19,16 +19,18 @@ package org.springframework.ws.server.endpoint;
import javax.xml.transform.Source;
import javax.xml.transform.sax.SAXResult;
import org.springframework.xml.transform.TransformerObjectSupport;
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}.
* 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}.
* <p>
* 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.
* 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
* @see #createContentHandler()
@@ -40,9 +42,8 @@ import org.xml.sax.ContentHandler;
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.
*
* 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)
*/
@@ -58,24 +59,25 @@ public abstract class AbstractSaxPayloadEndpoint extends TransformerObjectSuppor
}
/**
* 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.
* 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.
* <p>
* 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.
* 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.
* <p>
* If an incoming message does not contain a payload, this method will be invoked with {@code null} as content
* handler.
*
* 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;
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -20,7 +20,11 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import javax.xml.namespace.NamespaceContext;
import javax.xml.stream.*;
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;
@@ -34,12 +38,13 @@ 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}.
* 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
* @see #invokeInternal(javax.xml.stream.XMLEventReader,javax.xml.stream.util.XMLEventConsumer,
* javax.xml.stream.XMLEventFactory)
* javax.xml.stream.XMLEventFactory)
* @see XMLEventReader
* @see XMLEventWriter
* @since 1.0.0
@@ -59,10 +64,10 @@ public abstract class AbstractStaxEventPayloadEndpoint extends AbstractStaxPaylo
}
/**
* 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.
*
* 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() {
@@ -89,7 +94,8 @@ public abstract class AbstractStaxEventPayloadEndpoint extends AbstractStaxPaylo
if (streamReader != null) {
try {
eventReader = getInputFactory().createXMLEventReader(streamReader);
} catch (XMLStreamException ex) {
}
catch (XMLStreamException ex) {
eventReader = null;
}
}
@@ -98,7 +104,8 @@ public abstract class AbstractStaxEventPayloadEndpoint extends AbstractStaxPaylo
if (eventReader == null) {
try {
eventReader = getInputFactory().createXMLEventReader(source);
} catch (XMLStreamException | UnsupportedOperationException ex) {
}
catch (XMLStreamException | UnsupportedOperationException ex) {
eventReader = null;
}
}
@@ -120,7 +127,8 @@ public abstract class AbstractStaxEventPayloadEndpoint extends AbstractStaxPaylo
if (eventWriter == null) {
try {
eventWriter = getOutputFactory().createXMLEventWriter(result);
} catch (XMLStreamException ex) {
}
catch (XMLStreamException ex) {
// ignore
}
}
@@ -128,9 +136,9 @@ public abstract class AbstractStaxEventPayloadEndpoint extends AbstractStaxPaylo
}
/**
* Template method. Subclasses must implement this. Offers the request payload as a {@code XMLEventReader}, and a
* {@code XMLEventWriter} to write the response payload to.
*
* 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
@@ -139,8 +147,9 @@ public abstract class AbstractStaxEventPayloadEndpoint extends AbstractStaxPaylo
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.
* 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 class ResponseCreatingEventWriter implements XMLEventWriter {
@@ -180,11 +189,13 @@ public abstract class AbstractStaxEventPayloadEndpoint extends AbstractStaxPaylo
if (event.isEndDocument()) {
if (os != null) {
eventWriter.flush();
// if we used an output stream cache, we have to transform it to the response again
// if we used an output stream cache, we have to transform it to the
// response again
try {
ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
transform(new StreamSource(is), messageContext.getResponse().getPayloadResult());
} catch (TransformerException ex) {
}
catch (TransformerException ex) {
throw new XMLStreamException(ex);
}
}
@@ -228,11 +239,14 @@ public abstract class AbstractStaxEventPayloadEndpoint extends AbstractStaxPaylo
WebServiceMessage response = messageContext.getResponse();
eventWriter = getEventWriter(response.getPayloadResult());
if (eventWriter == null) {
// as a final resort, use a stream, and transform that at endDocument()
// as a final resort, use a stream, and transform that at
// endDocument()
os = new ByteArrayOutputStream();
eventWriter = getOutputFactory().createXMLEventWriter(os);
}
}
}
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -23,7 +23,8 @@ 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}.
* Abstract base class for endpoints use StAX. Provides an {@code XMLInputFactory} and an
* {@code XMLOutputFactory}.
*
* @author Arjen Poutsma
* @see XMLInputFactory
@@ -56,10 +57,10 @@ public abstract class AbstractStaxPayloadEndpoint extends TransformerObjectSuppo
}
/**
* 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.
*
* 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() {
@@ -67,13 +68,14 @@ public abstract class AbstractStaxPayloadEndpoint extends TransformerObjectSuppo
}
/**
* 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.
*
* 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();
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -35,8 +35,9 @@ 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}.
* 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
* @see #invokeInternal(javax.xml.stream.XMLStreamReader,javax.xml.stream.XMLStreamWriter)
@@ -69,7 +70,8 @@ public abstract class AbstractStaxStreamPayloadEndpoint extends AbstractStaxPayl
if (eventReader != null) {
try {
streamReader = StaxUtils.createEventStreamReader(eventReader);
} catch (XMLStreamException ex) {
}
catch (XMLStreamException ex) {
streamReader = null;
}
}
@@ -79,7 +81,8 @@ public abstract class AbstractStaxStreamPayloadEndpoint extends AbstractStaxPayl
if (streamReader == null) {
try {
streamReader = getInputFactory().createXMLStreamReader(source);
} catch (XMLStreamException | UnsupportedOperationException ex) {
}
catch (XMLStreamException | UnsupportedOperationException ex) {
// ignore
}
}
@@ -101,7 +104,8 @@ public abstract class AbstractStaxStreamPayloadEndpoint extends AbstractStaxPayl
if (streamWriter == null) {
try {
streamWriter = getOutputFactory().createXMLStreamWriter(result);
} catch (XMLStreamException ex) {
}
catch (XMLStreamException ex) {
// ignore
}
}
@@ -109,17 +113,18 @@ public abstract class AbstractStaxStreamPayloadEndpoint extends AbstractStaxPayl
}
/**
* Template method. Subclasses must implement this. Offers the request payload as a {@code XMLStreamReader}, and a
* {@code XMLStreamWriter} to write the response payload to.
*
* 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.
* 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 class ResponseCreatingStreamWriter implements XMLStreamWriter {
@@ -150,12 +155,14 @@ public abstract class AbstractStaxStreamPayloadEndpoint extends AbstractStaxPayl
streamWriter.close();
if (os != null) {
streamWriter.flush();
// if we used an output stream cache, we have to transform it to the response again
// if we used an output stream cache, we have to transform it to the
// response again
try {
ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
transform(new StreamSource(is), messageContext.getResponse().getPayloadResult());
os = null;
} catch (TransformerException ex) {
}
catch (TransformerException ex) {
throw new XMLStreamException(ex);
}
}
@@ -344,11 +351,14 @@ public abstract class AbstractStaxStreamPayloadEndpoint extends AbstractStaxPayl
WebServiceMessage response = messageContext.getResponse();
streamWriter = getStreamWriter(response.getPayloadResult());
if (streamWriter == null) {
// as a final resort, use a stream, and transform that at endDocument()
// as a final resort, use a stream, and transform that at
// endDocument()
os = new ByteArrayOutputStream();
streamWriter = getOutputFactory().createXMLStreamWriter(os);
}
}
}
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -23,9 +23,9 @@ 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 <strong>must</strong>
* {@link Validator#supports(Class) support} the request object.
* Extension of the {@link AbstractMarshallingPayloadEndpoint} which validates the request
* payload with {@link Validator}(s). The desired validators can be set using properties,
* and <strong>must</strong> {@link Validator#supports(Class) support} the request object.
*
* @author Arjen Poutsma
* @since 1.0.2
@@ -58,9 +58,10 @@ public abstract class AbstractValidatingMarshallingPayloadEndpoint extends Abstr
}
/**
* 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.
* 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 };
@@ -71,7 +72,10 @@ public abstract class AbstractValidatingMarshallingPayloadEndpoint extends Abstr
return validators;
}
/** Set the Validators for this controller. The Validator must support the specified command class. */
/**
* Set the Validators for this controller. The Validator must support the specified
* command class.
*/
public void setValidators(Validator[] validators) {
this.validators = validators;
}
@@ -92,12 +96,15 @@ public abstract class AbstractValidatingMarshallingPayloadEndpoint extends Abstr
}
/**
* Callback for post-processing validation errors. Called when validator(s) have been specified, and validation fails.
*
* 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 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
* @return {@code true} to continue and call {@link #invokeInternal(Object)};
* {@code false} otherwise
*/
protected abstract boolean onValidationErrors(MessageContext messageContext, Object requestObject, Errors errors);
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -16,10 +16,12 @@
package org.springframework.ws.server.endpoint;
import nu.xom.*;
import nu.xom.converters.DOMConverter;
import java.io.*;
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;
@@ -29,21 +31,32 @@ import javax.xml.stream.XMLStreamReader;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
import org.springframework.core.NestedRuntimeException;
import org.springframework.xml.namespace.QNameUtils;
import org.springframework.xml.transform.TransformerObjectSupport;
import org.springframework.xml.transform.TraxUtils;
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}.
* 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}.
* <p>
* An {@code AbstractXomPayloadEndpoint} only accept one payload element. Multiple payload elements are not in
* accordance with WS-I.
* An {@code AbstractXomPayloadEndpoint} only accept one payload element. Multiple payload
* elements are not in accordance with WS-I.
*
* @author Arjen Poutsma
* @see Element
@@ -61,7 +74,8 @@ public abstract class AbstractXomPayloadEndpoint extends TransformerObjectSuppor
XomSourceCallback sourceCallback = new XomSourceCallback();
try {
TraxUtils.doWithSource(request, sourceCallback);
} catch (XomParsingException ex) {
}
catch (XomParsingException ex) {
throw (ParsingException) ex.getCause();
}
requestElement = sourceCallback.element;
@@ -85,8 +99,8 @@ public abstract class AbstractXomPayloadEndpoint extends TransformerObjectSuppor
/**
* Creates a {@link Serializer} to be used for writing the response to.
* <p>
* Default implementation uses the UTF-8 encoding and does not set any options, but this may be changed in subclasses.
*
* 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
*/
@@ -95,9 +109,8 @@ public abstract class AbstractXomPayloadEndpoint extends TransformerObjectSuppor
}
/**
* Template method. Subclasses must implement this. Offers the request payload as a XOM {@code Element}, and allows
* subclasses to return a response {@code Element}.
*
* 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.
*/
@@ -111,10 +124,12 @@ public abstract class AbstractXomPayloadEndpoint extends TransformerObjectSuppor
public void domSource(Node node) {
if (node.getNodeType() == Node.ELEMENT_NODE) {
element = DOMConverter.convert((org.w3c.dom.Element) node);
} else if (node.getNodeType() == Node.DOCUMENT_NODE) {
}
else if (node.getNodeType() == Node.DOCUMENT_NODE) {
Document document = DOMConverter.convert((org.w3c.dom.Document) node);
element = document.getRootElement();
} else {
}
else {
throw new IllegalArgumentException("DOMSource contains neither Document nor Element");
}
}
@@ -126,14 +141,17 @@ public abstract class AbstractXomPayloadEndpoint extends TransformerObjectSuppor
Document document;
if (inputSource.getByteStream() != null) {
document = builder.build(inputSource.getByteStream());
} else if (inputSource.getCharacterStream() != null) {
}
else if (inputSource.getCharacterStream() != null) {
document = builder.build(inputSource.getCharacterStream());
} else {
}
else {
throw new IllegalArgumentException(
"InputSource in SAXSource contains neither byte stream nor character stream");
}
element = document.getRootElement();
} catch (ParsingException e) {
}
catch (ParsingException e) {
throw new XomParsingException(e);
}
}
@@ -155,7 +173,8 @@ public abstract class AbstractXomPayloadEndpoint extends TransformerObjectSuppor
Builder builder = new Builder();
Document document = builder.build(inputStream);
element = document.getRootElement();
} catch (ParsingException ex) {
}
catch (ParsingException ex) {
throw new XomParsingException(ex);
}
}
@@ -166,7 +185,8 @@ public abstract class AbstractXomPayloadEndpoint extends TransformerObjectSuppor
Builder builder = new Builder();
Document document = builder.build(reader);
element = document.getRootElement();
} catch (ParsingException ex) {
}
catch (ParsingException ex) {
throw new XomParsingException(ex);
}
}
@@ -177,10 +197,12 @@ public abstract class AbstractXomPayloadEndpoint extends TransformerObjectSuppor
Builder builder = new Builder();
Document document = builder.build(systemId);
element = document.getRootElement();
} catch (ParsingException ex) {
}
catch (ParsingException ex) {
throw new XomParsingException(ex);
}
}
}
@SuppressWarnings("serial")
@@ -189,6 +211,7 @@ public abstract class AbstractXomPayloadEndpoint extends TransformerObjectSuppor
private XomParsingException(ParsingException ex) {
super(ex.getMessage(), ex);
}
}
private static class StaxStreamConverter {
@@ -219,7 +242,8 @@ public abstract class AbstractXomPayloadEndpoint extends TransformerObjectSuppor
if (element == null) {
element = nodeFactory.makeRootElement(name, streamReader.getNamespaceURI());
document.setRootElement(element);
} else {
}
else {
element = nodeFactory.startMakingElement(name, streamReader.getNamespaceURI());
parent.appendChild(element);
}
@@ -275,28 +299,39 @@ public abstract class AbstractXomPayloadEndpoint extends TransformerObjectSuppor
type = type.toUpperCase(Locale.ENGLISH);
if ("CDATA".equals(type)) {
return Attribute.Type.CDATA;
} else if ("ENTITIES".equals(type)) {
}
else if ("ENTITIES".equals(type)) {
return Attribute.Type.ENTITIES;
} else if ("ENTITY".equals(type)) {
}
else if ("ENTITY".equals(type)) {
return Attribute.Type.ENTITY;
} else if ("ENUMERATION".equals(type)) {
}
else if ("ENUMERATION".equals(type)) {
return Attribute.Type.ENUMERATION;
} else if ("ID".equals(type)) {
}
else if ("ID".equals(type)) {
return Attribute.Type.ID;
} else if ("IDREF".equals(type)) {
}
else if ("IDREF".equals(type)) {
return Attribute.Type.IDREF;
} else if ("IDREFS".equals(type)) {
}
else if ("IDREFS".equals(type)) {
return Attribute.Type.IDREFS;
} else if ("NMTOKEN".equals(type)) {
}
else if ("NMTOKEN".equals(type)) {
return Attribute.Type.NMTOKEN;
} else if ("NMTOKENS".equals(type)) {
}
else if ("NMTOKENS".equals(type)) {
return Attribute.Type.NMTOKENS;
} else if ("NOTATION".equals(type)) {
}
else if ("NOTATION".equals(type)) {
return Attribute.Type.NOTATION;
} else {
}
else {
return Attribute.Type.UNDECLARED;
}
}
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -21,8 +21,9 @@ import org.springframework.ws.context.MessageContext;
/**
* Defines the basic contract for Web Services interested in the entire message payload.
* <p>
* The main entrypoint is {@link #invoke(MessageContext)}, which gets invoked with the message context. This context
* contains the {@link MessageContext#getRequest() request}, and can be used to create a response.
* The main entrypoint is {@link #invoke(MessageContext)}, which gets invoked with the
* message context. This context contains the {@link MessageContext#getRequest() request},
* and can be used to create a response.
*
* @author Arjen Poutsma
* @see org.springframework.ws.server.endpoint.PayloadEndpoint
@@ -34,9 +35,9 @@ public interface MessageEndpoint {
* Invokes an operation.
* <p>
* The given {@code messageContext} can be used to create a response.
*
* @param messageContext the message context
* @throws Exception if an exception occurs
*/
void invoke(MessageContext messageContext) throws Exception;
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -25,7 +25,8 @@ import org.springframework.util.Assert;
import org.springframework.util.ReflectionUtils;
/**
* Represents a bean method that will be invoked as part of an incoming Web service message.
* Represents a bean method that will be invoked as part of an incoming Web service
* message.
* <p>
* Consists of a {@link Method}, and a bean {@link Object}.
*
@@ -42,7 +43,6 @@ public final class MethodEndpoint {
/**
* Constructs a new method endpoint with the given bean and method.
*
* @param bean the object bean
* @param method the method
*/
@@ -56,7 +56,6 @@ public final class MethodEndpoint {
/**
* Constructs a new method endpoint with the given bean, method name and parameters.
*
* @param bean the object bean
* @param methodName the method name
* @param parameterTypes the method parameter types
@@ -71,9 +70,8 @@ public final class MethodEndpoint {
}
/**
* Constructs a new method endpoint with the given bean name and method. The bean name will be lazily initialized when
* {@link #invoke(Object...)} is called.
*
* Constructs a new method endpoint with the given bean name and method. The bean name
* will be lazily initialized when {@link #invoke(Object...)} is called.
* @param beanName the bean name
* @param beanFactory the bean factory to use for bean initialization
* @param method the method
@@ -94,7 +92,8 @@ public final class MethodEndpoint {
if (beanFactory != null && bean instanceof String) {
String beanName = (String) bean;
return beanFactory.getBean(beanName);
} else {
}
else {
return bean;
}
}
@@ -121,7 +120,6 @@ public final class MethodEndpoint {
/**
* Invokes this method endpoint with the given arguments.
*
* @param args the arguments
* @return the invocation result
* @throws Exception when the method invocation results in an exception
@@ -131,7 +129,8 @@ public final class MethodEndpoint {
ReflectionUtils.makeAccessible(method);
try {
return method.invoke(endpoint, args);
} catch (InvocationTargetException ex) {
}
catch (InvocationTargetException ex) {
handleInvocationTargetException(ex);
throw new IllegalStateException("Unexpected exception thrown by method - "
+ ex.getTargetException().getClass().getName() + ": " + ex.getTargetException().getMessage());

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -21,7 +21,8 @@ import javax.xml.transform.Source;
/**
* Defines the basic contract for Web Services interested in just the message payload.
* <p>
* The main entrypoint is {@link #invoke(Source)}, which gets invoked with the contents of the requesting message.
* The main entrypoint is {@link #invoke(Source)}, which gets invoked with the contents of
* the requesting message.
*
* @author Arjen Poutsma
* @since 1.0.0
@@ -29,11 +30,13 @@ import javax.xml.transform.Source;
public interface PayloadEndpoint {
/**
* Invokes the endpoint with the given request payload, and possibly returns a response.
*
* Invokes the endpoint with the given request payload, and possibly returns a
* response.
* @param request the payload of the request message, may be {@code null}
* @return the payload of the response message, may be {@code null} to indicate no response
* @return the payload of the response message, may be {@code null} to indicate no
* response
* @throws Exception if an exception occurs
*/
Source invoke(Source request) throws Exception;
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -22,8 +22,8 @@ import org.springframework.ws.server.endpoint.MethodEndpoint;
import org.springframework.xml.transform.TransformerObjectSupport;
/**
* Abstract base class for {@link EndpointAdapter} implementations that support {@link MethodEndpoint}s. Contains
* template methods for handling these method endpoints.
* Abstract base class for {@link EndpointAdapter} implementations that support
* {@link MethodEndpoint}s. Contains template methods for handling these method endpoints.
*
* @author Arjen Poutsma
* @since 1.0.0
@@ -31,8 +31,8 @@ import org.springframework.xml.transform.TransformerObjectSupport;
public abstract class AbstractMethodEndpointAdapter extends TransformerObjectSupport implements EndpointAdapter {
/**
* Delegates to {@link #supportsInternal(org.springframework.ws.server.endpoint.MethodEndpoint)}.
*
* Delegates to
* {@link #supportsInternal(org.springframework.ws.server.endpoint.MethodEndpoint)}.
* @param endpoint endpoint object to check
* @return whether or not this adapter can adapt the given endpoint
*/
@@ -42,11 +42,12 @@ public abstract class AbstractMethodEndpointAdapter extends TransformerObjectSup
}
/**
* Delegates to {@link #invokeInternal(org.springframework.ws.context.MessageContext,MethodEndpoint)}.
*
* Delegates to
* {@link #invokeInternal(org.springframework.ws.context.MessageContext,MethodEndpoint)}.
* @param messageContext the current message context
* @param endpoint the endpoint to use. This object must have previously been passed to the {@code supportsInternal}
* method of this interface, which must have returned {@code true}
* @param endpoint the endpoint to use. This object must have previously been passed
* to the {@code supportsInternal} method of this interface, which must have returned
* {@code true}
* @throws Exception in case of errors
*/
@Override
@@ -56,7 +57,6 @@ public abstract class AbstractMethodEndpointAdapter extends TransformerObjectSup
/**
* Given a method endpoint, return whether or not this adapter can support it.
*
* @param methodEndpoint method endpoint to check
* @return whether or not this adapter can adapt the given method
*/
@@ -64,11 +64,11 @@ public abstract class AbstractMethodEndpointAdapter extends TransformerObjectSup
/**
* Use the given method endpoint to handle the request.
*
* @param messageContext the current message context
* @param methodEndpoint the method endpoint to use
* @throws Exception in case of errors
*/
protected abstract void invokeInternal(MessageContext messageContext, MethodEndpoint methodEndpoint) throws Exception;
protected abstract void invokeInternal(MessageContext messageContext, MethodEndpoint methodEndpoint)
throws Exception;
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -43,8 +43,8 @@ import org.springframework.ws.server.endpoint.adapter.method.jaxb.XmlRootElement
/**
* Default extension of {@link AbstractMethodEndpointAdapter} with support for pluggable
* {@linkplain MethodArgumentResolver argument resolvers} and {@linkplain MethodReturnValueHandler return value
* handlers}.
* {@linkplain MethodArgumentResolver argument resolvers} and
* {@linkplain MethodReturnValueHandler return value handlers}.
*
* @author Arjen Poutsma
* @since 2.0
@@ -98,8 +98,9 @@ public class DefaultMethodEndpointAdapter extends AbstractMethodEndpointAdapter
}
/**
* Sets the custom handlers for method arguments. Custom handlers are ordered after built-in ones. To override the
* built-in support for return value handling use {@link #setMethodArgumentResolvers(List)}.
* Sets the custom handlers for method arguments. Custom handlers are ordered after
* built-in ones. To override the built-in support for return value handling use
* {@link #setMethodArgumentResolvers(List)}.
*/
public void setCustomMethodArgumentResolvers(List<MethodArgumentResolver> customMethodArgumentResolvers) {
this.customMethodArgumentResolvers = customMethodArgumentResolvers;
@@ -127,8 +128,9 @@ public class DefaultMethodEndpointAdapter extends AbstractMethodEndpointAdapter
}
/**
* Sets the handlers for custom return value types. Custom handlers are ordered after built-in ones. To override the
* built-in support for return value handling use {@link #setMethodReturnValueHandlers(List)}.
* Sets the handlers for custom return value types. Custom handlers are ordered after
* built-in ones. To override the built-in support for return value handling use
* {@link #setMethodReturnValueHandlers(List)}.
*/
public void setCustomMethodReturnValueHandlers(List<MethodReturnValueHandler> customMethodReturnValueHandlers) {
this.customMethodReturnValueHandlers = customMethodReturnValueHandlers;
@@ -190,16 +192,17 @@ public class DefaultMethodEndpointAdapter extends AbstractMethodEndpointAdapter
}
/**
* Certain (SOAP-specific) {@code MethodArgumentResolver}s have to be instantiated by class name, in order to not
* introduce a cyclic dependency.
* Certain (SOAP-specific) {@code MethodArgumentResolver}s have to be instantiated by
* class name, in order to not introduce a cyclic dependency.
*/
@SuppressWarnings("unchecked")
private void addMethodArgumentResolver(String className, List<MethodArgumentResolver> methodArgumentResolvers) {
try {
Class<MethodArgumentResolver> methodArgumentResolverClass = (Class<MethodArgumentResolver>) ClassUtils
.forName(className, getClassLoader());
.forName(className, getClassLoader());
methodArgumentResolvers.add(BeanUtils.instantiateClass(methodArgumentResolverClass));
} catch (ClassNotFoundException e) {
}
catch (ClassNotFoundException e) {
logger.warn("Could not find \"" + className + "\" on the classpath");
}
}
@@ -297,15 +300,16 @@ public class DefaultMethodEndpointAdapter extends AbstractMethodEndpointAdapter
/**
* Returns the argument array for the given method endpoint.
* <p>
* This implementation iterates over the set {@linkplain #setMethodArgumentResolvers(List) argument resolvers} to
* resolve each argument.
*
* This implementation iterates over the set
* {@linkplain #setMethodArgumentResolvers(List) argument resolvers} to resolve each
* argument.
* @param messageContext the current message context
* @param methodEndpoint the method endpoint to get arguments for
* @return the arguments
* @throws Exception in case of errors
*/
protected Object[] getMethodArguments(MessageContext messageContext, MethodEndpoint methodEndpoint) throws Exception {
protected Object[] getMethodArguments(MessageContext messageContext, MethodEndpoint methodEndpoint)
throws Exception {
MethodParameter[] parameters = methodEndpoint.getMethodParameters();
Object[] args = new Object[parameters.length];
for (int i = 0; i < parameters.length; i++) {
@@ -322,9 +326,9 @@ public class DefaultMethodEndpointAdapter extends AbstractMethodEndpointAdapter
/**
* Handle the return value for the given method endpoint.
* <p>
* This implementation iterates over the set {@linkplain #setMethodReturnValueHandlers(java.util.List)} return value
* handlers} to resolve the return value.
*
* This implementation iterates over the set
* {@linkplain #setMethodReturnValueHandlers(java.util.List)} return value handlers}
* to resolve the return value.
* @param messageContext the current message context
* @param returnValue the return value
* @param methodEndpoint the method endpoint to get arguments for
@@ -339,6 +343,8 @@ public class DefaultMethodEndpointAdapter extends AbstractMethodEndpointAdapter
return;
}
}
throw new IllegalStateException("Return value [" + returnValue + "] not resolved by any MethodReturnValueHandler");
throw new IllegalStateException(
"Return value [" + returnValue + "] not resolved by any MethodReturnValueHandler");
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -26,49 +26,53 @@ 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()}.
* 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()}.
* <p>
* Prefer to use this adapter rather than the plain {@link MarshallingMethodEndpointAdapter} in combination with Java 5
* marshallers, such as the {@link Jaxb2Marshaller}.
* 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 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.
*
* 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() {}
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.
* 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.
* <p>
* Note that all {@link Marshaller} implementations in Spring-WS also implement the {@link Unmarshaller} interface, so
* that you can safely use this constructor.
*
* 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
* @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.
*
* Creates a new {@code GenericMarshallingMethodEndpointAdapter} with the given
* marshaller and unmarshaller.
* @param marshaller the marshaller to use
* @param unmarshaller the unmarshaller to use
*/
@@ -85,10 +89,12 @@ public class GenericMarshallingMethodEndpointAdapter extends MarshallingMethodEn
private boolean supportsReturnType(Method method) {
if (Void.TYPE.equals(method.getReturnType())) {
return true;
} else {
}
else {
if (getMarshaller() instanceof GenericMarshaller) {
return ((GenericMarshaller) getMarshaller()).supports(method.getGenericReturnType());
} else {
}
else {
return getMarshaller().supports(method.getReturnType());
}
}
@@ -97,11 +103,14 @@ public class GenericMarshallingMethodEndpointAdapter extends MarshallingMethodEn
private boolean supportsParameters(Method method) {
if (method.getParameterTypes().length != 1) {
return false;
} else if (getUnmarshaller() instanceof GenericUnmarshaller) {
}
else if (getUnmarshaller() instanceof GenericUnmarshaller) {
GenericUnmarshaller genericUnmarshaller = (GenericUnmarshaller) getUnmarshaller();
return genericUnmarshaller.supports(method.getGenericParameterTypes()[0]);
} else {
}
else {
return getUnmarshaller().supports(method.getParameterTypes()[0]);
}
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -30,7 +30,8 @@ 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:
* Adapter that supports endpoint methods that use marshalling. Supports methods with the
* following signature:
*
* <pre>
* void handleMyMessage(MyUnmarshalledType request);
@@ -42,19 +43,22 @@ import org.springframework.ws.support.MarshallingUtils;
* MyMarshalledType handleMyMessage(MyUnmarshalledType request);
* </pre>
*
* 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}.
* 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}.
* <p>
* This endpoint needs a {@code Marshaller} and {@code Unmarshaller}, both of which can be set using properties.
* This endpoint needs a {@code Marshaller} and {@code Unmarshaller}, both of which can be
* set using properties.
*
* @author Arjen Poutsma
* @see #setMarshaller(org.springframework.oxm.Marshaller)
* @see #setUnmarshaller(org.springframework.oxm.Unmarshaller)
* @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.MarshallingPayloadMethodProcessor
* MarshallingPayloadMethodProcessor}.
* @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 {
@@ -64,24 +68,25 @@ public class MarshallingMethodEndpointAdapter extends AbstractMethodEndpointAdap
private Unmarshaller unmarshaller;
/**
* Creates a new {@code MarshallingMethodEndpointAdapter}. The {@link Marshaller} and {@link Unmarshaller} must be
* injected using properties.
*
* 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() {}
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.
* 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.
* <p>
* Note that all {@link Marshaller} implementations in Spring also implement the {@link Unmarshaller} interface, so
* that you can safely use this constructor.
*
* 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
* @throws IllegalArgumentException when {@code marshaller} does not implement the
* {@link Unmarshaller} interface
*/
public MarshallingMethodEndpointAdapter(Marshaller marshaller) {
Assert.notNull(marshaller, "marshaller must not be null");
@@ -89,15 +94,16 @@ public class MarshallingMethodEndpointAdapter extends AbstractMethodEndpointAdap
throw new IllegalArgumentException("Marshaller [" + marshaller + "] does not implement the Unmarshaller "
+ "interface. Please set an Unmarshaller explicitly by using the "
+ "MarshallingMethodEndpointAdapter(Marshaller, Unmarshaller) constructor.");
} else {
}
else {
this.setMarshaller(marshaller);
this.setUnmarshaller((Unmarshaller) marshaller);
}
}
/**
* Creates a new {@code MarshallingMethodEndpointAdapter} with the given marshaller and unmarshaller.
*
* Creates a new {@code MarshallingMethodEndpointAdapter} with the given marshaller
* and unmarshaller.
* @param marshaller the marshaller to use
* @param unmarshaller the unmarshaller to use
*/
@@ -161,8 +167,8 @@ public class MarshallingMethodEndpointAdapter extends AbstractMethodEndpointAdap
}
/**
* Supports a method with a single, unmarshallable parameter, and that return {@code void} or a marshallable type.
*
* 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)
*/
@@ -179,8 +185,10 @@ public class MarshallingMethodEndpointAdapter extends AbstractMethodEndpointAdap
private boolean supportsParameters(Method method) {
if (method.getParameterTypes().length != 1) {
return false;
} else {
}
else {
return getUnmarshaller().supports(method.getParameterTypes()[0]);
}
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -23,9 +23,11 @@ import org.springframework.ws.server.endpoint.MessageEndpoint;
import org.springframework.ws.soap.server.SoapMessageDispatcher;
/**
* Adapter to use a {@code MessageEndpoint} as the endpoint for a {@code EndpointInvocationChain}.
* Adapter to use a {@code MessageEndpoint} as the endpoint for a
* {@code EndpointInvocationChain}.
* <p>
* This adapter is registered by default by the {@link MessageDispatcher} and {@link SoapMessageDispatcher}.
* This adapter is registered by default by the {@link MessageDispatcher} and
* {@link SoapMessageDispatcher}.
*
* @author Arjen Poutsma
* @see org.springframework.ws.server.EndpointInvocationChain
@@ -42,4 +44,5 @@ public class MessageEndpointAdapter implements EndpointAdapter {
public void invoke(MessageContext messageContext, Object endpoint) throws Exception {
((MessageEndpoint) endpoint).invoke(messageContext);
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -24,22 +24,26 @@ 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:
* Adapter that supports endpoint methods with message contexts. Supports methods with the
* following signature:
*
* <pre>
* void handleMyMessage(MessageContext request);
* </pre>
*
* 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}.
* 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}.
* <p>
* This adapter is registered by default by the {@link MessageDispatcher} and {@link SoapMessageDispatcher}.
* 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 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 {

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -27,9 +27,11 @@ import org.springframework.ws.soap.server.SoapMessageDispatcher;
import org.springframework.xml.transform.TransformerObjectSupport;
/**
* Adapter to use a {@code PayloadEndpoint} as the endpoint for a {@code EndpointInvocationChain}.
* Adapter to use a {@code PayloadEndpoint} as the endpoint for a
* {@code EndpointInvocationChain}.
* <p>
* This adapter is registered by default by the {@link MessageDispatcher} and {@link SoapMessageDispatcher}.
* This adapter is registered by default by the {@link MessageDispatcher} and
* {@link SoapMessageDispatcher}.
*
* @author Arjen Poutsma
* @see org.springframework.ws.server.endpoint.PayloadEndpoint
@@ -53,4 +55,5 @@ public class PayloadEndpointAdapter extends TransformerObjectSupport implements
transform(responseSource, response.getPayloadResult());
}
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -27,7 +27,8 @@ 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:
* Adapter that supports endpoint methods that use marshalling. Supports methods with the
* following signature:
*
* <pre>
* void handleMyMessage(Source request);
@@ -39,16 +40,19 @@ import org.springframework.ws.soap.server.SoapMessageDispatcher;
* Source handleMyMessage(Source request);
* </pre>
*
* 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}.
* 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}.
* <p>
* This adapter is registered by default by the {@link MessageDispatcher} and {@link SoapMessageDispatcher}.
* 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 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 {
@@ -56,8 +60,9 @@ 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]);
return (Void.TYPE.isAssignableFrom(method.getReturnType())
|| Source.class.isAssignableFrom(method.getReturnType())) && method.getParameterTypes().length == 1
&& Source.class.isAssignableFrom(method.getParameterTypes()[0]);
}
@@ -71,4 +76,5 @@ public class PayloadMethodEndpointAdapter extends AbstractMethodEndpointAdapter
transform(responseSource, response.getPayloadResult());
}
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -29,19 +29,21 @@ 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;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
* Adapter that supports endpoint methods that use XPath expressions. Supports methods with the following signature:
* Adapter that supports endpoint methods that use XPath expressions. Supports methods
* with the following signature:
*
* <pre>
* void handleMyMessage(@XPathParam("/root/child/text") String param);
@@ -54,9 +56,9 @@ import org.w3c.dom.NodeList;
* &#64;XPathParam("/root/child/number") double param2);
* </pre>
*
* 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:
* 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:
* <ul>
* <li>{@code boolean}, or {@link Boolean}</li>
* <li>{@code double}, or {@link Double}</li>
@@ -67,9 +69,10 @@ import org.w3c.dom.NodeList;
*
* @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.XPathParamMethodArgumentResolver
* XPathParamMethodArgumentResolver}.
* @deprecated as of Spring Web Services 2.0, in favor of
* {@link DefaultMethodEndpointAdapter} and
* {@link org.springframework.ws.server.endpoint.adapter.method.XPathParamMethodArgumentResolver
* XPathParamMethodArgumentResolver}.
*/
@Deprecated
public class XPathParamAnnotationMethodEndpointAdapter extends AbstractMethodEndpointAdapter
@@ -89,7 +92,10 @@ public class XPathParamAnnotationMethodEndpointAdapter extends AbstractMethodEnd
xpathFactory = XPathFactory.newInstance();
}
/** Supports methods with @XPathParam parameters, and return either {@code Source} or nothing. */
/**
* Supports methods with @XPathParam parameters, and return either {@code Source} or
* nothing.
*/
@Override
protected boolean supportsInternal(MethodEndpoint methodEndpoint) {
Method method = methodEndpoint.getMethod();
@@ -142,15 +148,21 @@ public class XPathParamAnnotationMethodEndpointAdapter extends AbstractMethodEnd
QName conversionType;
if (Boolean.class.isAssignableFrom(parameterTypes[i]) || Boolean.TYPE.isAssignableFrom(parameterTypes[i])) {
conversionType = XPathConstants.BOOLEAN;
} else if (Double.class.isAssignableFrom(parameterTypes[i]) || Double.TYPE.isAssignableFrom(parameterTypes[i])) {
}
else if (Double.class.isAssignableFrom(parameterTypes[i])
|| Double.TYPE.isAssignableFrom(parameterTypes[i])) {
conversionType = XPathConstants.NUMBER;
} else if (Node.class.isAssignableFrom(parameterTypes[i])) {
}
else if (Node.class.isAssignableFrom(parameterTypes[i])) {
conversionType = XPathConstants.NODE;
} else if (NodeList.class.isAssignableFrom(parameterTypes[i])) {
}
else if (NodeList.class.isAssignableFrom(parameterTypes[i])) {
conversionType = XPathConstants.NODESET;
} else if (String.class.isAssignableFrom(parameterTypes[i])) {
}
else if (String.class.isAssignableFrom(parameterTypes[i])) {
conversionType = XPathConstants.STRING;
} else {
}
else {
throw new IllegalArgumentException("Invalid parameter type [" + parameterTypes[i] + "]. "
+ "Supported are: Boolean, Double, Node, NodeList, and String.");
}
@@ -171,7 +183,6 @@ public class XPathParamAnnotationMethodEndpointAdapter extends AbstractMethodEnd
/**
* Returns the root element of the given source.
*
* @param source the source to get the root element from
* @return the root element
*/

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -30,8 +30,9 @@ import org.springframework.ws.server.endpoint.annotation.ResponsePayload;
import org.springframework.xml.transform.TransformerObjectSupport;
/**
* Abstract base class for {@link MethodArgumentResolver} and {@link MethodReturnValueHandler} implementations based on
* {@link RequestPayload} and {@link ResponsePayload} annotations.
* Abstract base class for {@link MethodArgumentResolver} and
* {@link MethodReturnValueHandler} implementations based on {@link RequestPayload} and
* {@link ResponsePayload} annotations.
*
* @author Arjen Poutsma
* @since 2.0
@@ -44,25 +45,28 @@ public abstract class AbstractPayloadMethodProcessor extends TransformerObjectSu
/**
* {@inheritDoc}
* <p>
* This implementation gets checks if the given parameter is annotated with {@link RequestPayload}, and invokes
* {@link #supportsRequestPayloadParameter(org.springframework.core.MethodParameter)} afterwards.
* This implementation gets checks if the given parameter is annotated with
* {@link RequestPayload}, and invokes
* {@link #supportsRequestPayloadParameter(org.springframework.core.MethodParameter)}
* afterwards.
*/
@Override
public final boolean supportsParameter(MethodParameter parameter) {
Assert.isTrue(parameter.getParameterIndex() >= 0, "Parameter index smaller than 0");
if (parameter.getParameterAnnotation(RequestPayload.class) == null) {
return false;
} else {
}
else {
return supportsRequestPayloadParameter(parameter);
}
}
/**
* Indicates whether the given {@linkplain MethodParameter method parameter}, annotated with {@link RequestPayload},
* is supported by this resolver.
*
* Indicates whether the given {@linkplain MethodParameter method parameter},
* annotated with {@link RequestPayload}, is supported by this resolver.
* @param parameter the method parameter to check
* @return {@code true} if this resolver supports the supplied parameter; {@code false} otherwise
* @return {@code true} if this resolver supports the supplied parameter;
* {@code false} otherwise
*/
protected abstract boolean supportsRequestPayloadParameter(MethodParameter parameter);
@@ -71,31 +75,33 @@ public abstract class AbstractPayloadMethodProcessor extends TransformerObjectSu
/**
* {@inheritDoc}
* <p>
* This implementation gets checks if the method of the given return type is annotated with {@link ResponsePayload},
* and invokes {@link #supportsResponsePayloadReturnType(org.springframework.core.MethodParameter)} afterwards.
* This implementation gets checks if the method of the given return type is annotated
* with {@link ResponsePayload}, and invokes
* {@link #supportsResponsePayloadReturnType(org.springframework.core.MethodParameter)}
* afterwards.
*/
@Override
public final boolean supportsReturnType(MethodParameter returnType) {
Assert.isTrue(returnType.getParameterIndex() == -1, "Parameter index is not -1");
if (returnType.getMethodAnnotation(ResponsePayload.class) == null) {
return false;
} else {
}
else {
return supportsResponsePayloadReturnType(returnType);
}
}
/**
* Indicates whether the given {@linkplain MethodParameter method return type}, annotated with
* {@link ResponsePayload}, is supported.
*
* Indicates whether the given {@linkplain MethodParameter method return type},
* annotated with {@link ResponsePayload}, is supported.
* @param returnType the method parameter to check
* @return {@code true} if this resolver supports the supplied return type; {@code false} otherwise
* @return {@code true} if this resolver supports the supplied return type;
* {@code false} otherwise
*/
protected abstract boolean supportsResponsePayloadReturnType(MethodParameter returnType);
/**
* Converts the given source to a byte array input stream.
*
* @param source the source to convert
* @return the input stream
* @throws javax.xml.transform.TransformerException in case of transformation errors
@@ -105,4 +111,5 @@ public abstract class AbstractPayloadMethodProcessor extends TransformerObjectSu
transform(source, new StreamResult(bos));
return new ByteArrayInputStream(bos.toByteArray());
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -24,8 +24,8 @@ import org.springframework.ws.context.MessageContext;
import org.springframework.ws.server.endpoint.annotation.RequestPayload;
/**
* Abstract base class for {@link MethodArgumentResolver} and {@link MethodReturnValueHandler} implementations based on
* {@link Source}s.
* Abstract base class for {@link MethodArgumentResolver} and
* {@link MethodReturnValueHandler} implementations based on {@link Source}s.
*
* @author Arjen Poutsma
* @since 2.0
@@ -47,8 +47,8 @@ public abstract class AbstractPayloadSourceMethodProcessor extends AbstractPaylo
}
/**
* Resolves the given parameter, annotated with {@link RequestPayload}, into a method argument.
*
* Resolves the given parameter, annotated with {@link RequestPayload}, into a method
* argument.
* @param parameter the parameter to resolve to an argument
* @param requestPayload the request payload
* @return the resolved argument. May be {@code null}.
@@ -73,7 +73,6 @@ public abstract class AbstractPayloadSourceMethodProcessor extends AbstractPaylo
/**
* Creates a response payload for the given return value.
*
* @param returnType the return type to handle
* @param returnValue the return value to handle
* @return the response payload

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -27,8 +27,8 @@ import org.springframework.ws.context.MessageContext;
import org.springframework.ws.support.MarshallingUtils;
/**
* Implementation of {@link MethodArgumentResolver} and {@link MethodReturnValueHandler} that uses {@link Marshaller}
* and {@link Unmarshaller} to support marshalled objects.
* Implementation of {@link MethodArgumentResolver} and {@link MethodReturnValueHandler}
* that uses {@link Marshaller} and {@link Unmarshaller} to support marshalled objects.
*
* @author Arjen Poutsma
* @since 2.0
@@ -40,24 +40,25 @@ public class MarshallingPayloadMethodProcessor extends AbstractPayloadMethodProc
private Unmarshaller unmarshaller;
/**
* Creates a new {@code MarshallingPayloadMethodProcessor}. The {@link Marshaller} and {@link Unmarshaller} must be
* injected using properties.
*
* Creates a new {@code MarshallingPayloadMethodProcessor}. The {@link Marshaller} and
* {@link Unmarshaller} must be injected using properties.
* @see #setMarshaller(Marshaller)
* @see #setUnmarshaller(Unmarshaller)
*/
public MarshallingPayloadMethodProcessor() {}
public MarshallingPayloadMethodProcessor() {
}
/**
* Creates a new {@code MarshallingPayloadMethodProcessor} 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.
* Creates a new {@code MarshallingPayloadMethodProcessor} 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.
* <p>
* Note that all {@link Marshaller} implementations in Spring also implement the {@link Unmarshaller} interface, so
* that you can safely use this constructor.
*
* 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
* @throws IllegalArgumentException when {@code marshaller} does not implement the
* {@link Unmarshaller} interface
*/
public MarshallingPayloadMethodProcessor(Marshaller marshaller) {
Assert.notNull(marshaller, "marshaller must not be null");
@@ -67,8 +68,8 @@ public class MarshallingPayloadMethodProcessor extends AbstractPayloadMethodProc
}
/**
* Creates a new {@code MarshallingPayloadMethodProcessor} with the given marshaller and unmarshaller.
*
* Creates a new {@code MarshallingPayloadMethodProcessor} with the given marshaller
* and unmarshaller.
* @param marshaller the marshaller to use
* @param unmarshaller the unmarshaller to use
*/
@@ -112,9 +113,11 @@ public class MarshallingPayloadMethodProcessor extends AbstractPayloadMethodProc
Unmarshaller unmarshaller = getUnmarshaller();
if (unmarshaller == null) {
return false;
} else if (unmarshaller instanceof GenericUnmarshaller) {
}
else if (unmarshaller instanceof GenericUnmarshaller) {
return ((GenericUnmarshaller) unmarshaller).supports(parameter.getGenericParameterType());
} else {
}
else {
return unmarshaller.supports(parameter.getParameterType());
}
}
@@ -137,10 +140,12 @@ public class MarshallingPayloadMethodProcessor extends AbstractPayloadMethodProc
Marshaller marshaller = getMarshaller();
if (marshaller == null) {
return false;
} else if (marshaller instanceof GenericMarshaller) {
}
else if (marshaller instanceof GenericMarshaller) {
GenericMarshaller genericMarshaller = (GenericMarshaller) marshaller;
return genericMarshaller.supports(returnType.getGenericParameterType());
} else {
}
else {
return marshaller.supports(returnType.getParameterType());
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -20,7 +20,8 @@ import org.springframework.core.MethodParameter;
import org.springframework.ws.context.MessageContext;
/**
* Implementation of {@link MethodArgumentResolver} that supports {@link MessageContext} arguments.
* Implementation of {@link MethodArgumentResolver} that supports {@link MessageContext}
* arguments.
*
* @author Arjen Poutsma
* @since 2.0
@@ -36,4 +37,5 @@ public class MessageContextMethodArgumentResolver implements MethodArgumentResol
public MessageContext resolveArgument(MessageContext messageContext, MethodParameter parameter) throws Exception {
return messageContext;
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -20,9 +20,10 @@ import org.springframework.core.MethodParameter;
import org.springframework.ws.context.MessageContext;
/**
* Strategy interface used to resolve method parameters into arguments. This interface is used to allow the
* {@link org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter DefaultMethodEndpointAdapter} to
* be indefinitely extensible.
* Strategy interface used to resolve method parameters into arguments. This interface is
* used to allow the
* {@link org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter
* DefaultMethodEndpointAdapter} to be indefinitely extensible.
*
* @author Arjen Poutsma
* @since 2.0
@@ -30,20 +31,20 @@ import org.springframework.ws.context.MessageContext;
public interface MethodArgumentResolver {
/**
* Indicates whether the given {@linkplain MethodParameter method parameter} is supported by this resolver.
*
* Indicates whether the given {@linkplain MethodParameter method parameter} is
* supported by this resolver.
* @param parameter the method parameter to check
* @return {@code true} if this resolver supports the supplied parameter; {@code false} otherwise
* @return {@code true} if this resolver supports the supplied parameter;
* {@code false} otherwise
*/
boolean supportsParameter(MethodParameter parameter);
/**
* Resolves the given parameter into a method argument.
*
* @param messageContext the current message context
* @param parameter the parameter to resolve to an argument. This parameter must have previously been passed to the
* {@link #supportsParameter(MethodParameter)} method of this interface, which must have returned
* {@code true}.
* @param parameter the parameter to resolve to an argument. This parameter must have
* previously been passed to the {@link #supportsParameter(MethodParameter)} method of
* this interface, which must have returned {@code true}.
* @return the resolved argument. May be {@code null}.
* @throws Exception in case of errors
*/

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -20,9 +20,9 @@ import org.springframework.core.MethodParameter;
import org.springframework.ws.context.MessageContext;
/**
* Strategy interface used to handle method return values. This interface is used to allow the
* {@link org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter DefaultMethodEndpointAdapter} to
* be indefinitely extensible.
* Strategy interface used to handle method return values. This interface is used to allow
* the {@link org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter
* DefaultMethodEndpointAdapter} to be indefinitely extensible.
*
* @author Arjen Poutsma
* @since 2.0
@@ -30,20 +30,20 @@ import org.springframework.ws.context.MessageContext;
public interface MethodReturnValueHandler {
/**
* Indicates whether the given {@linkplain MethodParameter method return type} is supported by this handler.
*
* Indicates whether the given {@linkplain MethodParameter method return type} is
* supported by this handler.
* @param returnType the method return type to check
* @return {@code true} if this handler supports the supplied return type; {@code false} otherwise
* @return {@code true} if this handler supports the supplied return type;
* {@code false} otherwise
*/
boolean supportsReturnType(MethodParameter returnType);
/**
* Handles the given return value.
*
* @param messageContext the current message context
* @param returnType the return type to handle. This type must have previously been passed to the
* {@link #supportsReturnType(MethodParameter)} method of this interface, which must have returned
* {@code true}.
* @param returnType the return type to handle. This type must have previously been
* passed to the {@link #supportsReturnType(MethodParameter)} method of this
* interface, which must have returned {@code true}.
* @param returnValue the return value to handle
* @throws Exception in case of errors
*/

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -30,16 +30,17 @@ import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.stax.StAXSource;
import javax.xml.transform.stream.StreamSource;
import org.springframework.core.MethodParameter;
import org.springframework.xml.JaxpVersion;
import org.springframework.xml.XMLInputFactoryUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.xml.sax.InputSource;
import org.springframework.core.MethodParameter;
import org.springframework.xml.JaxpVersion;
import org.springframework.xml.XMLInputFactoryUtils;
/**
* Implementation of {@link MethodArgumentResolver} and {@link MethodReturnValueHandler} that supports {@link Source}
* objects.
* Implementation of {@link MethodArgumentResolver} and {@link MethodReturnValueHandler}
* that supports {@link Source} objects.
*
* @author Arjen Poutsma
* @since 2.0
@@ -67,21 +68,26 @@ public class SourcePayloadMethodProcessor extends AbstractPayloadSourceMethodPro
Node node = domResult.getNode();
if (node.getNodeType() == Node.DOCUMENT_NODE) {
return new DOMSource(((Document) node).getDocumentElement());
} else {
}
else {
return new DOMSource(domResult.getNode());
}
} else if (SAXSource.class.isAssignableFrom(parameterType)) {
}
else if (SAXSource.class.isAssignableFrom(parameterType)) {
ByteArrayInputStream bis = convertToByteArrayInputStream(requestPayload);
InputSource inputSource = new InputSource(bis);
return new SAXSource(inputSource);
} else if (StreamSource.class.isAssignableFrom(parameterType)) {
}
else if (StreamSource.class.isAssignableFrom(parameterType)) {
ByteArrayInputStream bis = convertToByteArrayInputStream(requestPayload);
return new StreamSource(bis);
} else if (JaxpVersion.isAtLeastJaxp14() && Jaxp14StaxHandler.isStaxSource(parameterType)) {
}
else if (JaxpVersion.isAtLeastJaxp14() && Jaxp14StaxHandler.isStaxSource(parameterType)) {
XMLStreamReader streamReader;
try {
streamReader = inputFactory.createXMLStreamReader(requestPayload);
} catch (UnsupportedOperationException | XMLStreamException ignored) {
}
catch (UnsupportedOperationException | XMLStreamException ignored) {
streamReader = null;
}
if (streamReader == null) {
@@ -110,12 +116,12 @@ public class SourcePayloadMethodProcessor extends AbstractPayloadSourceMethodPro
}
/**
* Create a {@code XMLInputFactory} that this resolver will use to create {@link javax.xml.stream.XMLStreamReader} and
* Create a {@code XMLInputFactory} that this resolver will use to create
* {@link javax.xml.stream.XMLStreamReader} and
* {@link javax.xml.stream.XMLEventReader} objects.
* <p>
* Can be overridden in subclasses, adding further initialization of the factory. The resulting factory is cached, so
* this method will only be called once.
*
* Can be overridden in subclasses, adding further initialization of the factory. The
* resulting factory is cached, so this method will only be called once.
* @return the created factory
*/
protected XMLInputFactory createXmlInputFactory() {
@@ -169,6 +175,7 @@ public class SourcePayloadMethodProcessor extends AbstractPayloadSourceMethodPro
}
};
}
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -35,8 +35,8 @@ import org.springframework.xml.XMLInputFactoryUtils;
import org.springframework.xml.transform.TransformerObjectSupport;
/**
* Implementation of {@link MethodArgumentResolver} that supports StAX {@link XMLStreamReader} and
* {@link XMLEventReader} arguments.
* Implementation of {@link MethodArgumentResolver} that supports StAX
* {@link XMLStreamReader} and {@link XMLEventReader} arguments.
*
* @author Arjen Poutsma
* @since 2.0
@@ -49,7 +49,8 @@ public class StaxPayloadMethodArgumentResolver extends TransformerObjectSupport
public boolean supportsParameter(MethodParameter parameter) {
if (parameter.getParameterAnnotation(RequestPayload.class) == null) {
return false;
} else {
}
else {
Class<?> parameterType = parameter.getParameterType();
return XMLStreamReader.class.equals(parameterType) || XMLEventReader.class.equals(parameterType);
}
@@ -65,7 +66,8 @@ public class StaxPayloadMethodArgumentResolver extends TransformerObjectSupport
Class<?> parameterType = parameter.getParameterType();
if (XMLStreamReader.class.equals(parameterType)) {
return resolveStreamReader(source);
} else if (XMLEventReader.class.equals(parameterType)) {
}
else if (XMLEventReader.class.equals(parameterType)) {
return resolveEventReader(source);
}
throw new UnsupportedOperationException();
@@ -80,7 +82,8 @@ public class StaxPayloadMethodArgumentResolver extends TransformerObjectSupport
if (eventReader != null) {
try {
streamReader = StaxUtils.createEventStreamReader(eventReader);
} catch (XMLStreamException ex) {
}
catch (XMLStreamException ex) {
streamReader = null;
}
}
@@ -89,7 +92,8 @@ public class StaxPayloadMethodArgumentResolver extends TransformerObjectSupport
if (streamReader == null) {
try {
streamReader = inputFactory.createXMLStreamReader(requestSource);
} catch (XMLStreamException | UnsupportedOperationException ex) {
}
catch (XMLStreamException | UnsupportedOperationException ex) {
streamReader = null;
}
}
@@ -110,7 +114,8 @@ public class StaxPayloadMethodArgumentResolver extends TransformerObjectSupport
if (streamReader != null) {
try {
eventReader = inputFactory.createXMLEventReader(streamReader);
} catch (XMLStreamException ex) {
}
catch (XMLStreamException ex) {
eventReader = null;
}
}
@@ -120,7 +125,8 @@ public class StaxPayloadMethodArgumentResolver extends TransformerObjectSupport
if (eventReader == null) {
try {
eventReader = inputFactory.createXMLEventReader(requestSource);
} catch (XMLStreamException | UnsupportedOperationException ex) {
}
catch (XMLStreamException | UnsupportedOperationException ex) {
eventReader = null;
}
}
@@ -133,12 +139,11 @@ public class StaxPayloadMethodArgumentResolver extends TransformerObjectSupport
}
/**
* Create a {@code XMLInputFactory} that this resolver will use to create {@link XMLStreamReader} and
* {@link XMLEventReader} objects.
* Create a {@code XMLInputFactory} that this resolver will use to create
* {@link XMLStreamReader} and {@link XMLEventReader} objects.
* <p>
* Can be overridden in subclasses, adding further initialization of the factory. The resulting factory is cached, so
* this method will only be called once.
*
* Can be overridden in subclasses, adding further initialization of the factory. The
* resulting factory is cached, so this method will only be called once.
* @return the created factory
*/
protected XMLInputFactory createXmlInputFactory() {

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -25,6 +25,11 @@ 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.core.MethodParameter;
import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.support.ConversionServiceFactory;
@@ -33,18 +38,17 @@ import org.springframework.ws.context.MessageContext;
import org.springframework.ws.server.endpoint.annotation.XPathParam;
import org.springframework.ws.server.endpoint.support.NamespaceUtils;
import org.springframework.xml.transform.TransformerHelper;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
* Implementation of {@link MethodArgumentResolver} that supports the {@link XPathParam @XPathParam} annotation.
* Implementation of {@link MethodArgumentResolver} that supports the
* {@link XPathParam @XPathParam} annotation.
* <p>
* This resolver supports parameters annotated with {@link XPathParam @XPathParam} that specifies the XPath expression
* that should be bound to that parameter. The parameter can either a "natively supported" XPath type ({@link Boolean
* boolean}, {@link Double double}, {@link String}, {@link Node}, or {@link NodeList}), or a type that is
* {@linkplain ConversionService#canConvert(Class, Class) supported} by the {@link ConversionService}.
* This resolver supports parameters annotated with {@link XPathParam @XPathParam} that
* specifies the XPath expression that should be bound to that parameter. The parameter
* can either a "natively supported" XPath type ({@link Boolean boolean}, {@link Double
* double}, {@link String}, {@link Node}, or {@link NodeList}), or a type that is
* {@linkplain ConversionService#canConvert(Class, Class) supported} by the
* {@link ConversionService}.
*
* @author Arjen Poutsma
* @since 2.0
@@ -60,7 +64,9 @@ public class XPathParamMethodArgumentResolver implements MethodArgumentResolver
/**
* Sets the conversion service to use.
* <p>
* Defaults to the {@linkplain ConversionServiceFactory#createDefaultConversionService() default conversion service}.
* Defaults to the
* {@linkplain ConversionServiceFactory#createDefaultConversionService() default
* conversion service}.
*/
public void setConversionService(ConversionService conversionService) {
this.conversionService = conversionService;
@@ -76,11 +82,13 @@ public class XPathParamMethodArgumentResolver implements MethodArgumentResolver
return false;
}
Class<?> parameterType = parameter.getParameterType();
if (Boolean.class.equals(parameterType) || Boolean.TYPE.equals(parameterType) || Double.class.equals(parameterType)
|| Double.TYPE.equals(parameterType) || Node.class.isAssignableFrom(parameterType)
|| NodeList.class.isAssignableFrom(parameterType) || String.class.isAssignableFrom(parameterType)) {
if (Boolean.class.equals(parameterType) || Boolean.TYPE.equals(parameterType)
|| Double.class.equals(parameterType) || Double.TYPE.equals(parameterType)
|| Node.class.isAssignableFrom(parameterType) || NodeList.class.isAssignableFrom(parameterType)
|| String.class.isAssignableFrom(parameterType)) {
return true;
} else {
}
else {
return conversionService.canConvert(String.class, parameterType);
}
}
@@ -108,15 +116,20 @@ public class XPathParamMethodArgumentResolver implements MethodArgumentResolver
private QName getReturnType(Class<?> parameterType) {
if (Boolean.class.equals(parameterType) || Boolean.TYPE.equals(parameterType)) {
return XPathConstants.BOOLEAN;
} else if (Double.class.equals(parameterType) || Double.TYPE.equals(parameterType)) {
}
else if (Double.class.equals(parameterType) || Double.TYPE.equals(parameterType)) {
return XPathConstants.NUMBER;
} else if (Node.class.equals(parameterType)) {
}
else if (Node.class.equals(parameterType)) {
return XPathConstants.NODE;
} else if (NodeList.class.equals(parameterType)) {
}
else if (NodeList.class.equals(parameterType)) {
return XPathConstants.NODESET;
} else if (String.class.equals(parameterType)) {
}
else if (String.class.equals(parameterType)) {
return XPathConstants.STRING;
} else {
}
else {
return null;
}
}
@@ -135,11 +148,11 @@ public class XPathParamMethodArgumentResolver implements MethodArgumentResolver
}
/**
* Create a {@code XPathFactory} that this resolver will use to create {@link XPath} objects.
* Create a {@code XPathFactory} that this resolver will use to create {@link XPath}
* objects.
* <p>
* Can be overridden in subclasses, adding further initialization of the factory. The resulting factory is cached, so
* this method will only be called once.
*
* Can be overridden in subclasses, adding further initialization of the factory. The
* resulting factory is cached, so this method will only be called once.
* @return the created factory
*/
protected XPathFactory createXPathFactory() {

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -25,12 +25,15 @@ import org.dom4j.Element;
import org.dom4j.io.DOMReader;
import org.dom4j.io.DocumentResult;
import org.dom4j.io.DocumentSource;
import org.springframework.core.MethodParameter;
import org.springframework.ws.server.endpoint.adapter.method.AbstractPayloadSourceMethodProcessor;
/**
* Implementation of {@link org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResolver
* MethodArgumentResolver} and {@link org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler
* Implementation of
* {@link org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResolver
* MethodArgumentResolver} and
* {@link org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler
* MethodReturnValueHandler} that supports dom4j {@linkplain Element elements}.
*
* @author Arjen Poutsma

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -20,15 +20,18 @@ import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
import org.springframework.core.MethodParameter;
import org.springframework.ws.server.endpoint.adapter.method.AbstractPayloadSourceMethodProcessor;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.springframework.core.MethodParameter;
import org.springframework.ws.server.endpoint.adapter.method.AbstractPayloadSourceMethodProcessor;
/**
* Implementation of {@link org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResolver
* MethodArgumentResolver} and {@link org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler
* Implementation of
* {@link org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResolver
* MethodArgumentResolver} and
* {@link org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler
* MethodReturnValueHandler} that supports W3C DOM {@linkplain Element elements}.
*
* @author Arjen Poutsma
@@ -47,7 +50,8 @@ public class DomPayloadMethodProcessor extends AbstractPayloadSourceMethodProces
protected Node resolveRequestPayloadArgument(MethodParameter parameter, Source requestPayload) throws Exception {
if (requestPayload instanceof DOMSource) {
return resolveArgumentDomSource(parameter, (DOMSource) requestPayload);
} else {
}
else {
DOMResult domResult = new DOMResult();
transform(requestPayload, domResult);
DOMSource domSource = new DOMSource(domResult.getNode());
@@ -60,7 +64,8 @@ public class DomPayloadMethodProcessor extends AbstractPayloadSourceMethodProces
Node requestNode = requestSource.getNode();
if (parameterType.isAssignableFrom(requestNode.getClass())) {
return requestNode;
} else if (Element.class.equals(parameterType) && requestNode instanceof Document) {
}
else if (Element.class.equals(parameterType) && requestNode instanceof Document) {
Document document = (Document) requestNode;
return document.getDocumentElement();
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -24,13 +24,16 @@ import org.jdom2.Element;
import org.jdom2.input.DOMBuilder;
import org.jdom2.transform.JDOMResult;
import org.jdom2.transform.JDOMSource;
import org.springframework.core.MethodParameter;
import org.springframework.ws.server.endpoint.adapter.method.AbstractPayloadSourceMethodProcessor;
import org.w3c.dom.Node;
import org.springframework.core.MethodParameter;
import org.springframework.ws.server.endpoint.adapter.method.AbstractPayloadSourceMethodProcessor;
/**
* Implementation of {@link org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResolver
* MethodArgumentResolver} and {@link org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler
* Implementation of
* {@link org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResolver
* MethodArgumentResolver} and
* {@link org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler
* MethodReturnValueHandler} that supports JDOM {@linkplain Element elements}.
*
* @author Arjen Poutsma
@@ -50,7 +53,8 @@ public class JDomPayloadMethodProcessor extends AbstractPayloadSourceMethodProce
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) {
}
else if (node.getNodeType() == Node.DOCUMENT_NODE) {
Document document = domBuilder.build((org.w3c.dom.Document) node);
return document.getRootElement();
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -16,12 +16,6 @@
package org.springframework.ws.server.endpoint.adapter.method.dom;
import nu.xom.Builder;
import nu.xom.Document;
import nu.xom.Element;
import nu.xom.ParsingException;
import nu.xom.converters.DOMConverter;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -32,14 +26,22 @@ import javax.xml.transform.Source;
import javax.xml.transform.TransformerException;
import javax.xml.transform.dom.DOMSource;
import nu.xom.Builder;
import nu.xom.Document;
import nu.xom.Element;
import nu.xom.ParsingException;
import nu.xom.converters.DOMConverter;
import org.w3c.dom.DOMImplementation;
import org.springframework.core.MethodParameter;
import org.springframework.ws.server.endpoint.adapter.method.AbstractPayloadSourceMethodProcessor;
import org.springframework.xml.DocumentBuilderFactoryUtils;
import org.w3c.dom.DOMImplementation;
/**
* Implementation of {@link org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResolver
* MethodArgumentResolver} and {@link org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler
* Implementation of
* {@link org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResolver
* MethodArgumentResolver} and
* {@link org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler
* MethodReturnValueHandler} that supports XOM {@linkplain Element elements}.
*
* @author Arjen Poutsma
@@ -61,7 +63,8 @@ public class XomPayloadMethodProcessor extends AbstractPayloadSourceMethodProces
org.w3c.dom.Node node = ((DOMSource) requestPayload).getNode();
if (node.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
return DOMConverter.convert((org.w3c.dom.Element) node);
} else if (node.getNodeType() == org.w3c.dom.Node.DOCUMENT_NODE) {
}
else if (node.getNodeType() == org.w3c.dom.Node.DOCUMENT_NODE) {
Document document = DOMConverter.convert((org.w3c.dom.Document) node);
return document.getRootElement();
}
@@ -97,11 +100,11 @@ public class XomPayloadMethodProcessor extends AbstractPayloadSourceMethodProces
}
/**
* Create a {@code DocumentBuilderFactory} that this resolver will use to create response payloads.
* Create a {@code DocumentBuilderFactory} that this resolver will use to create
* response payloads.
* <p>
* Can be overridden in subclasses, adding further initialization of the factory. The resulting factory is cached, so
* this method will only be called once.
*
* Can be overridden in subclasses, adding further initialization of the factory. The
* resulting factory is cached, so this method will only be called once.
* @return the created factory
*/
protected DocumentBuilderFactory createDocumentBuilderFactory() {

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -16,14 +16,6 @@
package org.springframework.ws.server.endpoint.adapter.method.jaxb;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBElement;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.JAXBIntrospector;
import jakarta.xml.bind.Marshaller;
import jakarta.xml.bind.Unmarshaller;
import jakarta.xml.bind.UnmarshallerHandler;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -45,6 +37,19 @@ import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBElement;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.JAXBIntrospector;
import jakarta.xml.bind.Marshaller;
import jakarta.xml.bind.Unmarshaller;
import jakarta.xml.bind.UnmarshallerHandler;
import org.w3c.dom.Node;
import org.xml.sax.ContentHandler;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
import org.xml.sax.ext.LexicalHandler;
import org.springframework.core.MethodParameter;
import org.springframework.util.Assert;
import org.springframework.ws.WebServiceMessage;
@@ -53,19 +58,18 @@ import org.springframework.ws.server.endpoint.adapter.method.AbstractPayloadMeth
import org.springframework.ws.stream.StreamingPayload;
import org.springframework.ws.stream.StreamingWebServiceMessage;
import org.springframework.xml.transform.TraxUtils;
import org.w3c.dom.Node;
import org.xml.sax.ContentHandler;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
import org.xml.sax.ext.LexicalHandler;
/**
* Abstract base class for {@link org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResolver
* MethodArgumentResolver} and {@link org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler
* MethodReturnValueHandler} implementations that use JAXB2. Creates {@link JAXBContext} object lazily, and offers
* {@linkplain #marshalToResponsePayload(org.springframework.ws.context.MessageContext, Class, Object) marshalling} and
* {@linkplain #unmarshalFromRequestPayload(org.springframework.ws.context.MessageContext, Class) unmarshalling}
* methods.
* Abstract base class for
* {@link org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResolver
* MethodArgumentResolver} and
* {@link org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler
* MethodReturnValueHandler} implementations that use JAXB2. Creates {@link JAXBContext}
* object lazily, and offers
* {@linkplain #marshalToResponsePayload(org.springframework.ws.context.MessageContext, Class, Object)
* marshalling} and
* {@linkplain #unmarshalFromRequestPayload(org.springframework.ws.context.MessageContext, Class)
* unmarshalling} methods.
*
* @author Arjen Poutsma
* @since 2.0
@@ -86,8 +90,8 @@ public abstract class AbstractJaxb2PayloadMethodProcessor extends AbstractPayloa
Object returnValue) throws Exception;
/**
* Marshals the given {@code jaxbElement} to the response payload of the given message context.
*
* Marshals the given {@code jaxbElement} to the response payload of the given message
* context.
* @param messageContext the message context to marshal to
* @param clazz the clazz to create a marshaller for
* @param jaxbElement the object to be marshalled
@@ -107,12 +111,14 @@ public abstract class AbstractJaxb2PayloadMethodProcessor extends AbstractPayloa
StreamingPayload payload = new JaxbStreamingPayload(clazz, jaxbElement);
streamingResponse.setStreamingPayload(payload);
} else {
}
else {
Result responsePayload = response.getPayloadResult();
try {
Jaxb2ResultCallback callback = new Jaxb2ResultCallback(clazz, jaxbElement);
TraxUtils.doWithResult(responsePayload, callback);
} catch (Exception ex) {
}
catch (Exception ex) {
throw convertToJaxbException(ex);
}
}
@@ -120,7 +126,6 @@ public abstract class AbstractJaxb2PayloadMethodProcessor extends AbstractPayloa
/**
* Unmarshals the request payload of the given message context.
*
* @param messageContext the message context to unmarshal from
* @param clazz the class to unmarshal
* @return the unmarshalled object, or {@code null} if the request has no payload
@@ -139,14 +144,14 @@ public abstract class AbstractJaxb2PayloadMethodProcessor extends AbstractPayloa
logger.debug("Unmarshalled payload request to [" + callback.result + "]");
}
return callback.result;
} catch (Exception ex) {
}
catch (Exception ex) {
throw convertToJaxbException(ex);
}
}
/**
* Unmarshals the request payload of the given message context as {@link JAXBElement}.
*
* @param messageContext the message context to unmarshal from
* @param clazz the class to unmarshal
* @return the unmarshalled element, or {@code null} if the request has no payload
@@ -165,7 +170,8 @@ public abstract class AbstractJaxb2PayloadMethodProcessor extends AbstractPayloa
logger.debug("Unmarshalled payload request to [" + callback.result + "]");
}
return callback.result;
} catch (Exception ex) {
}
catch (Exception ex) {
throw convertToJaxbException(ex);
}
}
@@ -178,16 +184,16 @@ public abstract class AbstractJaxb2PayloadMethodProcessor extends AbstractPayloa
private JAXBException convertToJaxbException(Exception ex) {
if (ex instanceof JAXBException) {
return (JAXBException) ex;
} else {
}
else {
return new JAXBException(ex);
}
}
/**
* Creates a new {@link Marshaller} to be used for marshalling objects to XML. Defaults to
* {@link jakarta.xml.bind.JAXBContext#createMarshaller()}, but can be overridden in subclasses for further
* customization.
*
* Creates a new {@link Marshaller} to be used for marshalling objects to XML.
* Defaults to {@link jakarta.xml.bind.JAXBContext#createMarshaller()}, but can be
* overridden in subclasses for further customization.
* @param jaxbContext the JAXB context to create a marshaller for
* @return the marshaller
* @throws JAXBException in case of JAXB errors
@@ -201,10 +207,9 @@ public abstract class AbstractJaxb2PayloadMethodProcessor extends AbstractPayloa
}
/**
* Creates a new {@link Unmarshaller} to be used for unmarshalling XML to objects. Defaults to
* {@link jakarta.xml.bind.JAXBContext#createUnmarshaller()}, but can be overridden in subclasses for further
* customization.
*
* Creates a new {@link Unmarshaller} to be used for unmarshalling XML to objects.
* Defaults to {@link jakarta.xml.bind.JAXBContext#createUnmarshaller()}, but can be
* overridden in subclasses for further customization.
* @param jaxbContext the JAXB context to create a unmarshaller for
* @return the unmarshaller
* @throws JAXBException in case of JAXB errors
@@ -248,16 +253,20 @@ public abstract class AbstractJaxb2PayloadMethodProcessor extends AbstractPayloa
public void saxSource(XMLReader reader, InputSource inputSource) throws Exception {
if (inputSource.getByteStream() == null && inputSource.getCharacterStream() == null
&& inputSource.getSystemId() == null) {
// The InputSource neither has a stream nor a system ID set; this means that
// we are dealing with a custom SAXSource that is not backed by a SAX parser
// The InputSource neither has a stream nor a system ID set; this means
// that
// we are dealing with a custom SAXSource that is not backed by a SAX
// parser
// but that generates a sequence of SAX events in some other way.
// In this case, we need to use a ContentHandler to feed the SAX events into
// In this case, we need to use a ContentHandler to feed the SAX events
// into
// the unmarshaller.
UnmarshallerHandler handler = unmarshaller.getUnmarshallerHandler();
reader.setContentHandler(handler);
reader.parse(inputSource);
result = handler.getResult();
} else {
}
else {
// If a stream or system ID is set, we assume that the SAXSource is backed
// by a SAX parser and we only pass the InputSource to the unmarshaller.
// This effectively ignores the SAX parser and lets the unmarshaller take
@@ -290,6 +299,7 @@ public abstract class AbstractJaxb2PayloadMethodProcessor extends AbstractPayloa
public void source(String systemId) throws Exception {
result = unmarshaller.unmarshal(new URL(systemId));
}
}
private class JaxbElementSourceCallback<T> implements TraxUtils.SourceCallback {
@@ -339,6 +349,7 @@ public abstract class AbstractJaxb2PayloadMethodProcessor extends AbstractPayloa
public void source(String systemId) throws Exception {
result = unmarshaller.unmarshal(new StreamSource(systemId), declaredType);
}
}
private class Jaxb2ResultCallback implements TraxUtils.ResultCallback {
@@ -386,6 +397,7 @@ public abstract class AbstractJaxb2PayloadMethodProcessor extends AbstractPayloa
public void result(String systemId) throws Exception {
marshaller.marshal(jaxbElement, new StreamResult(systemId));
}
}
private class JaxbStreamingPayload implements StreamingPayload {
@@ -414,10 +426,12 @@ public abstract class AbstractJaxb2PayloadMethodProcessor extends AbstractPayloa
public void writeTo(XMLStreamWriter streamWriter) throws XMLStreamException {
try {
marshaller.marshal(jaxbElement, streamWriter);
} catch (JAXBException ex) {
}
catch (JAXBException ex) {
throw new XMLStreamException("Could not marshal [" + jaxbElement + "]: " + ex.getMessage(), ex);
}
}
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -16,18 +16,20 @@
package org.springframework.ws.server.endpoint.adapter.method.jaxb;
import jakarta.xml.bind.JAXBElement;
import jakarta.xml.bind.JAXBException;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import jakarta.xml.bind.JAXBElement;
import jakarta.xml.bind.JAXBException;
import org.springframework.core.MethodParameter;
import org.springframework.ws.context.MessageContext;
/**
* Implementation of {@link org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResolver
* MethodArgumentResolver} and {@link org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler
* Implementation of
* {@link org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResolver
* MethodArgumentResolver} and
* {@link org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler
* MethodReturnValueHandler} that supports {@link JAXBElement} objects.
*
* @author Arjen Poutsma
@@ -43,7 +45,8 @@ public class JaxbElementPayloadMethodProcessor extends AbstractJaxb2PayloadMetho
}
@Override
public JAXBElement<?> resolveArgument(MessageContext messageContext, MethodParameter parameter) throws JAXBException {
public JAXBElement<?> resolveArgument(MessageContext messageContext, MethodParameter parameter)
throws JAXBException {
ParameterizedType parameterizedType = (ParameterizedType) parameter.getGenericParameterType();
Class<?> clazz = (Class<?>) parameterizedType.getActualTypeArguments()[0];
return unmarshalElementFromRequestPayload(messageContext, clazz);
@@ -61,4 +64,5 @@ public class JaxbElementPayloadMethodProcessor extends AbstractJaxb2PayloadMetho
JAXBElement<?> element = (JAXBElement<?>) returnValue;
marshalToResponsePayload(messageContext, element.getDeclaredType(), element);
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2005-2022 the original author or authors.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -25,10 +25,13 @@ import org.springframework.core.MethodParameter;
import org.springframework.ws.context.MessageContext;
/**
* Implementation of {@link org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResolver
* MethodArgumentResolver} and {@link org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler
* MethodReturnValueHandler} that supports parameters annotated with {@link XmlRootElement @XmlRootElement} or
* {@link XmlType @XmlType}, and return values annotated with {@link XmlRootElement @XmlRootElement}.
* Implementation of
* {@link org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResolver
* MethodArgumentResolver} and
* {@link org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler
* MethodReturnValueHandler} that supports parameters annotated with
* {@link XmlRootElement @XmlRootElement} or {@link XmlType @XmlType}, and return values
* annotated with {@link XmlRootElement @XmlRootElement}.
*
* @author Arjen Poutsma
* @since 2.0
@@ -38,7 +41,8 @@ public class XmlRootElementPayloadMethodProcessor extends AbstractJaxb2PayloadMe
@Override
protected boolean supportsRequestPayloadParameter(MethodParameter parameter) {
Class<?> parameterType = parameter.getParameterType();
return parameterType.isAnnotationPresent(XmlRootElement.class) || parameterType.isAnnotationPresent(XmlType.class);
return parameterType.isAnnotationPresent(XmlRootElement.class)
|| parameterType.isAnnotationPresent(XmlType.class);
}
@Override
@@ -47,7 +51,8 @@ public class XmlRootElementPayloadMethodProcessor extends AbstractJaxb2PayloadMe
if (parameterType.isAnnotationPresent(XmlRootElement.class)) {
return unmarshalFromRequestPayload(messageContext, parameterType);
} else {
}
else {
JAXBElement<?> element = unmarshalElementFromRequestPayload(messageContext, parameterType);
return element != null ? element.getValue() : null;
}

Some files were not shown because too many files have changed in this diff Show More