SWS-560 - IllegalStateException: Could not find SAAJ on the classpath after upgrading from 1.5.7 to 1.5.8
This commit is contained in:
@@ -42,6 +42,7 @@ import org.springframework.core.io.Resource;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.ws.soap.saaj.SaajSoapMessageException;
|
||||
import org.springframework.ws.transport.TransportConstants;
|
||||
import org.springframework.xml.namespace.QNameUtils;
|
||||
|
||||
@@ -153,12 +154,14 @@ public abstract class SaajUtils {
|
||||
*/
|
||||
public static int getSaajVersion(SOAPMessage soapMessage) {
|
||||
Assert.notNull(soapMessage, "'soapMessage' must not be null");
|
||||
SOAPEnvelope soapEnvelope;
|
||||
try {
|
||||
return getSaajVersion(soapMessage.getSOAPPart().getEnvelope());
|
||||
soapEnvelope = soapMessage.getSOAPPart().getEnvelope();
|
||||
}
|
||||
catch (SOAPException e) {
|
||||
return SAAJ_11;
|
||||
catch (SOAPException ex) {
|
||||
throw new SaajSoapMessageException("Could not access envelope: " + ex.getMessage(), ex);
|
||||
}
|
||||
return getSaajVersion(soapEnvelope);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,10 +16,13 @@
|
||||
|
||||
package org.springframework.ws.soap.saaj.support;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.soap.MessageFactory;
|
||||
import javax.xml.soap.MimeHeaders;
|
||||
import javax.xml.soap.Name;
|
||||
import javax.xml.soap.SOAPEnvelope;
|
||||
import javax.xml.soap.SOAPMessage;
|
||||
@@ -28,7 +31,9 @@ import org.custommonkey.xmlunit.XMLTestCase;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.ws.soap.saaj.SaajSoapMessageException;
|
||||
|
||||
public class SaajUtilsTest extends XMLTestCase {
|
||||
|
||||
@@ -115,5 +120,25 @@ public class SaajUtilsTest extends XMLTestCase {
|
||||
public void testGetSaajVersion() throws Exception {
|
||||
assertEquals("Invalid SAAJ version", SaajUtils.SAAJ_13, SaajUtils.getSaajVersion());
|
||||
}
|
||||
|
||||
public void testGetSaajVersionInvalidEnvelope() throws Exception {
|
||||
Resource resource = new ClassPathResource("invalidNamespaceReferenceSoapMessage.xml", getClass());
|
||||
InputStream in = null;
|
||||
try {
|
||||
in = resource.getInputStream();
|
||||
MimeHeaders headers = new MimeHeaders();
|
||||
SOAPMessage soapMessage = messageFactory.createMessage(headers, in);
|
||||
SaajUtils.getSaajVersion(soapMessage);
|
||||
fail("Should have thrown SaajSoapMessageException as message envelope is invalid and cannot be accessed.");
|
||||
}
|
||||
catch (SaajSoapMessageException e) {
|
||||
// expected
|
||||
}
|
||||
finally {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<soap:Envelope
|
||||
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
||||
<soap:Body>
|
||||
<ndns:doSomethingRequest/>
|
||||
</soap:Body>
|
||||
</soap:Envelope>
|
||||
Reference in New Issue
Block a user