diff --git a/core/src/main/java/org/springframework/ws/soap/SoapMessage.java b/core/src/main/java/org/springframework/ws/soap/SoapMessage.java
index eb6248f7..b8667513 100644
--- a/core/src/main/java/org/springframework/ws/soap/SoapMessage.java
+++ b/core/src/main/java/org/springframework/ws/soap/SoapMessage.java
@@ -34,9 +34,7 @@ import org.springframework.ws.WebServiceMessage;
*/
public interface SoapMessage extends WebServiceMessage {
- /**
- * Returns the SoapEnvelope associated with this SoapMessage.
- */
+ /** Returns the SoapEnvelope associated with this SoapMessage. */
SoapEnvelope getEnvelope() throws SoapEnvelopeException;
/**
@@ -46,6 +44,13 @@ public interface SoapMessage extends WebServiceMessage {
*/
String getSoapAction();
+ /**
+ * Sets the SOAP Action for this message.
+ *
+ * @param soapAction the SOAP Action.
+ */
+ void setSoapAction(String soapAction);
+
/**
* Returns the SoapBody associated with this SoapMessage. This is a convenience method for
* getEnvelope().getBody().
@@ -118,6 +123,4 @@ public interface SoapMessage extends WebServiceMessage {
* @see org.springframework.core.io.Resource
*/
Attachment addAttachment(InputStreamSource inputStreamSource, String contentType);
-
- void setSoapAction(String soapAction);
}
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 6a403c61..3c52caa7 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
@@ -36,12 +36,12 @@ import org.springframework.util.Assert;
import org.springframework.ws.soap.AbstractSoapMessage;
import org.springframework.ws.soap.Attachment;
import org.springframework.ws.soap.SoapEnvelope;
+import org.springframework.ws.soap.SoapMessage;
import org.springframework.ws.soap.SoapVersion;
import org.springframework.ws.transport.TransportOutputStream;
/**
- * AXIOM-specific implementation of the SoapMessage interface. Accessed via the
- * AxiomSoapMessageContext.
+ * AXIOM-specific implementation of the {@link SoapMessage} interface. Created via the {@link AxiomSoapMessageFactory}.
*
addAttachment methods throw an UnsupportedOperationException.
@@ -111,9 +111,7 @@ public class AxiomSoapMessage extends AbstractSoapMessage {
this.payloadCaching = payloadCaching;
}
- /**
- * Return the AXIOM SOAPMessage that this AxiomSoapMessage is based on.
- */
+ /** Return the AXIOM SOAPMessage that this AxiomSoapMessage is based on. */
public final SOAPMessage getAxiomMessage() {
return axiomMessage;
}
@@ -196,9 +194,7 @@ public class AxiomSoapMessage extends AbstractSoapMessage {
}
}
- /**
- * Axiom-specific implementation of org.springframework.ws.soap.Attachment
- */
+ /** Axiom-specific implementation of org.springframework.ws.soap.Attachment */
private static class AxiomAttachment implements Attachment {
private final DataHandler dataHandler;
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 411423c7..9fdbc670 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
@@ -145,21 +145,18 @@ public class AxiomSoapMessageFactory implements WebServiceMessageFactory, Initia
return contentType.indexOf(MULTI_PART_RELATED_CONTENT_TYPE) != -1;
}
- /**
- * Creates an AxiomSoapMessage without attachments.
- */
+ /** Creates an AxiomSoapMessage without attachments. */
private WebServiceMessage createAxiomSoapMessage(InputStream inputStream, String contentType, String soapAction)
throws XMLStreamException {
XMLStreamReader reader = inputFactory.createXMLStreamReader(inputStream, getCharSetEncoding(contentType));
SOAPFactory soapFactory = getSoapFactory(contentType);
- StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(reader, soapFactory, soapFactory.getSoapVersionURI());
+ String envelopeNamespace = getSoapEnvelopeNamespace(contentType);
+ StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(reader, soapFactory, envelopeNamespace);
SOAPMessage soapMessage = builder.getSoapMessage();
return new AxiomSoapMessage(soapMessage, soapAction, payloadCaching);
}
- /**
- * Creates an AxiomSoapMessage with attachments.
- */
+ /** Creates an AxiomSoapMessage with attachments. */
private AxiomSoapMessage createMultiPartAxiomSoapMessage(InputStream inputStream,
String contentType,
String soapAction) throws XMLStreamException {
@@ -171,13 +168,14 @@ public class AxiomSoapMessageFactory implements WebServiceMessageFactory, Initia
}
XMLStreamReader reader = inputFactory.createXMLStreamReader(attachments.getSOAPPartInputStream(),
getCharSetEncoding(attachments.getSOAPPartContentType()));
- SOAPFactory soapFactory = getSoapFactory(attachments.getSOAPPartContentType());
StAXSOAPModelBuilder builder = null;
+ String envelopeNamespace = getSoapEnvelopeNamespace(contentType);
if (attachments.getAttachmentSpecType().equals(MTOMConstants.SWA_TYPE)) {
- builder = new StAXSOAPModelBuilder(reader, soapFactory, soapFactory.getSoapVersionURI());
+ SOAPFactory soapFactory = getSoapFactory(attachments.getSOAPPartContentType());
+ builder = new StAXSOAPModelBuilder(reader, soapFactory, envelopeNamespace);
}
else if (attachments.getAttachmentSpecType().equals(MTOMConstants.MTOM_TYPE)) {
- builder = new MTOMStAXSOAPModelBuilder(reader, attachments, soapFactory.getSoapVersionURI());
+ builder = new MTOMStAXSOAPModelBuilder(reader, attachments, envelopeNamespace);
}
return new AxiomSoapMessage(builder.getSoapMessage(), attachments, soapAction, payloadCaching);
}
@@ -194,6 +192,19 @@ public class AxiomSoapMessageFactory implements WebServiceMessageFactory, Initia
}
}
+ private String getSoapEnvelopeNamespace(String contentType) {
+ if (contentType.indexOf(SOAP11Constants.SOAP_11_CONTENT_TYPE) != -1) {
+ return SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
+ }
+ else if (contentType.indexOf(SOAP12Constants.SOAP_12_CONTENT_TYPE) != -1) {
+ return SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI;
+ }
+ else {
+ throw new AxiomSoapMessageCreationException("Unknown content type '" + contentType + "'");
+ }
+
+ }
+
/**
* Returns the character set from the given content type. Mostly copied
*
diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/Saaj11Implementation.java b/core/src/main/java/org/springframework/ws/soap/saaj/Saaj11Implementation.java
index 15bc4a32..df3693ae 100644
--- a/core/src/main/java/org/springframework/ws/soap/saaj/Saaj11Implementation.java
+++ b/core/src/main/java/org/springframework/ws/soap/saaj/Saaj11Implementation.java
@@ -126,37 +126,27 @@ public class Saaj11Implementation implements SaajImplementation {
return fault;
}
- /**
- * Returns the envelope of the given message.
- */
+ /** Returns the envelope of the given message. */
public SOAPEnvelope getEnvelope(SOAPMessage message) throws SOAPException {
return message.getSOAPPart().getEnvelope();
}
- /**
- * Returns the header of the given envelope.
- */
+ /** Returns the header of the given envelope. */
public SOAPHeader getHeader(SOAPEnvelope envelope) throws SOAPException {
return envelope.getHeader();
}
- /**
- * Returns the body of the given envelope.
- */
+ /** Returns the body of the given envelope. */
public SOAPBody getBody(SOAPEnvelope envelope) throws SOAPException {
return envelope.getBody();
}
- /**
- * Returns all header elements.
- */
+ /** Returns all header elements. */
public Iterator examineAllHeaderElements(SOAPHeader header) {
return header.getChildElements();
}
- /**
- * Returns all header elements for which the must understand attribute is true, given the actor or role.
- */
+ /** Returns all header elements for which the must understand attribute is true, given the actor or role. */
public Iterator examineMustUnderstandHeaderElements(SOAPHeader header, String actorOrRole) {
List result = new ArrayList();
for (Iterator iterator = header.examineHeaderElements(actorOrRole); iterator.hasNext();) {
@@ -168,86 +158,62 @@ public class Saaj11Implementation implements SaajImplementation {
return result.iterator();
}
- /**
- * Returns the SOAP 1.1 actor or SOAP 1.2 role attribute for the given header element.
- */
+ /** Returns the SOAP 1.1 actor or SOAP 1.2 role attribute for the given header element. */
public String getActorOrRole(SOAPHeaderElement headerElement) {
return headerElement.getActor();
}
- /**
- * Sets the SOAP 1.1 actor or SOAP 1.2 role attribute for the given header element.
- */
+ /** Sets the SOAP 1.1 actor or SOAP 1.2 role attribute for the given header element. */
public void setActorOrRole(SOAPHeaderElement headerElement, String actorOrRole) {
headerElement.setActor(actorOrRole);
}
- /**
- * Gets the must understand attribute for the given header element.
- */
+ /** Gets the must understand attribute for the given header element. */
public boolean getMustUnderstand(SOAPHeaderElement headerElement) {
return headerElement.getMustUnderstand();
}
- /**
- * Sets the must understand attribute for the given header element.
- */
+ /** Sets the must understand attribute for the given header element. */
public void setMustUnderstand(SOAPHeaderElement headerElement, boolean mustUnderstand) {
headerElement.setMustUnderstand(mustUnderstand);
}
- /**
- * Returns true if the body has a fault, false otherwise.
- */
+ /** Returns true if the body has a fault, false otherwise. */
public boolean hasFault(SOAPBody body) {
return body.hasFault();
}
- /**
- * Returns the fault for the given body, if any.
- */
+ /** Returns the fault for the given body, if any. */
public SOAPFault getFault(SOAPBody body) {
return body.getFault();
}
- /**
- * Returns the actor for the given fault.
- */
+ /** Returns the actor for the given fault. */
public String getFaultActor(SOAPFault fault) {
return fault.getFaultActor();
}
- /**
- * Sets the actor for the given fault.
- */
+ /** Sets the actor for the given fault. */
public void setFaultActor(SOAPFault fault, String actorOrRole) throws SOAPException {
fault.setFaultActor(actorOrRole);
}
- /**
- * Returns the fault string for the given fault.
- */
+ /** Returns the fault string for the given fault. */
public String getFaultString(SOAPFault fault) {
return fault.getFaultString();
}
- /**
- * Returns the fault string language for the given fault.
- */
+ /** Returns the fault string language for the given fault. */
public Locale getFaultStringLocale(SOAPFault fault) {
return Locale.ENGLISH;
}
- /**
- * Returns the fault detail for the given fault.
- */
+ /** Returns the fault detail for the given fault. */
public Detail getFaultDetail(SOAPFault fault) {
return fault.getDetail();
}
- /**
- * Adds a fault detail for the given fault.
- */
+ /** Adds a fault detail for the given fault. */
public Detail addFaultDetail(SOAPFault fault) throws SOAPException {
return fault.addDetail();
}
@@ -256,9 +222,7 @@ public class Saaj11Implementation implements SaajImplementation {
detailEntry.addTextNode(text);
}
- /**
- * Returns an iteration over all detail entries.
- */
+ /** Returns an iteration over all detail entries. */
public Iterator getDetailEntries(Detail detail) {
return detail.getDetailEntries();
}
@@ -321,7 +285,7 @@ public class Saaj11Implementation implements SaajImplementation {
}
//
- // SOAP 1.2
+ // Unsupported
//
public String getFaultRole(SOAPFault fault) {
diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/Saaj12Implementation.java b/core/src/main/java/org/springframework/ws/soap/saaj/Saaj12Implementation.java
index a1e191b7..77911604 100644
--- a/core/src/main/java/org/springframework/ws/soap/saaj/Saaj12Implementation.java
+++ b/core/src/main/java/org/springframework/ws/soap/saaj/Saaj12Implementation.java
@@ -235,7 +235,7 @@ public class Saaj12Implementation implements SaajImplementation {
}
//
- // SOAP 1.2
+ // Unsupported
//
public String getFaultRole(SOAPFault fault) {
@@ -277,4 +277,5 @@ public class Saaj12Implementation implements SaajImplementation {
public void setFaultReasonText(SOAPFault fault, Locale locale, String text) {
throw new UnsupportedOperationException("SAAJ 1.2 does not support SOAP 1.2");
}
+
}
diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/SaajImplementation.java b/core/src/main/java/org/springframework/ws/soap/saaj/SaajImplementation.java
index 7f344b41..085584f6 100644
--- a/core/src/main/java/org/springframework/ws/soap/saaj/SaajImplementation.java
+++ b/core/src/main/java/org/springframework/ws/soap/saaj/SaajImplementation.java
@@ -44,215 +44,132 @@ import javax.xml.transform.Source;
*/
public interface SaajImplementation {
- /**
- * Returns the name of the given element.
- */
+ /** Returns the name of the given element. */
QName getName(SOAPElement element);
- /**
- * Returns the readable Source of the given element.
- */
+ /** Returns the readable Source of the given element. */
Source getSource(SOAPElement element);
- /**
- * Returns the writable Result of the given element.
- */
+ /** Returns the writable Result of the given element. */
Result getResult(SOAPElement element);
- /**
- * Returns the envelope of the given message.
- */
+ /** Returns the envelope of the given message. */
SOAPEnvelope getEnvelope(SOAPMessage message) throws SOAPException;
- /**
- * Returns the header of the given envelope.
- */
+ /** Returns the header of the given envelope. */
SOAPHeader getHeader(SOAPEnvelope envelope) throws SOAPException;
- /**
- * Returns the body of the given envelope.
- */
+ /** Returns the body of the given envelope. */
SOAPBody getBody(SOAPEnvelope envelope) throws SOAPException;
- /**
- * Adds a header element to the given header.
- */
+ /** Adds a header element to the given header. */
SOAPHeaderElement addHeaderElement(SOAPHeader header, QName name) throws SOAPException;
- /**
- * Returns all header elements.
- */
+ /** Returns all header elements. */
Iterator examineAllHeaderElements(SOAPHeader header);
- /**
- * Returns all header elements for which the must understand attribute is true, given the actor or role.
- */
+ /** Returns all header elements for which the must understand attribute is true, given the actor or role. */
Iterator examineMustUnderstandHeaderElements(SOAPHeader header, String actorOrRole);
- /**
- * Returns the SOAP 1.1 actor or SOAP 1.2 role attribute for the given header element.
- */
+ /** Returns the SOAP 1.1 actor or SOAP 1.2 role attribute for the given header element. */
String getActorOrRole(SOAPHeaderElement headerElement);
- /**
- * Sets the SOAP 1.1 actor or SOAP 1.2 role attribute for the given header element.
- */
+ /** Sets the SOAP 1.1 actor or SOAP 1.2 role attribute for the given header element. */
void setActorOrRole(SOAPHeaderElement headerElement, String actorOrRole);
- /**
- * Gets the must understand attribute for the given header element.
- */
+ /** Gets the must understand attribute for the given header element. */
boolean getMustUnderstand(SOAPHeaderElement headerElement);
- /**
- * Sets the must understand attribute for the given header element.
- */
+ /** Sets the must understand attribute for the given header element. */
void setMustUnderstand(SOAPHeaderElement headerElement, boolean mustUnderstand);
- /**
- * Returns true if the body has a fault, false otherwise.
- */
+ /** Returns true if the body has a fault, false otherwise. */
boolean hasFault(SOAPBody body);
- /**
- * Returns the fault for the given body, if any.
- */
+ /** Returns the fault for the given body, if any. */
SOAPFault getFault(SOAPBody body);
- /**
- * Adds a fault to the given body.
- */
+ /** Adds a fault to the given body. */
SOAPFault addFault(SOAPBody body, QName faultCode, String faultString, Locale locale) throws SOAPException;
- /**
- * Returns the fault code for the given fault.
- */
+ /** Returns the fault code for the given fault. */
QName getFaultCode(SOAPFault fault);
- /**
- * Returns the actor for the given fault.
- */
+ /** Returns the actor for the given fault. */
String getFaultActor(SOAPFault fault);
- /**
- * Sets the actor for the given fault.
- */
+ /** Sets the actor for the given fault. */
void setFaultActor(SOAPFault fault, String actorOrRole) throws SOAPException;
- /**
- * Returns the fault string for the given fault.
- */
+ /** Returns the fault string for the given fault. */
String getFaultString(SOAPFault fault);
- /**
- * Returns the fault string language for the given fault.
- */
+ /** Returns the fault string language for the given fault. */
Locale getFaultStringLocale(SOAPFault fault);
- /**
- * Adds a detail entry to the given detail.
- */
+ /** Adds a detail entry to the given detail. */
DetailEntry addDetailEntry(Detail detail, QName name) throws SOAPException;
- /**
- * Returns the fault detail for the given fault.
- */
+ /** Returns the fault detail for the given fault. */
Detail getFaultDetail(SOAPFault fault);
- /**
- * Adds a fault detail for the given fault.
- */
+ /** Adds a fault detail for the given fault. */
Detail addFaultDetail(SOAPFault fault) throws SOAPException;
void addTextNode(DetailEntry detailEntry, String text) throws SOAPException;
- /**
- * Returns an iteration over all detail entries.
- */
+ /** Returns an iteration over all detail entries. */
Iterator getDetailEntries(Detail detail);
- /**
- * Returns the first child element of the given body.
- */
+ /** Returns the first child element of the given body. */
SOAPElement getFirstBodyElement(SOAPBody body);
- /**
- * Removes the contents (i.e. children) of the element.
- */
+ /** Removes the contents (i.e. children) of the element. */
void removeContents(SOAPElement element);
- /**
- * Writes the given message to the given stream.
- */
+ /** Writes the given message to the given stream. */
void writeTo(SOAPMessage message, OutputStream outputStream) throws SOAPException, IOException;
- /**
- * Returns the MIME headers of the message.
- */
+ /** Returns the MIME headers of the message. */
MimeHeaders getMimeHeaders(SOAPMessage message);
- /**
- * Returns an iteration over all attachments in the message.
- */
+ /** Returns an iteration over all attachments in the message. */
Iterator getAttachments(SOAPMessage message);
- /**
- * Returns an iteration over all attachments in the message with the given headers.
- */
+ /** Returns an iteration over all attachments in the message with the given headers. */
Iterator getAttachment(SOAPMessage message, MimeHeaders mimeHeaders);
- /**
- * Adds an attachment to the given message.
- */
+ /** Adds an attachment to the given message. */
AttachmentPart addAttachmentPart(SOAPMessage message, DataSource dataSource);
- /**
- * Adds a not understood header element to the given header.
- */
+ /** Adds a not understood header element to the given header. */
SOAPHeaderElement addNotUnderstoodHeaderElement(SOAPHeader header, QName name) throws SOAPException;
- /**
- * Adds a upgrade header element to the given header.
- */
+ /** Adds a upgrade header element to the given header. */
SOAPHeaderElement addUpgradeHeaderElement(SOAPHeader header, String[] supportedSoapUris) throws SOAPException;
- /**
- * Returns the fault role.
- */
+ /** Returns the fault role. */
String getFaultRole(SOAPFault fault);
- /**
- * Sets the fault role.
- */
+ /** Sets the fault role. */
void setFaultRole(SOAPFault fault, String role) throws SOAPException;
- /**
- * Returns the fault sub code.
- */
+ /** Returns the fault sub code. */
Iterator getFaultSubcodes(SOAPFault fault);
- /**
- * Adds a fault sub code.
- */
+ /** Adds a fault sub code. */
void appendFaultSubcode(SOAPFault fault, QName subcode) throws SOAPException;
- /**
- * Returns the fault node.
- */
+ /** Returns the fault node. */
String getFaultNode(SOAPFault fault);
- /**
- * Sets the fault node.
- */
+ /** Sets the fault node. */
void setFaultNode(SOAPFault fault, String uri) throws SOAPException;
- /**
- * Returns the fault reason text.
- */
+ /** Returns the fault reason text. */
String getFaultReasonText(SOAPFault fault, Locale locale) throws SOAPException;
- /**
- * Sets the fault reason text.
- */
+ /** Sets the fault reason text. */
void setFaultReasonText(SOAPFault fault, Locale locale, String text) throws SOAPException;
+
}
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 172d8e85..987858ca 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
@@ -36,18 +36,20 @@ import org.springframework.ws.soap.AbstractSoapMessage;
import org.springframework.ws.soap.Attachment;
import org.springframework.ws.soap.AttachmentException;
import org.springframework.ws.soap.SoapEnvelope;
+import org.springframework.ws.soap.SoapMessage;
import org.springframework.ws.soap.saaj.support.SaajUtils;
/**
- * SAAJ-specific implementation of the SoapMessage interface. Accessed via the
- * SaajSoapMessageContext.
+ * SAAJ-specific implementation of the {@link SoapMessage} interface. Created via the {@link SaajSoapMessageFactory}.
*
* @author Arjen Poutsma
* @see javax.xml.soap.SOAPMessage
*/
public class SaajSoapMessage extends AbstractSoapMessage {
- private static final String SOAP_ACTION_HEADER = "SOAPAction";
+ private static final String MIME_HEADER_SOAP_ACTION = "SOAPAction";
+
+ private static final String MIME_HEADER_CONTENT_ID = "Content-Id";
private SOAPMessage saajMessage;
@@ -63,16 +65,12 @@ public class SaajSoapMessage extends AbstractSoapMessage {
saajMessage = soapMessage;
}
- /**
- * Return the SAAJ SOAPMessage that this SaajSoapMessage is based on.
- */
+ /** Return the SAAJ SOAPMessage that this SaajSoapMessage is based on. */
public SOAPMessage getSaajMessage() {
return saajMessage;
}
- /**
- * Sets the SAAJ SOAPMessage that this SaajSoapMessage is based on.
- */
+ /** Sets the SAAJ SOAPMessage that this SaajSoapMessage is based on. */
public void setSaajMessage(SOAPMessage soapMessage) {
Assert.notNull(soapMessage, "soapMessage must not be null");
saajMessage = soapMessage;
@@ -93,13 +91,13 @@ public class SaajSoapMessage extends AbstractSoapMessage {
public String getSoapAction() {
MimeHeaders mimeHeaders = getImplementation().getMimeHeaders(getSaajMessage());
- String[] values = mimeHeaders.getHeader(SOAP_ACTION_HEADER);
+ String[] values = mimeHeaders.getHeader(MIME_HEADER_SOAP_ACTION);
return ObjectUtils.isEmpty(values) ? null : values[0];
}
public void setSoapAction(String soapAction) {
MimeHeaders mimeHeaders = getImplementation().getMimeHeaders(getSaajMessage());
- mimeHeaders.setHeader(SOAP_ACTION_HEADER, soapAction);
+ mimeHeaders.setHeader(MIME_HEADER_SOAP_ACTION, soapAction);
}
public void writeTo(OutputStream outputStream) throws IOException {
@@ -118,16 +116,20 @@ public class SaajSoapMessage extends AbstractSoapMessage {
}
public Attachment getAttachment(String contentId) {
+ Assert.hasLength(contentId, "contentId must not be empty");
MimeHeaders mimeHeaders = new MimeHeaders();
- mimeHeaders.addHeader("Content-Id", contentId);
+ mimeHeaders.setHeader(MIME_HEADER_CONTENT_ID, contentId);
Iterator iterator = getImplementation().getAttachment(getSaajMessage(), mimeHeaders);
+ if (!iterator.hasNext()) {
+ // try to prefix it with an MTOM-specific < and >
+ mimeHeaders.setHeader(MIME_HEADER_CONTENT_ID, "<" + contentId + ">");
+ iterator = getImplementation().getAttachment(getSaajMessage(), mimeHeaders);
+ }
if (!iterator.hasNext()) {
return null;
}
- else {
- AttachmentPart saajAttachment = (AttachmentPart) iterator.next();
- return new SaajAttachment(saajAttachment);
- }
+ AttachmentPart saajAttachment = (AttachmentPart) iterator.next();
+ return new SaajAttachment(saajAttachment);
}
public Attachment addAttachment(File file) throws AttachmentException {
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 b3bc484d..fe6d6586 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
@@ -105,7 +105,7 @@ public abstract class SaajUtils {
/**
* Converts a javax.xml.namespace.QName to a javax.xml.soap.Name. A
- * SOAPEnvelope is required to create the name.
+ * SOAPElement is required to create the name.
*
* @param qName the QName to convert
* @param resolveElement a SOAPElement used to resolve namespaces to prefixes
diff --git a/core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap11MessageFactoryTest.java b/core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap11MessageFactoryTest.java
index f5e76458..146ebd2b 100644
--- a/core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap11MessageFactoryTest.java
+++ b/core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap11MessageFactoryTest.java
@@ -27,4 +27,39 @@ public class AxiomSoap11MessageFactoryTest extends AbstractSoap11MessageFactoryT
return factory;
}
+/*
+ public void testCreateMtom() throws Exception {
+ SOAP11Factory factory = new SOAP11Factory();
+ SOAPEnvelope envelope = factory.getDefaultEnvelope();
+
+ OMNamespace namespace = factory.createOMNamespace("http://springframework.org/spring-ws/mtom", "sws");
+ OMElement element = factory.createOMElement("image", namespace);
+ envelope.getBody().addChild(element);
+ DataHandler dataHandler = new javax.activation.DataHandler(new FileDataSource("/Users/arjen/spring-ws/src/site/resources/images/spring-ws.png"));
+
+ //create an OMText node with the above DataHandler and set optimized to true
+ OMText textData = factory.createOMText(dataHandler, true);
+
+ element.addChild(textData);
+
+ OMOutputFormat format = new OMOutputFormat();
+ format.setDoOptimize(true);
+ format.setSOAP11(true);
+ format.setCharSetEncoding("UTF-8");
+ assertTrue(format.isOptimized());
+ OutputStream os = new BufferedOutputStream(new FileOutputStream(
+ "/Users/arjen/Projects/Spring/spring-ws/core/src/test/resources/org/springframework/ws/soap/soap11/soap11-mtom.bin"));
+ try {
+ envelope.serialize(os, format);
+ } finally {
+ os.close();
+ }
+
+
+
+
+ }
+*/
+
+
}
\ No newline at end of file
diff --git a/core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap12MessageFactoryTest.java b/core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap12MessageFactoryTest.java
index d3f4b51a..104044ab 100644
--- a/core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap12MessageFactoryTest.java
+++ b/core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap12MessageFactoryTest.java
@@ -34,4 +34,5 @@ public class AxiomSoap12MessageFactoryTest extends AbstractSoap12MessageFactoryT
// Axiom does not support SwA with SOAP 1.2
}
+
}
diff --git a/core/src/test/java/org/springframework/ws/soap/saaj/SaajSoap11MessageFactoryTest.java b/core/src/test/java/org/springframework/ws/soap/saaj/SaajSoap11MessageFactoryTest.java
index 0893b5b1..9dc64e38 100644
--- a/core/src/test/java/org/springframework/ws/soap/saaj/SaajSoap11MessageFactoryTest.java
+++ b/core/src/test/java/org/springframework/ws/soap/saaj/SaajSoap11MessageFactoryTest.java
@@ -30,4 +30,6 @@ public class SaajSoap11MessageFactoryTest extends AbstractSoap11MessageFactoryTe
factory.afterPropertiesSet();
return factory;
}
+
+
}
\ No newline at end of file
diff --git a/core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11MessageFactoryTestCase.java b/core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11MessageFactoryTestCase.java
index 64324912..0678814e 100644
--- a/core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11MessageFactoryTestCase.java
+++ b/core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11MessageFactoryTestCase.java
@@ -17,6 +17,7 @@
package org.springframework.ws.soap.soap11;
import java.io.InputStream;
+import java.util.Iterator;
import java.util.Properties;
import org.springframework.ws.WebServiceMessage;
@@ -51,7 +52,7 @@ public abstract class AbstractSoap11MessageFactoryTestCase extends AbstractSoapM
assertEquals("Invalid soap action", soapAction, soapMessage.getSoapAction());
}
- public void testCreateSoapMessageAttachment() throws Exception {
+ public void testCreateSoapMessageSwA() throws Exception {
InputStream is = AbstractSoap11MessageFactoryTestCase.class.getResourceAsStream("soap11-attachment.bin");
Properties headers = new Properties();
headers.setProperty("Content-Type",
@@ -62,8 +63,30 @@ public abstract class AbstractSoap11MessageFactoryTestCase extends AbstractSoapM
assertTrue("Not a SoapMessage", message instanceof SoapMessage);
SoapMessage soapMessage = (SoapMessage) message;
assertEquals("Invalid soap version", SoapVersion.SOAP_11, soapMessage.getVersion());
+ Iterator iter = soapMessage.getAttachments();
+ assertTrue("No attachments read", iter.hasNext());
Attachment attachment = soapMessage.getAttachment("interface21");
assertNotNull("No attachment read", attachment);
+ assertEquals("Invalid content id", "interface21", attachment.getId());
+ }
+
+ public void testCreateSoapMessageMtom() throws Exception {
+ InputStream is = AbstractSoap11MessageFactoryTestCase.class.getResourceAsStream("soap11-mtom.bin");
+ Properties headers = new Properties();
+ headers.setProperty("Content-Type", "multipart/related;" + "start-info=\"text/xml\";" +
+ "type=\"application/xop+xml\";" + "start=\"<0.urn:uuid:492264AB42E57108E01176731445508@apache.org>\";" +
+ "boundary=\"MIMEBoundaryurn_uuid_492264AB42E57108E01176731445507\"");
+ TransportInputStream tis = new MockTransportInputStream(is, headers);
+
+ WebServiceMessage message = messageFactory.createWebServiceMessage(tis);
+ assertTrue("Not a SoapMessage", message instanceof SoapMessage);
+ SoapMessage soapMessage = (SoapMessage) message;
+ assertEquals("Invalid soap version", SoapVersion.SOAP_11, soapMessage.getVersion());
+ Iterator iter = soapMessage.getAttachments();
+ assertTrue("No attachments read", iter.hasNext());
+
+ Attachment attachment = soapMessage.getAttachment("1.urn:uuid:492264AB42E57108E01176731445504@apache.org");
+ assertNotNull("No attachment read", attachment);
}
diff --git a/core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12MessageFactoryTestCase.java b/core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12MessageFactoryTestCase.java
index 1935e3b1..f3a6e4a1 100644
--- a/core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12MessageFactoryTestCase.java
+++ b/core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12MessageFactoryTestCase.java
@@ -17,6 +17,7 @@
package org.springframework.ws.soap.soap12;
import java.io.InputStream;
+import java.util.Iterator;
import java.util.Properties;
import org.springframework.ws.WebServiceMessage;
@@ -63,5 +64,24 @@ public abstract class AbstractSoap12MessageFactoryTestCase extends AbstractSoapM
assertNotNull("No attachment read", attachment);
}
+ public void testCreateSoapMessageMtom() throws Exception {
+ InputStream is = AbstractSoap12MessageFactoryTestCase.class.getResourceAsStream("soap12-mtom.bin");
+ Properties headers = new Properties();
+ headers.setProperty("Content-Type", "multipart/related;" + "start-info=\"application/soap+xml\";" +
+ "type=\"application/xop+xml\";" + "start=\"<0.urn:uuid:40864869929B855F971176851454456@apache.org>\";" +
+ "boundary=\"MIMEBoundaryurn_uuid_40864869929B855F971176851454455\"");
+ TransportInputStream tis = new MockTransportInputStream(is, headers);
+
+ WebServiceMessage message = messageFactory.createWebServiceMessage(tis);
+ assertTrue("Not a SoapMessage", message instanceof SoapMessage);
+ SoapMessage soapMessage = (SoapMessage) message;
+ assertEquals("Invalid soap version", SoapVersion.SOAP_12, soapMessage.getVersion());
+ Iterator iter = soapMessage.getAttachments();
+ assertTrue("No attachments read", iter.hasNext());
+
+ Attachment attachment = soapMessage.getAttachment("1.urn:uuid:40864869929B855F971176851454452@apache.org");
+ assertNotNull("No attachment read", attachment);
+ }
+
}
diff --git a/core/src/test/resources/org/springframework/ws/soap/soap11/soap11-mtom.bin b/core/src/test/resources/org/springframework/ws/soap/soap11/soap11-mtom.bin
new file mode 100644
index 00000000..cec137ac
Binary files /dev/null and b/core/src/test/resources/org/springframework/ws/soap/soap11/soap11-mtom.bin differ
diff --git a/core/src/test/resources/org/springframework/ws/soap/soap12/soap12-mtom.bin b/core/src/test/resources/org/springframework/ws/soap/soap12/soap12-mtom.bin
new file mode 100644
index 00000000..91e863fe
Binary files /dev/null and b/core/src/test/resources/org/springframework/ws/soap/soap12/soap12-mtom.bin differ
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 75cf4634..4bcafb42 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -6,6 +6,7 @@