diff --git a/core/src/main/java/org/springframework/ws/server/endpoint/MethodEndpoint.java b/core/src/main/java/org/springframework/ws/server/endpoint/MethodEndpoint.java index bfc02659..cb863f0e 100644 --- a/core/src/main/java/org/springframework/ws/server/endpoint/MethodEndpoint.java +++ b/core/src/main/java/org/springframework/ws/server/endpoint/MethodEndpoint.java @@ -20,7 +20,6 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; 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. @@ -78,11 +77,30 @@ public final class MethodEndpoint { * * @param args the arguments * @return the invocation result - * @throws IllegalAccessException when there is insufficient access to invoke the method - * @throws InvocationTargetException when the method invocation results in an exception + * @throws Exception when the method invocation results in an exception */ - public Object invoke(Object[] args) throws IllegalAccessException, InvocationTargetException { - return ReflectionUtils.invokeMethod(this.method, this.bean, args); + public Object invoke(Object[] args) throws Exception { + try { + return this.method.invoke(this.bean, args); + } + catch (InvocationTargetException ex) { + handleInvocationTargetException(ex); + throw new IllegalStateException("Unexpected exception thrown by method - " + + ex.getTargetException().getClass().getName() + ": " + ex.getTargetException().getMessage()); + } + } + + private void handleInvocationTargetException(InvocationTargetException ex) throws Exception { + if (ex.getTargetException() instanceof RuntimeException) { + throw (RuntimeException) ex.getTargetException(); + } + if (ex.getTargetException() instanceof Error) { + throw (Error) ex.getTargetException(); + } + if (ex.getTargetException() instanceof Exception) { + throw (Exception) ex.getTargetException(); + } + } public boolean equals(Object o) { diff --git a/core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapMessageFactory.java b/core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapMessageFactory.java index f381a710..1a629c60 100644 --- a/core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapMessageFactory.java +++ b/core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapMessageFactory.java @@ -238,4 +238,15 @@ public class AxiomSoapMessageFactory implements SoapMessageFactory, Initializing } } + public String toString() { + StringBuffer buffer = new StringBuffer("AxiomSoapMessageFactory["); + if (soapFactory instanceof SOAP11Factory) { + buffer.append("SOAP 1.1"); + } + else if (soapFactory instanceof SOAP12Factory) { + buffer.append("SOAP 1.2"); + } + buffer.append(']'); + return buffer.toString(); + } } diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapMessageFactory.java b/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapMessageFactory.java index de641707..93f3d7ba 100644 --- a/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapMessageFactory.java +++ b/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapMessageFactory.java @@ -65,16 +65,16 @@ public class SaajSoapMessageFactory implements SoapMessageFactory, InitializingB this.messageFactory = messageFactory; } - /** Sets the SAAJ MessageFactory. */ - public void setMessageFactory(MessageFactory messageFactory) { - this.messageFactory = messageFactory; - } - /** Returns the SAAJ MessageFactory used. */ public MessageFactory getMessageFactory() { return messageFactory; } + /** Sets the SAAJ MessageFactory. */ + public void setMessageFactory(MessageFactory messageFactory) { + this.messageFactory = messageFactory; + } + public void setSoapVersion(SoapVersion version) { if (SaajUtils.getSaajVersion() >= SaajUtils.SAAJ_13) { if (SoapVersion.SOAP_11 == version) { @@ -115,11 +115,17 @@ public class SaajSoapMessageFactory implements SoapMessageFactory, InitializingB } else { throw new IllegalStateException( - "SaajSoapMessageFactory requires SAAJ 1.1, which was not" + "found on the classpath"); + "SaajSoapMessageFactory requires SAAJ 1.1, which was not found on the classpath"); } } + catch (NoSuchMethodError ex) { + throw new SoapMessageCreationException( + "Could not create SAAJ MessageFactory. Is the version of the SAAJ specification interfaces [" + + SaajUtils.getSaajVersionString() + + "] the same as the version supported by the application server?", ex); + } catch (SOAPException ex) { - throw new SoapMessageCreationException("Could not create MessageFactory: " + ex.getMessage(), ex); + throw new SoapMessageCreationException("Could not create SAAJ MessageFactory: " + ex.getMessage(), ex); } } if (logger.isDebugEnabled()) { @@ -158,4 +164,15 @@ public class SaajSoapMessageFactory implements SoapMessageFactory, InitializingB throw new SoapMessageCreationException("Could not create message from InputStream: " + ex.getMessage(), ex); } } + + public String toString() { + StringBuffer buffer = new StringBuffer("SaajSoapMessageFactory["); + buffer.append(SaajUtils.getSaajVersionString()); + if (SaajUtils.getSaajVersion() >= SaajUtils.SAAJ_13) { + buffer.append(','); + buffer.append(messageFactoryProtocol); + } + buffer.append(']'); + return buffer.toString(); + } } diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/support/SaajUtils.java b/core/src/main/java/org/springframework/ws/soap/saaj/support/SaajUtils.java index fe6d6586..4b78191e 100644 --- a/core/src/main/java/org/springframework/ws/soap/saaj/support/SaajUtils.java +++ b/core/src/main/java/org/springframework/ws/soap/saaj/support/SaajUtils.java @@ -103,6 +103,28 @@ public abstract class SaajUtils { return saajVersion; } + /** + * Returns the SAAJ version as a String. The returned string will be "SAAJ 1.3", + * "SAAJ 1.2", or "SAAJ 1.1". + * + * @return a string representation of the SAAJ version + * @see #getSaajVersion() + */ + public static String getSaajVersionString() { + if (saajVersion >= SaajUtils.SAAJ_13) { + return "SAAJ 1.3"; + } + else if (saajVersion == SaajUtils.SAAJ_12) { + return "SAAJ 1.2"; + } + else if (saajVersion == SaajUtils.SAAJ_11) { + return "SAAJ 1.1"; + } + else { + return ""; + } + } + /** * Converts a javax.xml.namespace.QName to a javax.xml.soap.Name. A * SOAPElement is required to create the name.