WebServiceMessageCallback can thrown TransformerException
This commit is contained in:
@@ -18,6 +18,7 @@ package org.springframework.ws.client.core;
|
||||
|
||||
import java.io.IOException;
|
||||
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.
|
||||
@@ -43,6 +44,6 @@ public interface SourceExtractor {
|
||||
* latter case)
|
||||
* @throws IOException in case of I/O errors
|
||||
*/
|
||||
Object extractData(Source source) throws IOException;
|
||||
Object extractData(Source source) throws IOException, TransformerException;
|
||||
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.ws.client.core;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.xml.transform.TransformerException;
|
||||
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
|
||||
@@ -34,8 +35,9 @@ public interface WebServiceMessageCallback {
|
||||
* Execute any number of operations on the supplied <code>message</code>.
|
||||
*
|
||||
* @param message the message
|
||||
* @throws IOException in case of I/O errors
|
||||
* @throws IOException in case of I/O errors
|
||||
* @throws TransformerException in case of transformation errors
|
||||
*/
|
||||
void doWithMessage(WebServiceMessage message) throws IOException;
|
||||
void doWithMessage(WebServiceMessage message) throws IOException, TransformerException;
|
||||
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.ws.client.core;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.xml.transform.TransformerException;
|
||||
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
|
||||
@@ -41,8 +42,9 @@ public interface WebServiceMessageExtractor {
|
||||
* @param message the message to extract data from (possibly a <code>SoapMessage</code>)
|
||||
* @return an arbitrary result object, or <code>null</code> if none (the extractor will typically be stateful in the
|
||||
* latter case)
|
||||
* @throws IOException in case of I/O errors
|
||||
* @throws IOException in case of I/O errors
|
||||
* @throws TransformerException in case of transformation errors
|
||||
*/
|
||||
Object extractData(WebServiceMessage message) throws IOException;
|
||||
Object extractData(WebServiceMessage message) throws IOException, TransformerException;
|
||||
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ public interface WebServiceOperations {
|
||||
* <p/>
|
||||
* 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 specified!
|
||||
* 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</code>
|
||||
@@ -162,7 +162,7 @@ public interface WebServiceOperations {
|
||||
* Sends a web service message that contains the given payload. Writes the response, if any, to the given
|
||||
* <code>Result</code>.
|
||||
* <p/>
|
||||
* This will only work with a default specified!
|
||||
* 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
|
||||
@@ -189,7 +189,7 @@ public interface WebServiceOperations {
|
||||
* <p/>
|
||||
* 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 specified!
|
||||
* 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</code>
|
||||
@@ -222,7 +222,7 @@ public interface WebServiceOperations {
|
||||
* Sends a web service message that can be manipulated with the given callback, reading the result with a
|
||||
* <code>WebServiceMessageExtractor</code>.
|
||||
* <p/>
|
||||
* This will only work with a default specified!
|
||||
* This will only work with a default uri specified!
|
||||
*
|
||||
* @param requestCallback the requestCallback to be used for manipulating the request message
|
||||
* @param responseExtractor object that will extract results
|
||||
@@ -250,7 +250,7 @@ public interface WebServiceOperations {
|
||||
* Sends a web service message that can be manipulated with the given callback, reading the result with a
|
||||
* <code>WebServiceMessageExtractor</code>.
|
||||
* <p/>
|
||||
* This will only work with a default specified!
|
||||
* 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
|
||||
|
||||
@@ -101,6 +101,9 @@ public abstract class WebServiceAccessor extends TransformerObjectSupport implem
|
||||
WebServiceMessageSender[] messageSenders = getMessageSenders();
|
||||
for (int i = 0; i < messageSenders.length; i++) {
|
||||
if (messageSenders[i].supports(uri)) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Opening connection to [" + uri + "] using [" + messageSenders[i] + "]");
|
||||
}
|
||||
return messageSenders[i].createConnection(uri);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,14 @@ public abstract class AbstractHttpSenderConnection extends AbstractSenderConnect
|
||||
return getResponseCode() / 100 != 2;
|
||||
}
|
||||
|
||||
public final String getErrorMessage() throws IOException {
|
||||
StringBuffer buffer = new StringBuffer(getResponseMessage());
|
||||
buffer.append(" [");
|
||||
buffer.append(getResponseCode());
|
||||
buffer.append(']');
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
/*
|
||||
* Receiving response
|
||||
*/
|
||||
@@ -83,6 +91,9 @@ public abstract class AbstractHttpSenderConnection extends AbstractSenderConnect
|
||||
/** Returns the HTTP status code of the response. */
|
||||
protected abstract int getResponseCode() throws IOException;
|
||||
|
||||
/** Returns the HTTP status message of the response. */
|
||||
protected abstract String getResponseMessage() throws IOException;
|
||||
|
||||
/** Returns the length of the response. */
|
||||
protected abstract long getResponseContentLength() throws IOException;
|
||||
|
||||
|
||||
@@ -56,10 +56,6 @@ public class CommonsHttpConnection extends AbstractHttpSenderConnection {
|
||||
return postMethod;
|
||||
}
|
||||
|
||||
public String getErrorMessage() throws IOException {
|
||||
return postMethod.getStatusText();
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
postMethod.releaseConnection();
|
||||
}
|
||||
@@ -94,6 +90,10 @@ public class CommonsHttpConnection extends AbstractHttpSenderConnection {
|
||||
return postMethod.getStatusCode();
|
||||
}
|
||||
|
||||
protected String getResponseMessage() throws IOException {
|
||||
return postMethod.getStatusText();
|
||||
}
|
||||
|
||||
protected long getResponseContentLength() throws IOException {
|
||||
return postMethod.getResponseContentLength();
|
||||
}
|
||||
|
||||
@@ -58,10 +58,6 @@ public class HttpUrlConnection extends AbstractHttpSenderConnection {
|
||||
connection.disconnect();
|
||||
}
|
||||
|
||||
public String getErrorMessage() throws IOException {
|
||||
return connection.getResponseMessage();
|
||||
}
|
||||
|
||||
/*
|
||||
* Sending request
|
||||
*/
|
||||
@@ -116,6 +112,10 @@ public class HttpUrlConnection extends AbstractHttpSenderConnection {
|
||||
return connection.getResponseCode();
|
||||
}
|
||||
|
||||
protected String getResponseMessage() throws IOException {
|
||||
return connection.getResponseMessage();
|
||||
}
|
||||
|
||||
protected InputStream getRawResponseInputStream() throws IOException {
|
||||
if (connection.getResponseCode() / 100 != 2) {
|
||||
return connection.getErrorStream();
|
||||
|
||||
@@ -182,7 +182,7 @@ public class WebServiceTemplateTest extends XMLTestCase {
|
||||
connectionControl.expectAndReturn(connectionMock.hasError(), true);
|
||||
connectionControl.expectAndReturn(connectionMock.hasFault(), false);
|
||||
String errorMessage = "errorMessage";
|
||||
connectionControl.expectAndReturn(connectionMock.getErrorMessage(), errorMessage, 2);
|
||||
connectionControl.expectAndReturn(connectionMock.getErrorMessage(), errorMessage);
|
||||
connectionMock.close();
|
||||
connectionControl.replay();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user