diff --git a/core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoap11Body.java b/core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoap11Body.java
index 880000ce..d6db692c 100644
--- a/core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoap11Body.java
+++ b/core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoap11Body.java
@@ -45,8 +45,14 @@ import org.springframework.xml.namespace.QNameUtils;
*/
class AxiomSoap11Body extends AxiomSoapBody implements Soap11Body {
- AxiomSoap11Body(SOAPBody axiomBody, SOAPFactory axiomFactory, boolean payloadCaching) {
+ private final boolean langAttributeOnSoap11FaulString;
+
+ AxiomSoap11Body(SOAPBody axiomBody,
+ SOAPFactory axiomFactory,
+ boolean payloadCaching,
+ boolean langAttributeOnSoap11FaulString) {
super(axiomBody, axiomFactory, payloadCaching);
+ this.langAttributeOnSoap11FaulString = langAttributeOnSoap11FaulString;
}
public SoapFault addMustUnderstandFault(String faultString, Locale locale) {
@@ -69,21 +75,24 @@ class AxiomSoap11Body extends AxiomSoapBody implements Soap11Body {
return new AxiomSoap11Fault(fault, getAxiomFactory());
}
- public Soap11Fault addFault(QName code, String faultString, Locale locale) {
+ public Soap11Fault addFault(QName code, String faultString, Locale faultStringLocale) {
Assert.notNull(code, "No faultCode given");
Assert.hasLength(faultString, "faultString cannot be empty");
if (!StringUtils.hasLength(code.getNamespaceURI())) {
throw new IllegalArgumentException(
"A fault code with namespace and local part must be specific for a custom fault code");
}
+ if (!langAttributeOnSoap11FaulString) {
+ faultStringLocale = null;
+ }
try {
AxiomUtils.removeContents(getAxiomBody());
SOAPFault fault = getAxiomFactory().createSOAPFault(getAxiomBody());
SOAPFaultCode faultCode = getAxiomFactory().createSOAPFaultCode(fault);
setValueText(code, fault, faultCode);
SOAPFaultReason faultReason = getAxiomFactory().createSOAPFaultReason(fault);
- if (locale != null) {
- addLangAttribute(locale, faultReason);
+ if (faultStringLocale != null) {
+ addLangAttribute(faultStringLocale, faultReason);
}
faultReason.setText(faultString);
return new AxiomSoap11Fault(fault, getAxiomFactory());
@@ -92,7 +101,6 @@ class AxiomSoap11Body extends AxiomSoapBody implements Soap11Body {
catch (SOAPProcessingException ex) {
throw new AxiomSoapFaultException(ex);
}
-
}
private void setValueText(QName code, SOAPFault fault, SOAPFaultCode faultCode) {
diff --git a/core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapEnvelope.java b/core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapEnvelope.java
index dfdcb9cd..0cd68c45 100644
--- a/core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapEnvelope.java
+++ b/core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapEnvelope.java
@@ -24,9 +24,15 @@ class AxiomSoapEnvelope extends AxiomSoapElement implements SoapEnvelope {
private AxiomSoapBody body;
- AxiomSoapEnvelope(SOAPEnvelope axiomEnvelope, SOAPFactory axiomFactory, boolean payloadCaching) {
+ private final boolean langAttributeOnSoap11FaulString;
+
+ AxiomSoapEnvelope(SOAPEnvelope axiomEnvelope,
+ SOAPFactory axiomFactory,
+ boolean payloadCaching,
+ boolean langAttributeOnSoap11FaulString) {
super(axiomEnvelope, axiomFactory);
this.payloadCaching = payloadCaching;
+ this.langAttributeOnSoap11FaulString = langAttributeOnSoap11FaulString;
}
public SoapHeader getHeader() {
@@ -59,7 +65,8 @@ class AxiomSoapEnvelope extends AxiomSoapElement implements SoapEnvelope {
SOAPBody axiomBody = getAxiomEnvelope().getBody();
String namespaceURI = getAxiomEnvelope().getNamespace().getNamespaceURI();
if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(namespaceURI)) {
- body = new AxiomSoap11Body(axiomBody, getAxiomFactory(), payloadCaching);
+ body = new AxiomSoap11Body(axiomBody, getAxiomFactory(), payloadCaching,
+ langAttributeOnSoap11FaulString);
}
else if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(namespaceURI)) {
body = new AxiomSoap12Body(axiomBody, getAxiomFactory(), payloadCaching);
diff --git a/core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapMessage.java b/core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapMessage.java
index 45056f7e..0933c35c 100644
--- a/core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapMessage.java
+++ b/core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapMessage.java
@@ -71,13 +71,15 @@ public class AxiomSoapMessage extends AbstractSoapMessage {
private String soapAction;
+ private final boolean langAttributeOnSoap11FaulString;
+
/**
* Create a new, empty AxiomSoapMessage.
*
* @param soapFactory the AXIOM SOAPFactory
*/
public AxiomSoapMessage(SOAPFactory soapFactory) {
- this(soapFactory, true);
+ this(soapFactory, true, true);
}
/**
@@ -85,12 +87,13 @@ public class AxiomSoapMessage extends AbstractSoapMessage {
*
* @param soapFactory the AXIOM SOAPFactory
*/
- public AxiomSoapMessage(SOAPFactory soapFactory, boolean payloadCaching) {
+ public AxiomSoapMessage(SOAPFactory soapFactory, boolean payloadCaching, boolean langAttributeOnSoap11FaulString) {
SOAPEnvelope soapEnvelope = soapFactory.getDefaultEnvelope();
axiomFactory = soapFactory;
axiomMessage = axiomFactory.createSOAPMessage(soapEnvelope, soapEnvelope.getBuilder());
attachments = new Attachments();
this.payloadCaching = payloadCaching;
+ this.langAttributeOnSoap11FaulString = langAttributeOnSoap11FaulString;
soapAction = EMPTY_SOAP_ACTION;
}
@@ -101,8 +104,11 @@ public class AxiomSoapMessage extends AbstractSoapMessage {
* @param soapAction the value of the SOAP Action header
* @param payloadCaching whether the contents of the SOAP body should be cached or not
*/
- public AxiomSoapMessage(SOAPMessage soapMessage, String soapAction, boolean payloadCaching) {
- this(soapMessage, new Attachments(), soapAction, payloadCaching);
+ public AxiomSoapMessage(SOAPMessage soapMessage,
+ String soapAction,
+ boolean payloadCaching,
+ boolean langAttributeOnSoap11FaulString) {
+ this(soapMessage, new Attachments(), soapAction, payloadCaching, langAttributeOnSoap11FaulString);
}
/**
@@ -116,7 +122,8 @@ public class AxiomSoapMessage extends AbstractSoapMessage {
public AxiomSoapMessage(SOAPMessage soapMessage,
Attachments attachments,
String soapAction,
- boolean payloadCaching) {
+ boolean payloadCaching,
+ boolean langAttributeOnSoap11FaulString) {
Assert.notNull(soapMessage, "'soapMessage' must not be null");
Assert.notNull(attachments, "'attachments' must not be null");
axiomMessage = soapMessage;
@@ -127,6 +134,7 @@ public class AxiomSoapMessage extends AbstractSoapMessage {
}
this.soapAction = soapAction;
this.payloadCaching = payloadCaching;
+ this.langAttributeOnSoap11FaulString = langAttributeOnSoap11FaulString;
}
/** Return the AXIOM SOAPMessage that this AxiomSoapMessage is based on. */
@@ -149,7 +157,8 @@ public class AxiomSoapMessage extends AbstractSoapMessage {
public SoapEnvelope getEnvelope() {
if (envelope == null) {
try {
- envelope = new AxiomSoapEnvelope(axiomMessage.getSOAPEnvelope(), axiomFactory, payloadCaching);
+ envelope = new AxiomSoapEnvelope(axiomMessage.getSOAPEnvelope(), axiomFactory, payloadCaching,
+ langAttributeOnSoap11FaulString);
}
catch (SOAPProcessingException ex) {
throw new AxiomSoapEnvelopeException(ex);
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 8773fcb6..3d27a8dd 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
@@ -101,6 +101,8 @@ public class AxiomSoapMessageFactory implements SoapMessageFactory, Initializing
// use SOAP 1.1 by default
private SOAPFactory soapFactory = new SOAP11Factory();
+ private boolean langAttributeOnSoap11FaulString = true;
+
/** Default constructor. */
public AxiomSoapMessageFactory() {
inputFactory = XMLInputFactory.newInstance();
@@ -165,6 +167,18 @@ public class AxiomSoapMessageFactory implements SoapMessageFactory, Initializing
}
}
+ /**
+ * Defines whether a {@code xml:lang} attribute should be set on SOAP 1.1 {@code } elements.
+ *
+ * The default is {@code true}, to comply with WS-I, but this flag can be set to {@code false} to the older W3C SOAP
+ * 1.1 specification.
+ *
+ * @see WS-I Basic Profile 1.1
+ */
+ public void setLangAttributeOnSoap11FaulString(boolean langAttributeOnSoap11FaulString) {
+ this.langAttributeOnSoap11FaulString = langAttributeOnSoap11FaulString;
+ }
+
public void afterPropertiesSet() throws Exception {
if (logger.isInfoEnabled()) {
logger.info(payloadCaching ? "Enabled payload caching" : "Disabled payload caching");
@@ -176,7 +190,7 @@ public class AxiomSoapMessageFactory implements SoapMessageFactory, Initializing
}
public WebServiceMessage createWebServiceMessage() {
- return new AxiomSoapMessage(soapFactory, payloadCaching);
+ return new AxiomSoapMessage(soapFactory, payloadCaching, langAttributeOnSoap11FaulString);
}
public WebServiceMessage createWebServiceMessage(InputStream inputStream) throws IOException {
@@ -227,15 +241,16 @@ public class AxiomSoapMessageFactory implements SoapMessageFactory, Initializing
String envelopeNamespace = getSoapEnvelopeNamespace(contentType);
StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(reader, soapFactory, envelopeNamespace);
SOAPMessage soapMessage = builder.getSoapMessage();
- return new AxiomSoapMessage(soapMessage, soapAction, payloadCaching);
+ return new AxiomSoapMessage(soapMessage, soapAction, payloadCaching, langAttributeOnSoap11FaulString);
}
/** Creates an AxiomSoapMessage with attachments. */
private AxiomSoapMessage createMultiPartAxiomSoapMessage(InputStream inputStream,
String contentType,
String soapAction) throws XMLStreamException {
- Attachments attachments = new Attachments(inputStream, contentType, attachmentCaching,
- attachmentCacheDir.getAbsolutePath(), Integer.toString(attachmentCacheThreshold));
+ Attachments attachments =
+ new Attachments(inputStream, contentType, attachmentCaching, attachmentCacheDir.getAbsolutePath(),
+ Integer.toString(attachmentCacheThreshold));
XMLStreamReader reader = inputFactory.createXMLStreamReader(attachments.getSOAPPartInputStream(),
getCharSetEncoding(attachments.getSOAPPartContentType()));
StAXSOAPModelBuilder builder;
@@ -251,7 +266,8 @@ public class AxiomSoapMessageFactory implements SoapMessageFactory, Initializing
throw new AxiomSoapMessageCreationException(
"Unknown attachment type: [" + attachments.getAttachmentSpecType() + "]");
}
- return new AxiomSoapMessage(builder.getSoapMessage(), attachments, soapAction, payloadCaching);
+ return new AxiomSoapMessage(builder.getSoapMessage(), attachments, soapAction, payloadCaching,
+ langAttributeOnSoap11FaulString);
}
private String getSoapEnvelopeNamespace(String contentType) {
diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap11Body.java b/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap11Body.java
index 2f2303e7..1d326ea4 100644
--- a/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap11Body.java
+++ b/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap11Body.java
@@ -36,8 +36,11 @@ import org.springframework.ws.soap.soap11.Soap11Fault;
*/
class SaajSoap11Body extends SaajSoapBody implements Soap11Body {
- SaajSoap11Body(SOAPBody body) {
+ private final boolean langAttributeOnSoap11FaulString;
+
+ SaajSoap11Body(SOAPBody body, boolean langAttributeOnSoap11FaulString) {
super(body);
+ this.langAttributeOnSoap11FaulString = langAttributeOnSoap11FaulString;
}
public SoapFault getFault() {
@@ -50,6 +53,9 @@ class SaajSoap11Body extends SaajSoapBody implements Soap11Body {
Assert.hasLength(faultString, "faultString cannot be empty");
Assert.hasLength(faultCode.getLocalPart(), "faultCode's localPart cannot be empty");
Assert.hasLength(faultCode.getNamespaceURI(), "faultCode's namespaceUri cannot be empty");
+ if (!langAttributeOnSoap11FaulString) {
+ faultStringLocale = null;
+ }
try {
getImplementation().removeContents(getSaajBody());
SOAPFault saajFault =
diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapEnvelope.java b/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapEnvelope.java
index 4ae794b8..fa0dad16 100644
--- a/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapEnvelope.java
+++ b/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapEnvelope.java
@@ -17,6 +17,7 @@
package org.springframework.ws.soap.saaj;
import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPHeader;
@@ -39,8 +40,11 @@ class SaajSoapEnvelope extends SaajSoapElement implements SoapEnvelope {
private SaajSoapHeader header;
- public SaajSoapEnvelope(SOAPEnvelope envelope) {
- super(envelope);
+ private final boolean langAttributeOnSoap11FaulString;
+
+ SaajSoapEnvelope(SOAPElement element, boolean langAttributeOnSoap11FaulString) {
+ super(element);
+ this.langAttributeOnSoap11FaulString = langAttributeOnSoap11FaulString;
}
public SoapBody getBody() {
@@ -49,7 +53,7 @@ class SaajSoapEnvelope extends SaajSoapElement implements SoapEnvelope {
SOAPBody saajBody = getImplementation().getBody(getSaajEnvelope());
if (getImplementation().getName(saajBody).getNamespaceURI()
.equals(SoapVersion.SOAP_11.getEnvelopeNamespaceUri())) {
- body = new SaajSoap11Body(saajBody);
+ body = new SaajSoap11Body(saajBody, langAttributeOnSoap11FaulString);
}
else {
body = new SaajSoap12Body(saajBody);
diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapMessage.java b/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapMessage.java
index 9d7dfeb1..1a299035 100644
--- a/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapMessage.java
+++ b/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapMessage.java
@@ -51,11 +51,13 @@ import org.springframework.ws.transport.TransportConstants;
*/
public class SaajSoapMessage extends AbstractSoapMessage {
+ private static final String CONTENT_TYPE_XOP = "application/xop+xml";
+
private SOAPMessage saajMessage;
private SoapEnvelope envelope;
- private static final String CONTENT_TYPE_XOP = "application/xop+xml";
+ private final boolean langAttributeOnSoap11FaulString;
/**
* Create a new SaajSoapMessage based on the given SAAJ SOAPMessage.
@@ -63,12 +65,24 @@ public class SaajSoapMessage extends AbstractSoapMessage {
* @param soapMessage the SAAJ SOAPMessage
*/
public SaajSoapMessage(SOAPMessage soapMessage) {
+ this(soapMessage, true);
+ }
+
+ /**
+ * Create a new SaajSoapMessage based on the given SAAJ SOAPMessage.
+ *
+ * @param soapMessage the SAAJ SOAPMessage
+ * @param langAttributeOnSoap11FaulString
+ * whether a {@code xml:lang} attribute is allowed on SOAP 1.1 {@code } elements
+ */
+ public SaajSoapMessage(SOAPMessage soapMessage, boolean langAttributeOnSoap11FaulString) {
Assert.notNull(soapMessage, "soapMessage must not be null");
MimeHeaders headers = getImplementation().getMimeHeaders(soapMessage);
if (ObjectUtils.isEmpty(headers.getHeader(TransportConstants.HEADER_SOAP_ACTION))) {
headers.addHeader(TransportConstants.HEADER_SOAP_ACTION, "\"\"");
}
saajMessage = soapMessage;
+ this.langAttributeOnSoap11FaulString = langAttributeOnSoap11FaulString;
}
/** Return the SAAJ SOAPMessage that this SaajSoapMessage is based on. */
@@ -87,7 +101,7 @@ public class SaajSoapMessage extends AbstractSoapMessage {
if (envelope == null) {
try {
SOAPEnvelope saajEnvelope = getImplementation().getEnvelope(getSaajMessage());
- envelope = new SaajSoapEnvelope(saajEnvelope);
+ envelope = new SaajSoapEnvelope(saajEnvelope, langAttributeOnSoap11FaulString);
}
catch (SOAPException ex) {
throw new SaajSoapEnvelopeException(ex);
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 98270aa2..4f11ad32 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
@@ -61,6 +61,8 @@ public class SaajSoapMessageFactory implements SoapMessageFactory, InitializingB
private String messageFactoryProtocol;
+ private boolean langAttributeOnSoap11FaulString = true;
+
/** Default, empty constructor. */
public SaajSoapMessageFactory() {
}
@@ -80,6 +82,18 @@ public class SaajSoapMessageFactory implements SoapMessageFactory, InitializingB
this.messageFactory = messageFactory;
}
+ /**
+ * Defines whether a {@code xml:lang} attribute should be set on SOAP 1.1 {@code } elements.
+ *
+ * The default is {@code true}, to comply with WS-I, but this flag can be set to {@code false} to the older W3C SOAP
+ * 1.1 specification.
+ *
+ * @see WS-I Basic Profile 1.1
+ */
+ public void setLangAttributeOnSoap11FaulString(boolean langAttributeOnSoap11FaulString) {
+ this.langAttributeOnSoap11FaulString = langAttributeOnSoap11FaulString;
+ }
+
public void setSoapVersion(SoapVersion version) {
if (SaajUtils.getSaajVersion() >= SaajUtils.SAAJ_13) {
if (SoapVersion.SOAP_11 == version) {
@@ -140,7 +154,7 @@ public class SaajSoapMessageFactory implements SoapMessageFactory, InitializingB
public WebServiceMessage createWebServiceMessage() {
try {
- return new SaajSoapMessage(messageFactory.createMessage());
+ return new SaajSoapMessage(messageFactory.createMessage(), langAttributeOnSoap11FaulString);
}
catch (SOAPException ex) {
throw new SoapMessageCreationException("Could not create empty message: " + ex.getMessage(), ex);
@@ -162,7 +176,8 @@ public class SaajSoapMessageFactory implements SoapMessageFactory, InitializingB
contentType = contentType.replace("startinfo", "start-info");
mimeHeaders.setHeader(TransportConstants.HEADER_CONTENT_TYPE, contentType);
try {
- return new SaajSoapMessage(messageFactory.createMessage(mimeHeaders, inputStream));
+ return new SaajSoapMessage(messageFactory.createMessage(mimeHeaders, inputStream),
+ langAttributeOnSoap11FaulString);
}
catch (SOAPException e) {
// fall-through
diff --git a/core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap11BodyTest.java b/core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap11BodyTest.java
index 06e4964c..2aa72b32 100644
--- a/core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap11BodyTest.java
+++ b/core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap11BodyTest.java
@@ -44,4 +44,5 @@ public class AxiomSoap11BodyTest extends AbstractSoap11BodyTestCase {
transformer.transform(new StringSource(payload), soapBody.getPayloadResult());
assertPayloadEqual(payload);
}
+
}
diff --git a/core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoapFaultDetailTest.java b/core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoapFaultDetailTest.java
index 581b6bc7..440c553e 100644
--- a/core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoapFaultDetailTest.java
+++ b/core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoapFaultDetailTest.java
@@ -23,6 +23,7 @@ import javax.xml.stream.XMLStreamReader;
import junit.framework.TestCase;
import org.apache.axiom.soap.SOAPMessage;
import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
+
import org.springframework.ws.soap.SoapFault;
import org.springframework.ws.soap.SoapFaultDetail;
@@ -57,13 +58,13 @@ public class AxiomSoapFaultDetailTest extends TestCase {
StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(parser);
SOAPMessage soapMessage = builder.getSoapMessage();
- failingMessage = new AxiomSoapMessage(soapMessage, null, false);
+ failingMessage = new AxiomSoapMessage(soapMessage, null, false, true);
parser = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(SUCCEEDING_FAULT));
builder = new StAXSOAPModelBuilder(parser);
soapMessage = builder.getSoapMessage();
- succeedingMessage = new AxiomSoapMessage(soapMessage, null, false);
+ succeedingMessage = new AxiomSoapMessage(soapMessage, null, false, true);
}
diff --git a/core/src/test/java/org/springframework/ws/soap/saaj/SaajSoap11BodyTest.java b/core/src/test/java/org/springframework/ws/soap/saaj/SaajSoap11BodyTest.java
index 182fa665..08a506da 100644
--- a/core/src/test/java/org/springframework/ws/soap/saaj/SaajSoap11BodyTest.java
+++ b/core/src/test/java/org/springframework/ws/soap/saaj/SaajSoap11BodyTest.java
@@ -16,7 +16,9 @@
package org.springframework.ws.soap.saaj;
+import java.util.Locale;
import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPMessage;
@@ -28,7 +30,25 @@ public class SaajSoap11BodyTest extends AbstractSoap11BodyTestCase {
protected SoapBody createSoapBody() throws Exception {
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
SOAPMessage saajMessage = messageFactory.createMessage();
- return new SaajSoap11Body(saajMessage.getSOAPPart().getEnvelope().getBody());
+ return new SaajSoap11Body(saajMessage.getSOAPPart().getEnvelope().getBody(), true);
}
+ public void testLangAttributeOnSoap11FaulString() throws Exception {
+ MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
+ SOAPMessage saajMessage = messageFactory.createMessage();
+
+ SOAPBody saajSoapBody = saajMessage.getSOAPPart().getEnvelope().getBody();
+ SaajSoap11Body soapBody = new SaajSoap11Body(saajSoapBody, true);
+
+ soapBody.addClientOrSenderFault("Foo", Locale.ENGLISH);
+ assertNotNull("No Language set", saajSoapBody.getFault().getFaultStringLocale());
+
+ saajSoapBody = saajMessage.getSOAPPart().getEnvelope().getBody();
+ soapBody = new SaajSoap11Body(saajSoapBody, false);
+
+ soapBody.addClientOrSenderFault("Foo", Locale.ENGLISH);
+ assertNull("Language set", saajSoapBody.getFault().getFaultStringLocale());
+ }
+
+
}
diff --git a/core/src/test/java/org/springframework/ws/soap/saaj/SaajSoap11EnvelopeTest.java b/core/src/test/java/org/springframework/ws/soap/saaj/SaajSoap11EnvelopeTest.java
index f1d3ead5..4f5c1931 100644
--- a/core/src/test/java/org/springframework/ws/soap/saaj/SaajSoap11EnvelopeTest.java
+++ b/core/src/test/java/org/springframework/ws/soap/saaj/SaajSoap11EnvelopeTest.java
@@ -28,6 +28,6 @@ public class SaajSoap11EnvelopeTest extends AbstractSoap11EnvelopeTestCase {
protected SoapEnvelope createSoapEnvelope() throws Exception {
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
SOAPMessage saajMessage = messageFactory.createMessage();
- return new SaajSoapEnvelope(saajMessage.getSOAPPart().getEnvelope());
+ return new SaajSoapEnvelope(saajMessage.getSOAPPart().getEnvelope(), true);
}
}
diff --git a/core/src/test/java/org/springframework/ws/soap/saaj/SaajSoap12EnvelopeTest.java b/core/src/test/java/org/springframework/ws/soap/saaj/SaajSoap12EnvelopeTest.java
index faa27a37..e61165cd 100644
--- a/core/src/test/java/org/springframework/ws/soap/saaj/SaajSoap12EnvelopeTest.java
+++ b/core/src/test/java/org/springframework/ws/soap/saaj/SaajSoap12EnvelopeTest.java
@@ -28,6 +28,6 @@ public class SaajSoap12EnvelopeTest extends AbstractSoap12EnvelopeTestCase {
protected SoapEnvelope createSoapEnvelope() throws Exception {
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
SOAPMessage saajMessage = messageFactory.createMessage();
- return new SaajSoapEnvelope(saajMessage.getSOAPPart().getEnvelope());
+ return new SaajSoapEnvelope(saajMessage.getSOAPPart().getEnvelope(), true);
}
}
diff --git a/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jTestCase.java b/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jTestCase.java
index a4f8f70a..c4686818 100755
--- a/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jTestCase.java
+++ b/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jTestCase.java
@@ -48,11 +48,9 @@ public abstract class Wss4jTestCase extends TestCase {
protected MessageFactory messageFactory;
- protected final boolean axiomTest = this.getClass().getSimpleName()
- .startsWith("Axiom");
+ protected final boolean axiomTest = this.getClass().getSimpleName().startsWith("Axiom");
- protected final boolean saajTest = this.getClass().getSimpleName()
- .startsWith("Saaj");
+ protected final boolean saajTest = this.getClass().getSimpleName().startsWith("Saaj");
protected Map namespaces;
@@ -77,22 +75,19 @@ public abstract class Wss4jTestCase extends TestCase {
String expectedValue,
String xpathExpression,
Document document) {
- XPathExpression expression = XPathExpressionFactory
- .createXPathExpression(xpathExpression, namespaces);
+ XPathExpression expression = XPathExpressionFactory.createXPathExpression(xpathExpression, namespaces);
String actualValue = expression.evaluateAsString(document);
assertEquals(message, expectedValue, actualValue);
}
protected void assertXpathExists(String message, String xpathExpression, Document document) {
- XPathExpression expression = XPathExpressionFactory
- .createXPathExpression(xpathExpression, namespaces);
+ XPathExpression expression = XPathExpressionFactory.createXPathExpression(xpathExpression, namespaces);
Node node = expression.evaluateAsNode(document);
assertNotNull(message, node);
}
protected void assertXpathNotExists(String message, String xpathExpression, Document document) {
- XPathExpression expression = XPathExpressionFactory
- .createXPathExpression(xpathExpression, namespaces);
+ XPathExpression expression = XPathExpressionFactory.createXPathExpression(xpathExpression, namespaces);
Node node = expression.evaluateAsNode(document);
assertNull(message, node);
}
@@ -119,12 +114,10 @@ public abstract class Wss4jTestCase extends TestCase {
assertTrue("Could not load Axiom message [" + resource + "]", resource.exists());
is = resource.getInputStream();
- XMLStreamReader parser = XMLInputFactory.newInstance()
- .createXMLStreamReader(is);
+ XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(is);
StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(parser, null);
- org.apache.axiom.soap.SOAPMessage soapMessage = builder
- .getSoapMessage();
- return new AxiomSoapMessage(soapMessage, "", true);
+ org.apache.axiom.soap.SOAPMessage soapMessage = builder.getSoapMessage();
+ return new AxiomSoapMessage(soapMessage, "", true, true);
}
finally {
is.close();
@@ -144,13 +137,11 @@ public abstract class Wss4jTestCase extends TestCase {
protected void setMessage(SoapMessage soapMessage, Object message) {
if (soapMessage instanceof SaajSoapMessage) {
- ((SaajSoapMessage) soapMessage)
- .setSaajMessage((SOAPMessage) message);
+ ((SaajSoapMessage) soapMessage).setSaajMessage((SOAPMessage) message);
return;
}
if (soapMessage instanceof AxiomSoapMessage) {
- ((AxiomSoapMessage) soapMessage)
- .setAxiomMessage((org.apache.axiom.soap.SOAPMessage) message);
+ ((AxiomSoapMessage) soapMessage).setAxiomMessage((org.apache.axiom.soap.SOAPMessage) message);
return;
}
throw new IllegalArgumentException("Illegal message: " + message);