Fixed #SWS-62: MTOM support.
This commit is contained in:
@@ -34,9 +34,7 @@ import org.springframework.ws.WebServiceMessage;
|
||||
*/
|
||||
public interface SoapMessage extends WebServiceMessage {
|
||||
|
||||
/**
|
||||
* Returns the <code>SoapEnvelope</code> associated with this <code>SoapMessage</code>.
|
||||
*/
|
||||
/** Returns the <code>SoapEnvelope</code> associated with this <code>SoapMessage</code>. */
|
||||
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 <code>SoapBody</code> associated with this <code>SoapMessage</code>. This is a convenience method for
|
||||
* <code>getEnvelope().getBody()</code>.
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 <code>SoapMessage</code> interface. Accessed via the
|
||||
* <code>AxiomSoapMessageContext</code>.
|
||||
* AXIOM-specific implementation of the {@link SoapMessage} interface. Created via the {@link AxiomSoapMessageFactory}.
|
||||
* <p/>
|
||||
* Note that Axiom does support reading SOAP with Attachments (SwA) messages, but does not support creating them
|
||||
* manually. Hence, the <code>addAttachment</code> methods throw an <code>UnsupportedOperationException</code>.
|
||||
@@ -111,9 +111,7 @@ public class AxiomSoapMessage extends AbstractSoapMessage {
|
||||
this.payloadCaching = payloadCaching;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the AXIOM <code>SOAPMessage</code> that this <code>AxiomSoapMessage</code> is based on.
|
||||
*/
|
||||
/** Return the AXIOM <code>SOAPMessage</code> that this <code>AxiomSoapMessage</code> is based on. */
|
||||
public final SOAPMessage getAxiomMessage() {
|
||||
return axiomMessage;
|
||||
}
|
||||
@@ -196,9 +194,7 @@ public class AxiomSoapMessage extends AbstractSoapMessage {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Axiom-specific implementation of <code>org.springframework.ws.soap.Attachment</code>
|
||||
*/
|
||||
/** Axiom-specific implementation of <code>org.springframework.ws.soap.Attachment</code> */
|
||||
private static class AxiomAttachment implements Attachment {
|
||||
|
||||
private final DataHandler dataHandler;
|
||||
|
||||
@@ -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
|
||||
*
|
||||
|
||||
@@ -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 <code>true</code> if the body has a fault, <code>false</code> otherwise.
|
||||
*/
|
||||
/** Returns <code>true</code> if the body has a fault, <code>false</code> 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) {
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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 <code>Source</code> of the given element.
|
||||
*/
|
||||
/** Returns the readable <code>Source</code> of the given element. */
|
||||
Source getSource(SOAPElement element);
|
||||
|
||||
/**
|
||||
* Returns the writable <code>Result</code> of the given element.
|
||||
*/
|
||||
/** Returns the writable <code>Result</code> 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 <code>true</code> if the body has a fault, <code>false</code> otherwise.
|
||||
*/
|
||||
/** Returns <code>true</code> if the body has a fault, <code>false</code> 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;
|
||||
|
||||
}
|
||||
|
||||
@@ -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 <code>SoapMessage</code> interface. Accessed via the
|
||||
* <code>SaajSoapMessageContext</code>.
|
||||
* 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 <code>SOAPMessage</code> that this <code>SaajSoapMessage</code> is based on.
|
||||
*/
|
||||
/** Return the SAAJ <code>SOAPMessage</code> that this <code>SaajSoapMessage</code> is based on. */
|
||||
public SOAPMessage getSaajMessage() {
|
||||
return saajMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the SAAJ <code>SOAPMessage</code> that this <code>SaajSoapMessage</code> is based on.
|
||||
*/
|
||||
/** Sets the SAAJ <code>SOAPMessage</code> that this <code>SaajSoapMessage</code> 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 {
|
||||
|
||||
@@ -105,7 +105,7 @@ public abstract class SaajUtils {
|
||||
|
||||
/**
|
||||
* Converts a <code>javax.xml.namespace.QName</code> to a <code>javax.xml.soap.Name</code>. A
|
||||
* <code>SOAPEnvelope</code> is required to create the name.
|
||||
* <code>SOAPElement</code> is required to create the name.
|
||||
*
|
||||
* @param qName the <code>QName</code> to convert
|
||||
* @param resolveElement a <code>SOAPElement</code> used to resolve namespaces to prefixes
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
@@ -34,4 +34,5 @@ public class AxiomSoap12MessageFactoryTest extends AbstractSoap12MessageFactoryT
|
||||
// Axiom does not support SwA with SOAP 1.2
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -30,4 +30,6 @@ public class SaajSoap11MessageFactoryTest extends AbstractSoap11MessageFactoryTe
|
||||
factory.afterPropertiesSet();
|
||||
return factory;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -6,6 +6,7 @@
|
||||
</properties>
|
||||
<body>
|
||||
<release version="1.0-RC1">
|
||||
<action dev="poutsma" type="add" issue="SWS-62">MTOM support</action>
|
||||
<action dev="poutsma" type="add">Added XPathExpressionFactoryBean, for injection of XPath expressions
|
||||
</action>
|
||||
<action dev="poutsma" type="fix" issue="SWS-106">Default message factory for WebServiceTemplate</action>
|
||||
|
||||
Reference in New Issue
Block a user