Better testing of SAAJ

This commit is contained in:
Arjen Poutsma
2006-10-15 18:12:01 +00:00
parent 745e0a9fe1
commit f740700d1e
54 changed files with 1127 additions and 641 deletions

View File

@@ -39,8 +39,6 @@ import org.springframework.ws.soap.Attachment;
import org.springframework.ws.soap.AttachmentException;
import org.springframework.ws.soap.SoapEnvelope;
import org.springframework.ws.soap.SoapVersion;
import org.springframework.ws.soap.saaj.saaj12.Saaj12SoapEnvelope;
import org.springframework.ws.soap.saaj.saaj13.Saaj13SoapEnvelope;
import org.springframework.ws.soap.saaj.support.SaajUtils;
/**
@@ -51,18 +49,18 @@ import org.springframework.ws.soap.saaj.support.SaajUtils;
* @see javax.xml.soap.SOAPMessage
* @see SaajSoapMessageContext
*/
public class SaajSoapMessage extends AbstractSoapMessage {
public abstract class SaajSoapMessage extends AbstractSoapMessage {
private final SOAPMessage saajMessage;
private SaajSoapEnvelope envelope;
private SoapEnvelope envelope;
/**
* Create a new <code>SaajSoapMessage</code> based on the given SAAJ <code>SOAPMessage</code>.
*
* @param soapMessage the SAAJ SOAPMessage
*/
public SaajSoapMessage(SOAPMessage soapMessage) {
protected SaajSoapMessage(SOAPMessage soapMessage) {
saajMessage = soapMessage;
}
@@ -73,16 +71,11 @@ public class SaajSoapMessage extends AbstractSoapMessage {
return saajMessage;
}
public SoapEnvelope getEnvelope() {
public final SoapEnvelope getEnvelope() {
if (envelope == null) {
try {
SOAPEnvelope saajEnvelope = saajMessage.getSOAPPart().getEnvelope();
if (SaajUtils.getSaajVersion() == SaajUtils.SAAJ_12) {
envelope = new Saaj12SoapEnvelope(saajEnvelope);
}
else {
envelope = new Saaj13SoapEnvelope(saajEnvelope);
}
envelope = createSaajSoapEnvelope(saajEnvelope);
}
catch (SOAPException ex) {
throw new SaajSoapEnvelopeException(ex);
@@ -91,7 +84,9 @@ public class SaajSoapMessage extends AbstractSoapMessage {
return envelope;
}
public void writeTo(OutputStream outputStream) throws IOException {
protected abstract SoapEnvelope createSaajSoapEnvelope(SOAPEnvelope saajEnvelope);
public final void writeTo(OutputStream outputStream) throws IOException {
try {
if (saajMessage.saveRequired()) {
saajMessage.saveChanges();

View File

@@ -39,7 +39,7 @@ import org.springframework.ws.transport.TransportResponse;
* @author Arjen Poutsma
* @see SaajSoapMessageContextFactory
*/
public class SaajSoapMessageContext extends AbstractSoapMessageContext {
public abstract class SaajSoapMessageContext extends AbstractSoapMessageContext {
private final MessageFactory messageFactory;
@@ -50,43 +50,15 @@ public class SaajSoapMessageContext extends AbstractSoapMessageContext {
* @param transportRequest the transport request
* @param messageFactory the message factory used for creating a response
*/
public SaajSoapMessageContext(SOAPMessage request,
TransportRequest transportRequest,
MessageFactory messageFactory) {
super(new SaajSoapMessage(request), transportRequest);
protected SaajSoapMessageContext(SaajSoapMessage request,
TransportRequest transportRequest,
MessageFactory messageFactory) {
super(request, transportRequest);
Assert.notNull(messageFactory);
this.messageFactory = messageFactory;
}
/**
* Returns the request as a SAAJ SOAP message.
*/
public SOAPMessage getSaajRequest() {
return ((SaajSoapMessage) getSoapRequest()).getSaajMessage();
}
/**
* Sets the request to the given SAAJ SOAP message.
*/
public void setSaajRequest(SOAPMessage request) {
setRequest(new SaajSoapMessage(request));
}
/**
* Returns the response as a SAAJ SOAP message.
*/
public SOAPMessage getSaajResponse() {
return ((SaajSoapMessage) getSoapResponse()).getSaajMessage();
}
/**
* Sets the response to the given SAAJ SOAP message.
*/
public void setSaajResponse(SOAPMessage response) {
setResponse(new SaajSoapMessage(response));
}
public void sendResponse(TransportResponse transportResponse) throws IOException {
public final void sendResponse(TransportResponse transportResponse) throws IOException {
if (hasResponse()) {
SOAPMessage response = getSaajResponse();
try {
@@ -111,17 +83,45 @@ public class SaajSoapMessageContext extends AbstractSoapMessageContext {
throw new SaajSoapMessageException("Could not write message to TransportResponse: " + ex.getMessage(),
ex);
}
}
}
protected SoapMessage createResponseSoapMessage() {
try {
SOAPMessage saajMessage = messageFactory.createMessage();
return new SaajSoapMessage(saajMessage);
return createSaajSoapMessage(saajMessage);
}
catch (SOAPException ex) {
throw new SoapMessageCreationException("Could not create message: " + ex.toString(), ex);
}
}
/**
* Creates a new <code>SaajSoapMessage</code> using the given SAAJ message.
*/
protected abstract SaajSoapMessage createSaajSoapMessage(SOAPMessage saajMessage);
/**
* Returns the request as a SAAJ SOAP message.
*/
public final SOAPMessage getSaajRequest() {
return ((SaajSoapMessage) getSoapRequest()).getSaajMessage();
}
/**
* Returns the response as a SAAJ SOAP message.
*/
public final SOAPMessage getSaajResponse() {
return ((SaajSoapMessage) getSoapResponse()).getSaajMessage();
}
/**
* Sets the request to the given SAAJ SOAP message.
*/
public abstract void setSaajRequest(SOAPMessage request);
/**
* Sets the response to the given SAAJ SOAP message.
*/
public abstract void setSaajResponse(SOAPMessage response);
}

View File

@@ -32,6 +32,8 @@ import org.springframework.util.StringUtils;
import org.springframework.ws.context.MessageContext;
import org.springframework.ws.context.MessageContextFactory;
import org.springframework.ws.soap.SoapMessageCreationException;
import org.springframework.ws.soap.saaj.saaj12.Saaj12SoapMessageContext;
import org.springframework.ws.soap.saaj.saaj13.Saaj13SoapMessageContext;
import org.springframework.ws.soap.saaj.support.SaajUtils;
import org.springframework.ws.transport.TransportContext;
import org.springframework.ws.transport.TransportRequest;
@@ -113,7 +115,16 @@ public class SaajSoapMessageContextFactory implements MessageContextFactory, Ini
}
try {
SOAPMessage requestMessage = messageFactory.createMessage(mimeHeaders, transportRequest.getInputStream());
return new SaajSoapMessageContext(requestMessage, transportRequest, messageFactory);
if (SaajUtils.getSaajVersion() >= SaajUtils.SAAJ_13) {
return new Saaj13SoapMessageContext(requestMessage, transportRequest, messageFactory);
}
else if (SaajUtils.getSaajVersion() == SaajUtils.SAAJ_12) {
return new Saaj12SoapMessageContext(requestMessage, transportRequest, messageFactory);
}
else {
throw new IllegalStateException(
"SaajSoapMessageContextFactory requires SAAJ 1.2, which was not" + "found on the classpath");
}
}
catch (SOAPException ex) {
throw new SoapMessageCreationException("Could not create message from TransportRequest: " + ex.getMessage(),

View File

@@ -43,23 +43,10 @@ import org.springframework.ws.soap.soap11.Soap11Fault;
*
* @author Arjen Poutsma
*/
class Saaj12Soap11Body implements Soap11Body {
private final SOAPBody saajBody;
class Saaj12Soap11Body extends Saaj12SoapElement implements Soap11Body {
Saaj12Soap11Body(SOAPBody saajBody) {
Assert.notNull(saajBody, "No saajBody given");
this.saajBody = saajBody;
}
public Source getPayloadSource() {
SOAPBodyElement payloadElement = getPayloadElement();
return payloadElement != null ? new DOMSource(payloadElement) : null;
}
public Result getPayloadResult() {
saajBody.removeContents();
return new DOMResult(saajBody);
super(saajBody);
}
public Soap11Fault addFault(QName faultCode, String faultString, Locale faultStringLocale) {
@@ -70,14 +57,14 @@ class Saaj12Soap11Body implements Soap11Body {
"A fault code with namespace and local part must be specific for a custom fault code");
}
try {
Name name = SaajUtils.toName(faultCode, saajBody, getEnvelope());
saajBody.removeContents();
Name name = SaajUtils.toName(faultCode, getSaajBody(), getEnvelope());
getSaajBody().removeContents();
SOAPFault saajFault;
if (faultStringLocale == null) {
saajFault = saajBody.addFault(name, faultString);
saajFault = getSaajBody().addFault(name, faultString);
}
else {
saajFault = saajBody.addFault(name, faultString, faultStringLocale);
saajFault = getSaajBody().addFault(name, faultString, faultStringLocale);
}
return new Saaj12Soap11Fault(saajFault);
}
@@ -86,14 +73,14 @@ class Saaj12Soap11Body implements Soap11Body {
}
}
public SoapFault addMustUnderstandFault(String faultString, Locale locale) {
return addStandardFault("MustUnderstand", faultString, locale);
}
public SoapFault addClientOrSenderFault(String faultString, Locale locale) {
return addStandardFault("Client", faultString, locale);
}
public SoapFault addMustUnderstandFault(String faultString, Locale locale) {
return addStandardFault("MustUnderstand", faultString, locale);
}
public SoapFault addServerOrReceiverFault(String faultString, Locale locale) {
return addStandardFault("Server", faultString, locale);
}
@@ -102,17 +89,36 @@ class Saaj12Soap11Body implements Soap11Body {
return addStandardFault("VersionMismatch", faultString, locale);
}
public SoapFault getFault() {
return new Saaj12Soap11Fault(getSaajBody().getFault());
}
public final Result getPayloadResult() {
getSaajBody().removeContents();
return new DOMResult(getSaajBody());
}
public final Source getPayloadSource() {
SOAPBodyElement payloadElement = getPayloadElement();
return payloadElement != null ? new DOMSource(payloadElement) : null;
}
public final boolean hasFault() {
return getSaajBody().hasFault();
}
private Soap11Fault addStandardFault(String localName, String faultString, Locale locale) {
try {
Name faultCode = getEnvelope()
.createName(localName, saajBody.getElementName().getPrefix(), saajBody.getElementName().getURI());
saajBody.removeContents();
.createName(localName, getSaajBody().getElementName().getPrefix(),
getSaajBody().getElementName().getURI());
getSaajBody().removeContents();
SOAPFault saajFault;
if (locale == null) {
saajFault = saajBody.addFault(faultCode, faultString);
saajFault = getSaajBody().addFault(faultCode, faultString);
}
else {
saajFault = saajBody.addFault(faultCode, faultString, locale);
saajFault = getSaajBody().addFault(faultCode, faultString, locale);
}
return new Saaj12Soap11Fault(saajFault);
}
@@ -121,24 +127,8 @@ class Saaj12Soap11Body implements Soap11Body {
}
}
public boolean hasFault() {
return saajBody.hasFault();
}
public SoapFault getFault() {
return new Saaj12Soap11Fault(saajBody.getFault());
}
public QName getName() {
return SaajUtils.toQName(saajBody.getElementName());
}
public Source getSource() {
return new DOMSource(saajBody);
}
private SOAPEnvelope getEnvelope() {
return (SOAPEnvelope) saajBody.getParentElement();
return (SOAPEnvelope) getSaajBody().getParentElement();
}
/**
@@ -148,7 +138,7 @@ class Saaj12Soap11Body implements Soap11Body {
* @return the message payload, or <code>null</code> if none is set.
*/
private SOAPBodyElement getPayloadElement() {
for (Iterator iterator = saajBody.getChildElements(); iterator.hasNext();) {
for (Iterator iterator = getSaajBody().getChildElements(); iterator.hasNext();) {
Object child = iterator.next();
if (child instanceof SOAPBodyElement) {
return (SOAPBodyElement) child;
@@ -156,4 +146,8 @@ class Saaj12Soap11Body implements Soap11Body {
}
return null;
}
protected final SOAPBody getSaajBody() {
return (SOAPBody) getSaajElement();
}
}

View File

@@ -21,10 +21,7 @@ import javax.xml.namespace.QName;
import javax.xml.soap.Detail;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFault;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import org.springframework.util.Assert;
import org.springframework.ws.soap.SoapFaultDetail;
import org.springframework.ws.soap.saaj.SaajSoapFaultException;
import org.springframework.ws.soap.saaj.support.SaajUtils;
@@ -35,60 +32,53 @@ import org.springframework.ws.soap.soap11.Soap11Fault;
*
* @author Arjen Poutsma
*/
class Saaj12Soap11Fault implements Soap11Fault {
private final SOAPFault saajFault;
class Saaj12Soap11Fault extends Saaj12SoapElement implements Soap11Fault {
Saaj12Soap11Fault(SOAPFault saajFault) {
Assert.notNull(saajFault, "No saajFault given");
this.saajFault = saajFault;
}
public QName getName() {
return SaajUtils.toQName(saajFault.getElementName());
}
public Source getSource() {
return new DOMSource(saajFault);
}
public QName getFaultCode() {
return SaajUtils.toQName(saajFault.getFaultCodeAsName());
super(saajFault);
}
public String getFaultString() {
return saajFault.getFaultString();
}
public String getFaultActorOrRole() {
return saajFault.getFaultActor();
}
public void setFaultActorOrRole(String faultActor) {
try {
saajFault.setFaultActor(faultActor);
}
catch (SOAPException ex) {
throw new SaajSoapFaultException(ex);
}
return getSaajFault().getFaultString();
}
public Locale getFaultStringLocale() {
return saajFault.getFaultStringLocale();
}
public SoapFaultDetail getFaultDetail() {
Detail saajDetail = saajFault.getDetail();
return saajDetail != null ? new Saaj12SoapFaultDetail(saajDetail) : null;
return getSaajFault().getFaultStringLocale();
}
public SoapFaultDetail addFaultDetail() {
try {
Detail saajDetail = saajFault.addDetail();
Detail saajDetail = getSaajFault().addDetail();
return saajDetail != null ? new Saaj12SoapFaultDetail(saajDetail) : null;
}
catch (SOAPException ex) {
throw new SaajSoapFaultException(ex);
}
}
public String getFaultActorOrRole() {
return getSaajFault().getFaultActor();
}
public QName getFaultCode() {
return SaajUtils.toQName(getSaajFault().getFaultCodeAsName());
}
public SoapFaultDetail getFaultDetail() {
Detail saajDetail = getSaajFault().getDetail();
return saajDetail != null ? new Saaj12SoapFaultDetail(saajDetail) : null;
}
public void setFaultActorOrRole(String faultActor) {
try {
getSaajFault().setFaultActor(faultActor);
}
catch (SOAPException ex) {
throw new SaajSoapFaultException(ex);
}
}
protected SOAPFault getSaajFault() {
return (SOAPFault) getSaajElement();
}
}

View File

@@ -0,0 +1,48 @@
/*
* Copyright 2006 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ws.soap.saaj.saaj12;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPElement;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import org.springframework.util.Assert;
import org.springframework.ws.soap.SoapElement;
import org.springframework.ws.soap.saaj.support.SaajUtils;
abstract class Saaj12SoapElement implements SoapElement {
private final SOAPElement saajElement;
protected Saaj12SoapElement(SOAPElement saajElement) {
Assert.notNull(saajElement, "No saajElement given");
this.saajElement = saajElement;
}
protected SOAPElement getSaajElement() {
return saajElement;
}
public final QName getName() {
return SaajUtils.toQName(saajElement.getElementName());
}
public final Source getSource() {
return new DOMSource(saajElement);
}
}

View File

@@ -16,18 +16,15 @@
package org.springframework.ws.soap.saaj.saaj12;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import javax.xml.soap.SOAPHeader;
import org.springframework.ws.soap.SoapBody;
import org.springframework.ws.soap.SoapEnvelope;
import org.springframework.ws.soap.SoapHeader;
import org.springframework.ws.soap.saaj.SaajSoapBodyException;
import org.springframework.ws.soap.saaj.SaajSoapEnvelope;
import org.springframework.ws.soap.saaj.SaajSoapHeaderException;
import org.springframework.ws.soap.saaj.support.SaajUtils;
/**
* Internal class that uses SAAJ 1.2 to implement the <code>SoapEnvelope</code> interface. Used by
@@ -35,38 +32,17 @@ import org.springframework.ws.soap.saaj.support.SaajUtils;
*
* @author Arjen Poutsma
*/
public class Saaj12SoapEnvelope extends SaajSoapEnvelope {
private Saaj12SoapHeader header;
class Saaj12SoapEnvelope extends Saaj12SoapElement implements SoapEnvelope {
private Saaj12Soap11Body body;
private Saaj12SoapHeader header;
public Saaj12SoapEnvelope(SOAPEnvelope saajEnvelope) {
super(saajEnvelope);
}
public QName getName() {
return SaajUtils.toQName(getSaajEnvelope().getElementName());
}
public Source getSource() {
return new DOMSource(getSaajEnvelope());
}
public SoapHeader getHeader() {
if (header != null) {
try {
header = getSaajEnvelope().getHeader() != null ? new Saaj12SoapHeader(getSaajEnvelope().getHeader()) :
null;
}
catch (SOAPException ex) {
throw new SaajSoapHeaderException(ex);
}
}
return header;
}
public SoapBody getBody() {
public final SoapBody getBody() {
if (body == null) {
try {
body = new Saaj12Soap11Body(getSaajEnvelope().getBody());
@@ -78,5 +54,25 @@ public class Saaj12SoapEnvelope extends SaajSoapEnvelope {
return body;
}
public final SoapHeader getHeader() {
if (header == null) {
try {
SOAPHeader saajHeader = getSaajEnvelope().getHeader();
if (saajHeader != null) {
header = new Saaj12SoapHeader(saajHeader);
}
else {
header = null;
}
}
catch (SOAPException ex) {
throw new SaajSoapHeaderException(ex);
}
}
return header;
}
protected SOAPEnvelope getSaajEnvelope() {
return (SOAPEnvelope) getSaajElement();
}
}

View File

@@ -24,9 +24,7 @@ import javax.xml.soap.Name;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
import org.springframework.util.Assert;
import org.springframework.ws.soap.SoapFaultDetail;
@@ -39,31 +37,16 @@ import org.springframework.ws.soap.saaj.support.SaajUtils;
*
* @author Arjen Poutsma
*/
class Saaj12SoapFaultDetail implements SoapFaultDetail {
private Detail saajDetail;
class Saaj12SoapFaultDetail extends Saaj12SoapElement implements SoapFaultDetail {
Saaj12SoapFaultDetail(Detail saajDetail) {
Assert.notNull(saajDetail, "No saajDetail given");
this.saajDetail = saajDetail;
}
public QName getName() {
return SaajUtils.toQName(saajDetail.getElementName());
}
public Source getSource() {
return new DOMSource(saajDetail);
}
public Result getResult() {
return new DOMResult(saajDetail);
super(saajDetail);
}
public SoapFaultDetailElement addFaultDetailElement(QName name) {
try {
Name detailEntryName = SaajUtils.toName(name, saajDetail, getEnvelope());
DetailEntry saajDetailEntry = saajDetail.addDetailEntry(detailEntryName);
Name detailEntryName = SaajUtils.toName(name, getSaajDetail(), getEnvelope());
DetailEntry saajDetailEntry = getSaajDetail().addDetailEntry(detailEntryName);
return new Saaj12SoapFaultDetailElement(saajDetailEntry);
}
catch (SOAPException ex) {
@@ -72,11 +55,19 @@ class Saaj12SoapFaultDetail implements SoapFaultDetail {
}
public Iterator getDetailEntries() {
return new Saaj12SoapFaultDetailIterator(saajDetail.getDetailEntries());
return new Saaj12SoapFaultDetailIterator(getSaajDetail().getDetailEntries());
}
public Result getResult() {
return new DOMResult(getSaajDetail());
}
private SOAPEnvelope getEnvelope() {
return (SOAPEnvelope) saajDetail.getParentElement().getParentElement().getParentElement();
return (SOAPEnvelope) getSaajDetail().getParentElement().getParentElement().getParentElement();
}
private Detail getSaajDetail() {
return (Detail) getSaajElement();
}
private static class Saaj12SoapFaultDetailIterator implements Iterator {
@@ -100,8 +91,5 @@ class Saaj12SoapFaultDetail implements SoapFaultDetail {
public void remove() {
saajIterator.remove();
}
}
}

View File

@@ -16,51 +16,40 @@
package org.springframework.ws.soap.saaj.saaj12;
import javax.xml.namespace.QName;
import javax.xml.soap.DetailEntry;
import javax.xml.soap.SOAPException;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
import org.springframework.util.Assert;
import org.springframework.ws.soap.SoapFaultDetailElement;
import org.springframework.ws.soap.saaj.SaajSoapFaultException;
import org.springframework.ws.soap.saaj.support.SaajUtils;
/**
* Internal class that uses SAAJ 1.2 to implement the <code>SoapFaultDetailElement</code> interface.
*
* @author Arjen Poutsma
*/
class Saaj12SoapFaultDetailElement implements SoapFaultDetailElement {
private DetailEntry saajDetailEntry;
class Saaj12SoapFaultDetailElement extends Saaj12SoapElement implements SoapFaultDetailElement {
Saaj12SoapFaultDetailElement(DetailEntry saajDetailEntry) {
Assert.notNull(saajDetailEntry, "No saajDetailEntry given");
this.saajDetailEntry = saajDetailEntry;
super(saajDetailEntry);
}
public Result getResult() {
return new DOMResult(saajDetailEntry);
return new DOMResult(getSaajDetailEntry());
}
private DetailEntry getSaajDetailEntry() {
return (DetailEntry) getSaajElement();
}
public void addText(String text) {
try {
saajDetailEntry.addTextNode(text);
getSaajDetailEntry().addTextNode(text);
}
catch (SOAPException ex) {
throw new SaajSoapFaultException(ex);
}
}
public QName getName() {
return SaajUtils.toQName(saajDetailEntry.getElementName());
}
public Source getSource() {
return new DOMSource(saajDetailEntry);
}
}

View File

@@ -23,10 +23,7 @@ import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPHeaderElement;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import org.springframework.util.Assert;
import org.springframework.ws.soap.SoapHeader;
import org.springframework.ws.soap.SoapHeaderElement;
import org.springframework.ws.soap.saaj.SaajSoapHeaderException;
@@ -37,27 +34,16 @@ import org.springframework.ws.soap.saaj.support.SaajUtils;
*
* @author Arjen Poutsma
*/
class Saaj12SoapHeader implements SoapHeader {
private final SOAPHeader saajHeader;
class Saaj12SoapHeader extends Saaj12SoapElement implements SoapHeader {
Saaj12SoapHeader(SOAPHeader saajHeader) {
Assert.notNull(saajHeader, "No saajHeader given");
this.saajHeader = saajHeader;
}
public QName getName() {
return SaajUtils.toQName(saajHeader.getElementName());
}
public Source getSource() {
return new DOMSource(saajHeader);
super(saajHeader);
}
public SoapHeaderElement addHeaderElement(QName name) {
try {
Name saajName = SaajUtils.toName(name, saajHeader, getEnvelope());
SOAPHeaderElement saajHeaderElement = saajHeader.addHeaderElement(saajName);
Name saajName = SaajUtils.toName(name, getSaajHeader(), getEnvelope());
SOAPHeaderElement saajHeaderElement = getSaajHeader().addHeaderElement(saajName);
return new Saaj12SoapHeaderElement(saajHeaderElement);
}
catch (SOAPException ex) {
@@ -65,23 +51,27 @@ class Saaj12SoapHeader implements SoapHeader {
}
}
public Iterator examineMustUnderstandHeaderElements(String role) {
return new SaajSoapHeaderElementIterator(saajHeader.examineMustUnderstandHeaderElements(role));
public Iterator examineAllHeaderElements() {
return new Saaj12SoapHeaderElementIterator(getSaajHeader().examineAllHeaderElements());
}
public Iterator examineAllHeaderElements() {
return new SaajSoapHeaderElementIterator(saajHeader.examineAllHeaderElements());
public Iterator examineMustUnderstandHeaderElements(String role) {
return new Saaj12SoapHeaderElementIterator(getSaajHeader().examineMustUnderstandHeaderElements(role));
}
private SOAPEnvelope getEnvelope() {
return (SOAPEnvelope) saajHeader.getParentElement();
return (SOAPEnvelope) getSaajHeader().getParentElement();
}
private static class SaajSoapHeaderElementIterator implements Iterator {
private SOAPHeader getSaajHeader() {
return (SOAPHeader) getSaajElement();
}
private static class Saaj12SoapHeaderElementIterator implements Iterator {
private final Iterator saajIterator;
private SaajSoapHeaderElementIterator(Iterator saajIterator) {
private Saaj12SoapHeaderElementIterator(Iterator saajIterator) {
this.saajIterator = saajIterator;
}

View File

@@ -22,11 +22,8 @@ import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPHeaderElement;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
import org.springframework.util.Assert;
import org.springframework.ws.soap.SoapHeaderElement;
import org.springframework.ws.soap.SoapHeaderException;
import org.springframework.ws.soap.saaj.SaajSoapHeaderException;
@@ -37,47 +34,36 @@ import org.springframework.ws.soap.saaj.support.SaajUtils;
*
* @author Arjen Poutsma
*/
class Saaj12SoapHeaderElement implements SoapHeaderElement {
private final SOAPHeaderElement saajHeaderElement;
class Saaj12SoapHeaderElement extends Saaj12SoapElement implements SoapHeaderElement {
Saaj12SoapHeaderElement(SOAPHeaderElement saajHeaderElement) {
Assert.notNull(saajHeaderElement, "No saajHeaderElement given");
this.saajHeaderElement = saajHeaderElement;
}
public QName getName() {
return SaajUtils.toQName(saajHeaderElement.getElementName());
}
public Source getSource() {
return new DOMSource(saajHeaderElement);
super(saajHeaderElement);
}
public String getActorOrRole() {
return saajHeaderElement.getActor();
}
public void setActorOrRole(String role) {
saajHeaderElement.setActor(role);
return getSaajHeaderElement().getActor();
}
public boolean getMustUnderstand() {
return saajHeaderElement.getMustUnderstand();
}
public void setMustUnderstand(boolean mustUnderstand) {
saajHeaderElement.setMustUnderstand(mustUnderstand);
return getSaajHeaderElement().getMustUnderstand();
}
public Result getResult() {
return new DOMResult(saajHeaderElement);
return new DOMResult(getSaajHeaderElement());
}
public void setActorOrRole(String role) {
getSaajHeaderElement().setActor(role);
}
public void setMustUnderstand(boolean mustUnderstand) {
getSaajHeaderElement().setMustUnderstand(mustUnderstand);
}
public void addAttribute(QName name, String value) throws SoapHeaderException {
try {
Name saajName = SaajUtils.toName(name, saajHeaderElement, getEnvelope());
saajHeaderElement.addAttribute(saajName, value);
Name saajName = SaajUtils.toName(name, getSaajHeaderElement(), getEnvelope());
getSaajHeaderElement().addAttribute(saajName, value);
}
catch (SOAPException ex) {
throw new SaajSoapHeaderException(ex);
@@ -85,7 +71,10 @@ class Saaj12SoapHeaderElement implements SoapHeaderElement {
}
private SOAPEnvelope getEnvelope() {
return (SOAPEnvelope) saajHeaderElement.getParentElement().getParentElement();
return (SOAPEnvelope) getSaajHeaderElement().getParentElement().getParentElement();
}
private SOAPHeaderElement getSaajHeaderElement() {
return (SOAPHeaderElement) getSaajElement();
}
}

View File

@@ -0,0 +1,43 @@
/*
* Copyright 2006 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ws.soap.saaj.saaj12;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPMessage;
import org.springframework.ws.soap.SoapEnvelope;
import org.springframework.ws.soap.saaj.SaajSoapMessage;
/**
* SAAJ 1.2 specific implementation of the <code>SoapMessage</code> interface. Accessed via the
* <code>SaajSoapMessageContext</code>.
*
* @author Arjen Poutsma
* @see javax.xml.soap.SOAPMessage
* @see org.springframework.ws.soap.saaj.SaajSoapMessageContext
*/
class Saaj12SoapMessage extends SaajSoapMessage {
public Saaj12SoapMessage(SOAPMessage soapMessage) {
super(soapMessage);
}
protected SoapEnvelope createSaajSoapEnvelope(SOAPEnvelope saajEnvelope) {
return new Saaj12SoapEnvelope(saajEnvelope);
}
}

View File

@@ -0,0 +1,59 @@
/*
* Copyright 2006 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ws.soap.saaj.saaj12;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPMessage;
import org.springframework.ws.soap.saaj.SaajSoapMessage;
import org.springframework.ws.soap.saaj.SaajSoapMessageContext;
import org.springframework.ws.transport.TransportRequest;
/**
* SAAJ 1.2 specific implementation of the <code>SoapMessageContext</code> interface. Created by the
* <code>SaajSoapMessageContextFactory</code>.
*
* @author Arjen Poutsma
* @see org.springframework.ws.soap.saaj.SaajSoapMessageContextFactory
*/
public class Saaj12SoapMessageContext extends SaajSoapMessageContext {
/**
* Creates a new instance based on the given SAAJ request message, and a message factory.
*
* @param request the request message
* @param transportRequest the transport request
* @param messageFactory the message factory used for creating a response
*/
public Saaj12SoapMessageContext(SOAPMessage request,
TransportRequest transportRequest,
MessageFactory messageFactory) {
super(new Saaj12SoapMessage(request), transportRequest, messageFactory);
}
protected SaajSoapMessage createSaajSoapMessage(SOAPMessage saajMessage) {
return new Saaj12SoapMessage(saajMessage);
}
public void setSaajRequest(SOAPMessage request) {
setRequest(new Saaj12SoapMessage(request));
}
public void setSaajResponse(SOAPMessage response) {
setResponse(new Saaj12SoapMessage(response));
}
}

View File

@@ -49,13 +49,13 @@ class Saaj13Soap11Body extends Saaj13SoapBody implements Soap11Body {
throw new IllegalArgumentException("fault code has no namespace");
}
try {
saajBody.removeContents();
getSaajBody().removeContents();
SOAPFault saajFault;
if (faultStringLocale == null) {
saajFault = saajBody.addFault(faultCode, faultString);
saajFault = getSaajBody().addFault(faultCode, faultString);
}
else {
saajFault = saajBody.addFault(faultCode, faultString, faultStringLocale);
saajFault = getSaajBody().addFault(faultCode, faultString, faultStringLocale);
}
return new Saaj13Soap11Fault(saajFault);
}
@@ -83,11 +83,11 @@ class Saaj13Soap11Body extends Saaj13SoapBody implements Soap11Body {
private Soap11Fault addStandardFault(String localName, String faultString, Locale faultStringLocale) {
try {
QName faultCode = QNameUtils.createQName(saajBody.getElementQName().getNamespaceURI(), localName,
QNameUtils.getPrefix(saajBody.getElementQName()));
saajBody.removeContents();
SOAPFault saajFault = faultStringLocale == null ? saajBody.addFault(faultCode, faultString) :
saajBody.addFault(faultCode, faultString, faultStringLocale);
QName faultCode = QNameUtils.createQName(getSaajBody().getElementQName().getNamespaceURI(), localName,
QNameUtils.getPrefix(getSaajBody().getElementQName()));
getSaajBody().removeContents();
SOAPFault saajFault = faultStringLocale == null ? getSaajBody().addFault(faultCode, faultString) :
getSaajBody().addFault(faultCode, faultString, faultStringLocale);
return new Saaj13Soap11Fault(saajFault);
}
catch (SOAPException ex) {
@@ -96,7 +96,7 @@ class Saaj13Soap11Body extends Saaj13SoapBody implements Soap11Body {
}
public SoapFault getFault() {
return new Saaj13Soap11Fault(saajBody.getFault());
return new Saaj13Soap11Fault(getSaajBody().getFault());
}
}

View File

@@ -21,10 +21,7 @@ import javax.xml.namespace.QName;
import javax.xml.soap.Detail;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFault;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import org.springframework.util.Assert;
import org.springframework.ws.soap.SoapFaultDetail;
import org.springframework.ws.soap.saaj.SaajSoapFaultException;
import org.springframework.ws.soap.soap11.Soap11Fault;
@@ -34,34 +31,23 @@ import org.springframework.ws.soap.soap11.Soap11Fault;
*
* @author Arjen Poutsma
*/
class Saaj13Soap11Fault implements Soap11Fault {
private final SOAPFault saajFault;
class Saaj13Soap11Fault extends Saaj13SoapElement implements Soap11Fault {
Saaj13Soap11Fault(SOAPFault saajFault) {
Assert.notNull(saajFault, "No saajFault given");
this.saajFault = saajFault;
}
public Locale getFaultStringLocale() {
return saajFault.getFaultStringLocale();
super(saajFault);
}
public String getFaultString() {
return saajFault.getFaultString();
return getSaajFault().getFaultString();
}
public Source getSource() {
return new DOMSource(saajFault);
}
public QName getName() {
return saajFault.getElementQName();
public Locale getFaultStringLocale() {
return getSaajFault().getFaultStringLocale();
}
public SoapFaultDetail addFaultDetail() {
try {
Detail saajDetail = saajFault.addDetail();
Detail saajDetail = getSaajFault().addDetail();
return saajDetail != null ? new Saaj13SoapFaultDetail(saajDetail) : null;
}
catch (SOAPException ex) {
@@ -69,25 +55,29 @@ class Saaj13Soap11Fault implements Soap11Fault {
}
}
public SoapFaultDetail getFaultDetail() {
Detail saajDetail = saajFault.getDetail();
return saajDetail != null ? new Saaj13SoapFaultDetail(saajDetail) : null;
public String getFaultActorOrRole() {
return getSaajFault().getFaultActor();
}
public String getFaultActorOrRole() {
return saajFault.getFaultActor();
public QName getFaultCode() {
return getSaajFault().getFaultCodeAsQName();
}
public SoapFaultDetail getFaultDetail() {
Detail saajDetail = getSaajFault().getDetail();
return saajDetail != null ? new Saaj13SoapFaultDetail(saajDetail) : null;
}
public void setFaultActorOrRole(String faultActor) {
try {
saajFault.setFaultActor(faultActor);
getSaajFault().setFaultActor(faultActor);
}
catch (SOAPException ex) {
throw new SaajSoapFaultException(ex);
}
}
public QName getFaultCode() {
return saajFault.getFaultCodeAsQName();
private SOAPFault getSaajFault() {
return (SOAPFault) getSaajElement();
}
}

View File

@@ -51,8 +51,8 @@ class Saaj13Soap12Body extends Saaj13SoapBody implements Soap12Body {
"A code with namespace and local part must be specific for a custom fault code");
}
try {
saajBody.removeContents();
SOAPFault saajFault = saajBody.addFault(code, reason, locale);
getSaajBody().removeContents();
SOAPFault saajFault = getSaajBody().addFault(code, reason, locale);
return new Saaj13Soap12Fault(saajFault);
}
catch (SOAPException ex) {
@@ -81,6 +81,6 @@ class Saaj13Soap12Body extends Saaj13SoapBody implements Soap12Body {
}
public SoapFault getFault() {
return new Saaj13Soap12Fault(saajBody.getFault());
return new Saaj13Soap12Fault(getSaajBody().getFault());
}
}

View File

@@ -38,7 +38,7 @@ class Saaj13Soap12Header extends Saaj13SoapHeader implements Soap12Header {
public SoapHeaderElement addNotUnderstoodHeaderElement(QName headerName) {
try {
SOAPHeaderElement saajHeaderElement = saajHeader.addNotUnderstoodHeaderElement(headerName);
SOAPHeaderElement saajHeaderElement = getSaajHeader().addNotUnderstoodHeaderElement(headerName);
return new Saaj13SoapHeaderElement(saajHeaderElement);
}
catch (SOAPException ex) {
@@ -48,7 +48,7 @@ class Saaj13Soap12Header extends Saaj13SoapHeader implements Soap12Header {
public SoapHeaderElement addUpgradeHeaderElement(String[] supportedSoapUris) {
try {
SOAPHeaderElement saajHeaderElement = saajHeader.addUpgradeHeaderElement(supportedSoapUris);
SOAPHeaderElement saajHeaderElement = getSaajHeader().addUpgradeHeaderElement(supportedSoapUris);
return new Saaj13SoapHeaderElement(saajHeaderElement);
}
catch (SOAPException ex) {

View File

@@ -17,7 +17,6 @@
package org.springframework.ws.soap.saaj.saaj13;
import java.util.Iterator;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPBodyElement;
import javax.xml.transform.Result;
@@ -25,7 +24,6 @@ import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
import org.springframework.util.Assert;
import org.springframework.ws.soap.SoapBody;
/**
@@ -34,13 +32,15 @@ import org.springframework.ws.soap.SoapBody;
*
* @author Arjen Poutsma
*/
abstract class Saaj13SoapBody implements SoapBody {
abstract class Saaj13SoapBody extends Saaj13SoapElement implements SoapBody {
protected final SOAPBody saajBody;
protected Saaj13SoapBody(SOAPBody saajBody) {
super(saajBody);
}
Saaj13SoapBody(SOAPBody saajBody) {
Assert.notNull(saajBody, "No saajBody given");
this.saajBody = saajBody;
public final Result getPayloadResult() {
getSaajBody().removeContents();
return new DOMResult(getSaajBody());
}
public final Source getPayloadSource() {
@@ -48,21 +48,8 @@ abstract class Saaj13SoapBody implements SoapBody {
return payloadElement != null ? new DOMSource(payloadElement) : null;
}
public final Result getPayloadResult() {
saajBody.removeContents();
return new DOMResult(saajBody);
}
public final boolean hasFault() {
return saajBody.hasFault();
}
public final QName getName() {
return saajBody.getElementQName();
}
public final Source getSource() {
return new DOMSource(saajBody);
return getSaajBody().hasFault();
}
/**
@@ -72,7 +59,7 @@ abstract class Saaj13SoapBody implements SoapBody {
* @return the message payload, or <code>null</code> if none is set.
*/
private SOAPBodyElement getPayloadElement() {
for (Iterator iterator = saajBody.getChildElements(); iterator.hasNext();) {
for (Iterator iterator = getSaajBody().getChildElements(); iterator.hasNext();) {
Object child = iterator.next();
if (child instanceof SOAPBodyElement) {
return (SOAPBodyElement) child;
@@ -81,4 +68,7 @@ abstract class Saaj13SoapBody implements SoapBody {
return null;
}
protected final SOAPBody getSaajBody() {
return (SOAPBody) getSaajElement();
}
}

View File

@@ -14,35 +14,33 @@
* limitations under the License.
*/
package org.springframework.ws.soap.saaj;
package org.springframework.ws.soap.saaj.saaj13;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPElement;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import org.springframework.util.Assert;
import org.springframework.ws.soap.SoapEnvelope;
/**
* Abstract base class for implementations of the <code>SoapEnvelope</code> interface that use SAAJ. Used by
* <code>SaajSoapMessage</code>.
*
* @author Arjen Poutsma
*/
public abstract class SaajSoapEnvelope implements SoapEnvelope {
abstract class Saaj13SoapElement {
private final SOAPEnvelope saajEnvelope;
private final SOAPElement saajElement;
protected SaajSoapEnvelope(SOAPEnvelope saajEnvelope) {
Assert.notNull(saajEnvelope, "No saajEnvelope given");
this.saajEnvelope = saajEnvelope;
protected Saaj13SoapElement(SOAPElement saajElement) {
Assert.notNull(saajElement, "No saajElement given");
this.saajElement = saajElement;
}
protected SOAPEnvelope getSaajEnvelope() {
return saajEnvelope;
protected SOAPElement getSaajElement() {
return saajElement;
}
public Source getSource() {
return new DOMSource(saajEnvelope);
public final QName getName() {
return saajElement.getElementQName();
}
public final Source getSource() {
return new DOMSource(saajElement);
}
}

View File

@@ -16,19 +16,16 @@
package org.springframework.ws.soap.saaj.saaj13;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPHeader;
import org.springframework.util.Assert;
import org.springframework.ws.soap.SoapBody;
import org.springframework.ws.soap.SoapEnvelope;
import org.springframework.ws.soap.SoapHeader;
import org.springframework.ws.soap.saaj.SaajSoapBodyException;
import org.springframework.ws.soap.saaj.SaajSoapEnvelope;
import org.springframework.ws.soap.saaj.SaajSoapEnvelopeException;
import org.springframework.ws.soap.saaj.SaajSoapHeaderException;
/**
@@ -37,39 +34,50 @@ import org.springframework.ws.soap.saaj.SaajSoapHeaderException;
*
* @author Arjen Poutsma
*/
public class Saaj13SoapEnvelope extends SaajSoapEnvelope {
private Saaj13SoapHeader header;
class Saaj13SoapEnvelope extends Saaj13SoapElement implements SoapEnvelope {
private Saaj13SoapBody body;
private Saaj13SoapHeader header;
public Saaj13SoapEnvelope(SOAPEnvelope saajEnvelope) {
super(saajEnvelope);
Assert.notNull(saajEnvelope, "No saajEnvelope given");
}
public QName getName() {
return getSaajEnvelope().getElementQName();
}
public SoapHeader getHeader() {
if (header == null) {
public final SoapBody getBody() {
if (body == null) {
try {
if (getSaajEnvelope().getHeader() == null) {
return null;
SOAPBody saajBody = getSaajEnvelope().getBody();
Saaj13SoapBody result;
if (isSoap11()) {
result = new Saaj13Soap11Body(saajBody);
}
else {
SOAPHeader saajHeader = getSaajEnvelope().getHeader();
String namespaceURI = getSaajEnvelope().getElementQName().getNamespaceURI();
if (SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE.equals(namespaceURI)) {
result = new Saaj13Soap12Body(saajBody);
}
body = result;
}
catch (SOAPException ex) {
throw new SaajSoapBodyException(ex);
}
}
return body;
}
public final SoapHeader getHeader() {
if (header == null) {
try {
SOAPHeader saajHeader = getSaajEnvelope().getHeader();
if (saajHeader != null) {
if (isSoap11()) {
header = new Saaj13SoapHeader(saajHeader);
}
else if (SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE.equals(namespaceURI)) {
else {
header = new Saaj13Soap12Header(saajHeader);
}
else {
throw new SaajSoapEnvelopeException("Unknown SOAP namespace \"" + namespaceURI + "\"");
}
}
else {
header = null;
}
}
catch (SOAPException ex) {
@@ -79,27 +87,24 @@ public class Saaj13SoapEnvelope extends SaajSoapEnvelope {
return header;
}
public SoapBody getBody() {
if (body == null) {
try {
SOAPBody saajBody = getSaajEnvelope().getBody();
String namespaceURI = getSaajEnvelope().getElementQName().getNamespaceURI();
if (SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE.equals(namespaceURI)) {
body = new Saaj13Soap11Body(saajBody);
}
else if (SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE.equals(namespaceURI)) {
body = new Saaj13Soap12Body(saajBody);
}
else {
throw new SaajSoapEnvelopeException("Unknown SOAP namespace \"" + namespaceURI + "\"");
}
}
catch (SOAPException ex) {
throw new SaajSoapBodyException(ex);
}
}
return body;
protected SOAPEnvelope getSaajEnvelope() {
return (SOAPEnvelope) getSaajElement();
}
/**
* Returns <code>true</code> if this is a SOAP 1.1 message, <code>false</code> if SOAP 1.2. Throws an exception
* otherwise.
*/
private boolean isSoap11() {
String namespaceURI = getSaajEnvelope().getElementQName().getNamespaceURI();
if (SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE.equals(namespaceURI)) {
return true;
}
else if (SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE.equals(namespaceURI)) {
return false;
}
else {
throw new IllegalStateException("Unknown SOAP namespace \"" + namespaceURI + "\"");
}
}
}

View File

@@ -21,10 +21,7 @@ import javax.xml.namespace.QName;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPHeaderElement;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import org.springframework.util.Assert;
import org.springframework.ws.soap.SoapHeader;
import org.springframework.ws.soap.SoapHeaderElement;
import org.springframework.ws.soap.saaj.SaajSoapHeaderException;
@@ -34,26 +31,19 @@ import org.springframework.ws.soap.saaj.SaajSoapHeaderException;
*
* @author Arjen Poutsma
*/
class Saaj13SoapHeader implements SoapHeader {
protected final SOAPHeader saajHeader;
class Saaj13SoapHeader extends Saaj13SoapElement implements SoapHeader {
Saaj13SoapHeader(SOAPHeader saajHeader) {
Assert.notNull(saajHeader, "No saajHeader given");
this.saajHeader = saajHeader;
super(saajHeader);
}
public QName getName() {
return saajHeader.getElementQName();
}
public Source getSource() {
return new DOMSource(saajHeader);
protected final SOAPHeader getSaajHeader() {
return (SOAPHeader) getSaajElement();
}
public SoapHeaderElement addHeaderElement(QName name) {
try {
SOAPHeaderElement saajHeaderElement = saajHeader.addHeaderElement(name);
SOAPHeaderElement saajHeaderElement = getSaajHeader().addHeaderElement(name);
return new Saaj13SoapHeaderElement(saajHeaderElement);
}
catch (SOAPException ex) {
@@ -62,11 +52,11 @@ class Saaj13SoapHeader implements SoapHeader {
}
public Iterator examineMustUnderstandHeaderElements(String role) {
return new SaajSoapHeaderElementIterator(saajHeader.examineMustUnderstandHeaderElements(role));
return new SaajSoapHeaderElementIterator(getSaajHeader().examineMustUnderstandHeaderElements(role));
}
public Iterator examineAllHeaderElements() {
return new SaajSoapHeaderElementIterator(saajHeader.examineAllHeaderElements());
return new SaajSoapHeaderElementIterator(getSaajHeader().examineAllHeaderElements());
}
private static class SaajSoapHeaderElementIterator implements Iterator {

View File

@@ -0,0 +1,39 @@
/*
* Copyright 2006 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ws.soap.saaj.saaj13;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPMessage;
import org.springframework.ws.soap.SoapEnvelope;
import org.springframework.ws.soap.saaj.SaajSoapMessage;
class Saaj13SoapMessage extends SaajSoapMessage {
/**
* Create a new <code>SaajSoapMessage</code> based on the given SAAJ <code>SOAPMessage</code>.
*
* @param soapMessage the SAAJ SOAPMessage
*/
protected Saaj13SoapMessage(SOAPMessage soapMessage) {
super(soapMessage);
}
protected SoapEnvelope createSaajSoapEnvelope(SOAPEnvelope saajEnvelope) {
return new Saaj13SoapEnvelope(saajEnvelope);
}
}

View File

@@ -0,0 +1,59 @@
/*
* Copyright 2006 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ws.soap.saaj.saaj13;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPMessage;
import org.springframework.ws.soap.saaj.SaajSoapMessage;
import org.springframework.ws.soap.saaj.SaajSoapMessageContext;
import org.springframework.ws.transport.TransportRequest;
/**
* SAAJ 1.3 specific implementation of the <code>SoapMessageContext</code> interface. Created by the
* <code>SaajSoapMessageContextFactory</code>.
*
* @author Arjen Poutsma
* @see org.springframework.ws.soap.saaj.SaajSoapMessageContextFactory
*/
public class Saaj13SoapMessageContext extends SaajSoapMessageContext {
/**
* Creates a new instance based on the given SAAJ request message, and a message factory.
*
* @param request the request message
* @param transportRequest the transport request
* @param messageFactory the message factory used for creating a response
*/
public Saaj13SoapMessageContext(SOAPMessage request,
TransportRequest transportRequest,
MessageFactory messageFactory) {
super(new Saaj13SoapMessage(request), transportRequest, messageFactory);
}
protected SaajSoapMessage createSaajSoapMessage(SOAPMessage saajMessage) {
return new Saaj13SoapMessage(saajMessage);
}
public void setSaajRequest(SOAPMessage request) {
setRequest(new Saaj13SoapMessage(request));
}
public void setSaajResponse(SOAPMessage response) {
setResponse(new Saaj13SoapMessage(response));
}
}

View File

@@ -59,7 +59,7 @@ public abstract class SaajUtils {
saajVersion = SAAJ_13;
}
catch (ClassNotFoundException ex) {
if (Element.class.isAssignableFrom(SOAPElement.class)) {
if (Element.class.isAssignableFrom(SOAPElement.class) && !isWebLogic9Implementation()) {
saajVersion = SAAJ_12;
}
else {
@@ -68,6 +68,27 @@ public abstract class SaajUtils {
}
}
/**
* Checks whether we are dealing with a WebLogic 9 implementation of SAAJ. WebLogic 9 does implement SAAJ 1.2, but
* throws UnsupportedOperationExceptions when a SAAJ 1.2 method is called.
*/
private static boolean isWebLogic9Implementation() {
try {
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage message = messageFactory.createMessage();
try {
message.getSOAPBody();
}
catch (UnsupportedOperationException ex) {
return true;
}
return false;
}
catch (SOAPException e) {
return false;
}
}
/**
* Gets the SAAJ version.
*

View File

@@ -36,6 +36,7 @@ import org.springframework.ws.mock.MockWebServiceMessage;
import org.springframework.ws.soap.SoapMessage;
import org.springframework.ws.soap.SoapVersion;
import org.springframework.ws.soap.saaj.SaajSoapMessageContext;
import org.springframework.ws.soap.saaj.saaj13.Saaj13SoapMessageContext;
import org.springframework.ws.soap.saaj.support.SaajUtils;
import org.springframework.ws.soap.soap11.Soap11Fault;
import org.springframework.ws.soap.soap12.Soap12Fault;
@@ -65,7 +66,7 @@ public class PayloadValidatingInterceptorTest extends TestCase {
InputStream inputStream = getClass().getResourceAsStream("invalidMessage.xml");
transformer.transform(new StreamSource(inputStream), new DOMResult(invalidMessage.getSOAPBody()));
SaajSoapMessageContext context =
new SaajSoapMessageContext(invalidMessage, new MockTransportRequest(), messageFactory);
new Saaj13SoapMessageContext(invalidMessage, new MockTransportRequest(), messageFactory);
boolean result = interceptor.handleRequest(context, null);
assertFalse("Invalid response from interceptor", result);
@@ -73,11 +74,9 @@ public class PayloadValidatingInterceptorTest extends TestCase {
SoapMessage response = context.getSoapResponse();
assertTrue("Resonse has no fault", response.getSoapBody().hasFault());
Soap11Fault fault = (Soap11Fault) response.getSoapBody().getFault();
assertEquals("Invalid fault code on fault",
SoapVersion.SOAP_11.getClientOrSenderFaultName(),
assertEquals("Invalid fault code on fault", SoapVersion.SOAP_11.getClientOrSenderFaultName(),
fault.getFaultCode());
assertEquals("Invalid fault string on fault",
PayloadValidatingInterceptor.DEFAULT_FAULTSTRING_OR_REASON,
assertEquals("Invalid fault string on fault", PayloadValidatingInterceptor.DEFAULT_FAULTSTRING_OR_REASON,
fault.getFaultString());
assertNotNull("No Detail on fault", fault.getFaultDetail());
}
@@ -89,7 +88,7 @@ public class PayloadValidatingInterceptorTest extends TestCase {
InputStream inputStream = getClass().getResourceAsStream("invalidMessage.xml");
transformer.transform(new StreamSource(inputStream), new DOMResult(invalidMessage.getSOAPBody()));
SaajSoapMessageContext context =
new SaajSoapMessageContext(invalidMessage, new MockTransportRequest(), messageFactory);
new Saaj13SoapMessageContext(invalidMessage, new MockTransportRequest(), messageFactory);
boolean result = interceptor.handleRequest(context, null);
assertFalse("Invalid response from interceptor", result);
@@ -97,11 +96,9 @@ public class PayloadValidatingInterceptorTest extends TestCase {
SoapMessage response = context.getSoapResponse();
assertTrue("Resonse has no fault", response.getSoapBody().hasFault());
Soap12Fault fault = (Soap12Fault) response.getSoapBody().getFault();
assertEquals("Invalid fault code on fault",
SoapVersion.SOAP_12.getClientOrSenderFaultName(),
assertEquals("Invalid fault code on fault", SoapVersion.SOAP_12.getClientOrSenderFaultName(),
fault.getFaultCode());
assertEquals("Invalid fault string on fault",
PayloadValidatingInterceptor.DEFAULT_FAULTSTRING_OR_REASON,
assertEquals("Invalid fault string on fault", PayloadValidatingInterceptor.DEFAULT_FAULTSTRING_OR_REASON,
fault.getFaultReasonText(Locale.ENGLISH));
assertNotNull("No Detail on fault", fault.getFaultDetail());
}
@@ -119,7 +116,7 @@ public class PayloadValidatingInterceptorTest extends TestCase {
InputStream inputStream = getClass().getResourceAsStream("invalidMessage.xml");
transformer.transform(new StreamSource(inputStream), new DOMResult(invalidMessage.getSOAPBody()));
SaajSoapMessageContext context =
new SaajSoapMessageContext(invalidMessage, new MockTransportRequest(), messageFactory);
new Saaj13SoapMessageContext(invalidMessage, new MockTransportRequest(), messageFactory);
boolean result = interceptor.handleRequest(context, null);
assertFalse("Invalid response from interceptor", result);
@@ -127,8 +124,7 @@ public class PayloadValidatingInterceptorTest extends TestCase {
SoapMessage response = context.getSoapResponse();
assertTrue("Resonse has no fault", response.getSoapBody().hasFault());
Soap11Fault fault = (Soap11Fault) response.getSoapBody().getFault();
assertEquals("Invalid fault code on fault",
SoapVersion.SOAP_11.getClientOrSenderFaultName(),
assertEquals("Invalid fault code on fault", SoapVersion.SOAP_11.getClientOrSenderFaultName(),
fault.getFaultCode());
assertEquals("Invalid fault string on fault", faultString, fault.getFaultString());
assertEquals("Invalid fault string locale on fault", locale, fault.getFaultStringLocale());
@@ -174,7 +170,7 @@ public class PayloadValidatingInterceptorTest extends TestCase {
SOAPMessage saajMessage =
SaajUtils.loadMessage(new ClassPathResource("validSoapMessage.xml", getClass()), messageFactory);
SaajSoapMessageContext soapContext =
new SaajSoapMessageContext(saajMessage, new MockTransportRequest(), messageFactory);
new Saaj13SoapMessageContext(saajMessage, new MockTransportRequest(), messageFactory);
boolean result = interceptor.handleRequest(soapContext, null);
assertTrue("Invalid response from interceptor", result);
assertFalse("Response set", soapContext.hasResponse());

View File

@@ -0,0 +1,64 @@
/*
* Copyright 2006 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ws.soap;
import java.io.IOException;
import java.io.InputStream;
import javax.xml.soap.SOAPException;
import junit.framework.TestCase;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.util.FileCopyUtils;
public abstract class AbstractAttachmentTestCase extends TestCase {
private Attachment attachment;
private static byte[] CONTENTS;
private static final String CONTENT_TYPE = "text/plain";
protected final void setUp() throws Exception {
CONTENTS = "attachment contents".getBytes("UTF-8");
SoapMessage message = createMessage();
attachment = message.addAttachment(new ByteArrayResource(CONTENTS), CONTENT_TYPE);
}
protected abstract SoapMessage createMessage() throws Exception;
public void testGetSize() throws SOAPException {
assertTrue("Invalid size", attachment.getSize() > 0);
}
public void testContentId() {
String id = "123";
attachment.setId(id);
assertEquals("Invalid content id", id, attachment.getId());
}
public void testGetContentType() {
assertEquals("Invalid content type", CONTENT_TYPE, attachment.getContentType());
}
public void testGetInputStream() throws IOException {
InputStream inputStream = attachment.getInputStream();
assertNotNull("Invalid input stream returned", inputStream);
byte[] bytes = FileCopyUtils.copyToByteArray(inputStream);
assertEquals("Invalid size", CONTENTS.length, bytes.length);
}
}

View File

@@ -28,6 +28,7 @@ import junit.framework.TestCase;
import org.easymock.MockControl;
import org.springframework.ws.mock.MockTransportRequest;
import org.springframework.ws.soap.saaj.SaajSoapMessageContext;
import org.springframework.ws.soap.saaj.saaj13.Saaj13SoapMessageContext;
import org.springframework.ws.soap.soap11.Soap11Fault;
import org.springframework.ws.soap.soap12.Soap12Fault;
@@ -53,7 +54,7 @@ public class SoapMessageDispatcherTest extends TestCase {
header.setActor(SOAPConstants.URI_SOAP_ACTOR_NEXT);
header.setMustUnderstand(true);
SaajSoapMessageContext context =
new SaajSoapMessageContext(request, new MockTransportRequest(), messageFactory);
new Saaj13SoapMessageContext(request, new MockTransportRequest(), messageFactory);
interceptorMock.understands(null);
interceptorControl.setMatcher(MockControl.ALWAYS_MATCHER);
interceptorControl.setReturnValue(true);
@@ -75,7 +76,7 @@ public class SoapMessageDispatcherTest extends TestCase {
header.setMustUnderstand(true);
header.setRole(SOAPConstants.URI_SOAP_1_2_ROLE_NEXT);
SaajSoapMessageContext context =
new SaajSoapMessageContext(request, new MockTransportRequest(), messageFactory);
new Saaj13SoapMessageContext(request, new MockTransportRequest(), messageFactory);
interceptorMock.understands(null);
interceptorControl.setMatcher(MockControl.ALWAYS_MATCHER);
interceptorControl.setReturnValue(true);
@@ -97,7 +98,7 @@ public class SoapMessageDispatcherTest extends TestCase {
header.setActor(SOAPConstants.URI_SOAP_ACTOR_NEXT);
header.setMustUnderstand(true);
SaajSoapMessageContext context =
new SaajSoapMessageContext(request, new MockTransportRequest(), messageFactory);
new Saaj13SoapMessageContext(request, new MockTransportRequest(), messageFactory);
interceptorMock.understands(null);
interceptorControl.setMatcher(MockControl.ALWAYS_MATCHER);
interceptorControl.setReturnValue(false);
@@ -112,11 +113,9 @@ public class SoapMessageDispatcherTest extends TestCase {
SoapBody responseBody = context.getSoapResponse().getSoapBody();
assertTrue("Response body has no fault", responseBody.hasFault());
Soap11Fault fault = (Soap11Fault) responseBody.getFault();
assertEquals("Invalid fault code",
new QName(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE, "MustUnderstand"),
assertEquals("Invalid fault code", new QName(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE, "MustUnderstand"),
fault.getFaultCode());
assertEquals("Invalid fault string",
SoapMessageDispatcher.DEFAULT_MUST_UNDERSTAND_FAULT,
assertEquals("Invalid fault string", SoapMessageDispatcher.DEFAULT_MUST_UNDERSTAND_FAULT,
fault.getFaultString());
assertEquals("Invalid fault string locale", Locale.ENGLISH, fault.getFaultStringLocale());
assertEquals("Invalid fault actor", SOAPConstants.URI_SOAP_ACTOR_NEXT, fault.getFaultActorOrRole());
@@ -131,7 +130,7 @@ public class SoapMessageDispatcherTest extends TestCase {
header.setMustUnderstand(true);
header.setRole(SOAPConstants.URI_SOAP_1_2_ROLE_NEXT);
SaajSoapMessageContext context =
new SaajSoapMessageContext(request, new MockTransportRequest(), messageFactory);
new Saaj13SoapMessageContext(request, new MockTransportRequest(), messageFactory);
interceptorMock.understands(null);
interceptorControl.setMatcher(MockControl.ALWAYS_MATCHER);
interceptorControl.setReturnValue(false);
@@ -146,19 +145,16 @@ public class SoapMessageDispatcherTest extends TestCase {
SoapBody responseBody = context.getSoapResponse().getSoapBody();
assertTrue("Response body has no fault", responseBody.hasFault());
Soap12Fault fault = (Soap12Fault) responseBody.getFault();
assertEquals("Invalid fault code",
new QName(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, "MustUnderstand"),
assertEquals("Invalid fault code", new QName(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, "MustUnderstand"),
fault.getFaultCode());
assertEquals("Invalid fault string",
SoapMessageDispatcher.DEFAULT_MUST_UNDERSTAND_FAULT,
assertEquals("Invalid fault string", SoapMessageDispatcher.DEFAULT_MUST_UNDERSTAND_FAULT,
fault.getFaultReasonText(Locale.ENGLISH));
assertEquals("Invalid fault actor", SOAPConstants.URI_SOAP_1_2_ROLE_NEXT, fault.getFaultActorOrRole());
SoapHeader responseHeader = context.getSoapResponse().getSoapHeader();
Iterator iterator = responseHeader.examineAllHeaderElements();
assertTrue("Response header has no elements", iterator.hasNext());
SoapHeaderElement headerElement = (SoapHeaderElement) iterator.next();
assertEquals("No NotUnderstood header",
new QName(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, "NotUnderstood"),
assertEquals("No NotUnderstood header", new QName(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, "NotUnderstood"),
headerElement.getName());
interceptorControl.verify();
}
@@ -172,15 +168,14 @@ public class SoapMessageDispatcherTest extends TestCase {
header.setActor(headerActor);
header.setMustUnderstand(true);
SaajSoapMessageContext context =
new SaajSoapMessageContext(request, new MockTransportRequest(), messageFactory);
new Saaj13SoapMessageContext(request, new MockTransportRequest(), messageFactory);
interceptorMock.understands(null);
interceptorControl.setMatcher(MockControl.ALWAYS_MATCHER);
interceptorControl.setReturnValue(true);
interceptorControl.replay();
SoapEndpointInvocationChain chain = new SoapEndpointInvocationChain(new Object(),
new SoapEndpointInterceptor[]{interceptorMock},
new String[]{headerActor});
new SoapEndpointInterceptor[]{interceptorMock}, new String[]{headerActor});
boolean result = dispatcher.handleRequest(chain, context);
assertTrue("actor-specific header not understood", result);
@@ -196,15 +191,14 @@ public class SoapMessageDispatcherTest extends TestCase {
header.setRole(headerRole);
header.setMustUnderstand(true);
SaajSoapMessageContext context =
new SaajSoapMessageContext(request, new MockTransportRequest(), messageFactory);
new Saaj13SoapMessageContext(request, new MockTransportRequest(), messageFactory);
interceptorMock.understands(null);
interceptorControl.setMatcher(MockControl.ALWAYS_MATCHER);
interceptorControl.setReturnValue(true);
interceptorControl.replay();
SoapEndpointInvocationChain chain = new SoapEndpointInvocationChain(new Object(),
new SoapEndpointInterceptor[]{interceptorMock},
new String[]{headerRole});
new SoapEndpointInterceptor[]{interceptorMock}, new String[]{headerRole});
boolean result = dispatcher.handleRequest(chain, context);
assertTrue("role-specific header not understood", result);
@@ -216,12 +210,11 @@ public class SoapMessageDispatcherTest extends TestCase {
SOAPMessage request = messageFactory.createMessage();
request.getSOAPHeader().detachNode();
SaajSoapMessageContext context =
new SaajSoapMessageContext(request, new MockTransportRequest(), messageFactory);
new Saaj13SoapMessageContext(request, new MockTransportRequest(), messageFactory);
interceptorControl.replay();
SoapEndpointInvocationChain chain = new SoapEndpointInvocationChain(new Object(),
new SoapEndpointInterceptor[]{interceptorMock},
new String[]{"role"});
new SoapEndpointInterceptor[]{interceptorMock}, new String[]{"role"});
boolean result = dispatcher.handleRequest(chain, context);
assertTrue("Invalid result", result);

View File

@@ -35,8 +35,6 @@ public abstract class AbstractSoap11MessageContextTestCase extends AbstractSoapM
InputStreamSource inputStreamSource = new ByteArrayResource("contents".getBytes("UTF-8"));
messageContext.getSoapResponse().addAttachment(inputStreamSource, "text/plain");
messageContext.sendResponse(transportResponse);
assertTrue("Invalid Content-Type set",
transportResponse.getHeaders().getProperty("Content-Type").indexOf("multipart/related") != -1);
assertTrue("Invalid Content-Type set", transportResponse.getHeaders().getProperty("Content-Type")
.indexOf(SoapVersion.SOAP_11.getContentType()) != -1);
}

View File

@@ -24,7 +24,7 @@ public abstract class AbstractSoap12MessageContextTestCase extends AbstractSoapM
public void testWriteToTransportResponse() throws Exception {
messageContext.getResponse(); // create response
messageContext.sendResponse(null);
messageContext.sendResponse(transportResponse);
assertXMLEqual("<Envelope xmlns='http://www.w3.org/2003/05/soap-envelope'><Header/><Body/></Envelope>",
transportResponse.getContents());
assertTrue("Invalid Content-Type set", transportResponse.getHeaders().getProperty("Content-Type")
@@ -34,9 +34,7 @@ public abstract class AbstractSoap12MessageContextTestCase extends AbstractSoapM
public void testWriteToTransportResponseAttachment() throws Exception {
InputStreamSource inputStreamSource = new ByteArrayResource("contents".getBytes("UTF-8"));
messageContext.getSoapResponse().addAttachment(inputStreamSource, "text/plain");
messageContext.sendResponse(null);
assertTrue("Invalid Content-Type set",
transportResponse.getHeaders().getProperty("Content-Type").indexOf("multipart/related") != -1);
messageContext.sendResponse(transportResponse);
assertTrue("Invalid Content-Type set", transportResponse.getHeaders().getProperty("Content-Type")
.indexOf(SoapVersion.SOAP_12.getContentType()) != -1);
}

View File

@@ -28,6 +28,7 @@ import org.springframework.ws.soap.SoapMessage;
import org.springframework.ws.soap.SoapMessageException;
import org.springframework.ws.soap.SoapVersion;
import org.springframework.ws.soap.saaj.SaajSoapMessageContext;
import org.springframework.ws.soap.saaj.saaj13.Saaj13SoapMessageContext;
import org.springframework.ws.soap.soap11.Soap11Fault;
import org.springframework.ws.soap.soap12.Soap12Fault;
@@ -41,11 +42,9 @@ public class SoapFaultMappingExceptionResolverTest extends XMLTestCase {
public void testGetDepth() throws Exception {
assertEquals("Invalid depth for Exception", 0, resolver.getDepth("java.lang.Exception", new Exception()));
assertEquals("Invalid depth for IllegalArgumentException",
2,
assertEquals("Invalid depth for IllegalArgumentException", 2,
resolver.getDepth("java.lang.Exception", new IllegalArgumentException()));
assertEquals("Invalid depth for IllegalStateException",
-1,
assertEquals("Invalid depth for IllegalStateException", -1,
resolver.getDepth("IllegalArgumentException", new IllegalStateException()));
}
@@ -58,7 +57,7 @@ public class SoapFaultMappingExceptionResolverTest extends XMLTestCase {
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
SOAPMessage message = messageFactory.createMessage();
SaajSoapMessageContext context =
new SaajSoapMessageContext(message, new MockTransportRequest(), messageFactory);
new Saaj13SoapMessageContext(message, new MockTransportRequest(), messageFactory);
boolean result = resolver.resolveException(context, null, new IllegalArgumentException("bla"));
assertTrue("resolveException returns false", result);
@@ -66,8 +65,7 @@ public class SoapFaultMappingExceptionResolverTest extends XMLTestCase {
SoapMessage response = context.getSoapResponse();
assertTrue("Resonse has no fault", response.getSoapBody().hasFault());
Soap11Fault fault = (Soap11Fault) response.getSoapBody().getFault();
assertEquals("Invalid fault code on fault",
SoapVersion.SOAP_11.getClientOrSenderFaultName(),
assertEquals("Invalid fault code on fault", SoapVersion.SOAP_11.getClientOrSenderFaultName(),
fault.getFaultCode());
assertEquals("Invalid fault string on fault", "Client error", fault.getFaultString());
assertNull("Detail on fault", fault.getFaultDetail());
@@ -82,7 +80,7 @@ public class SoapFaultMappingExceptionResolverTest extends XMLTestCase {
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
SOAPMessage message = messageFactory.createMessage();
SaajSoapMessageContext context =
new SaajSoapMessageContext(message, new MockTransportRequest(), messageFactory);
new Saaj13SoapMessageContext(message, new MockTransportRequest(), messageFactory);
boolean result = resolver.resolveException(context, null, new IllegalArgumentException("bla"));
assertTrue("resolveException returns false", result);
@@ -90,8 +88,7 @@ public class SoapFaultMappingExceptionResolverTest extends XMLTestCase {
SoapMessage response = context.getSoapResponse();
assertTrue("Resonse has no fault", response.getSoapBody().hasFault());
Soap12Fault fault = (Soap12Fault) response.getSoapBody().getFault();
assertEquals("Invalid fault code on fault",
SoapVersion.SOAP_12.getClientOrSenderFaultName(),
assertEquals("Invalid fault code on fault", SoapVersion.SOAP_12.getClientOrSenderFaultName(),
fault.getFaultCode());
assertEquals("Invalid fault string on fault", "Sender error", fault.getFaultReasonText(Locale.ENGLISH));
assertNull("Detail on fault", fault.getFaultDetail());
@@ -106,7 +103,7 @@ public class SoapFaultMappingExceptionResolverTest extends XMLTestCase {
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
SOAPMessage message = messageFactory.createMessage();
SaajSoapMessageContext context =
new SaajSoapMessageContext(message, new MockTransportRequest(), messageFactory);
new Saaj13SoapMessageContext(message, new MockTransportRequest(), messageFactory);
boolean result = resolver.resolveException(context, null, new IllegalArgumentException("bla"));
assertTrue("resolveException returns false", result);
@@ -114,8 +111,7 @@ public class SoapFaultMappingExceptionResolverTest extends XMLTestCase {
SoapMessage response = context.getSoapResponse();
assertTrue("Resonse has no fault", response.getSoapBody().hasFault());
Soap11Fault fault = (Soap11Fault) response.getSoapBody().getFault();
assertEquals("Invalid fault code on fault",
SoapVersion.SOAP_11.getServerOrReceiverFaultName(),
assertEquals("Invalid fault code on fault", SoapVersion.SOAP_11.getServerOrReceiverFaultName(),
fault.getFaultCode());
assertEquals("Invalid fault string on fault", "Server error", fault.getFaultString());
assertNull("Detail on fault", fault.getFaultDetail());
@@ -130,7 +126,7 @@ public class SoapFaultMappingExceptionResolverTest extends XMLTestCase {
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
SOAPMessage message = messageFactory.createMessage();
SaajSoapMessageContext context =
new SaajSoapMessageContext(message, new MockTransportRequest(), messageFactory);
new Saaj13SoapMessageContext(message, new MockTransportRequest(), messageFactory);
boolean result = resolver.resolveException(context, null, new IllegalArgumentException("bla"));
assertTrue("resolveException returns false", result);
@@ -138,8 +134,7 @@ public class SoapFaultMappingExceptionResolverTest extends XMLTestCase {
SoapMessage response = context.getSoapResponse();
assertTrue("Resonse has no fault", response.getSoapBody().hasFault());
Soap12Fault fault = (Soap12Fault) response.getSoapBody().getFault();
assertEquals("Invalid fault code on fault",
SoapVersion.SOAP_12.getServerOrReceiverFaultName(),
assertEquals("Invalid fault code on fault", SoapVersion.SOAP_12.getServerOrReceiverFaultName(),
fault.getFaultCode());
assertEquals("Invalid fault string on fault", "Receiver error", fault.getFaultReasonText(Locale.ENGLISH));
assertNull("Detail on fault", fault.getFaultDetail());
@@ -156,7 +151,7 @@ public class SoapFaultMappingExceptionResolverTest extends XMLTestCase {
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
SOAPMessage message = messageFactory.createMessage();
SaajSoapMessageContext context =
new SaajSoapMessageContext(message, new MockTransportRequest(), messageFactory);
new Saaj13SoapMessageContext(message, new MockTransportRequest(), messageFactory);
boolean result = resolver.resolveException(context, null, new IllegalArgumentException("bla"));
assertTrue("resolveException returns false", result);
@@ -164,8 +159,7 @@ public class SoapFaultMappingExceptionResolverTest extends XMLTestCase {
SoapMessage response = context.getSoapResponse();
assertTrue("Resonse has no fault", response.getSoapBody().hasFault());
Soap11Fault fault = (Soap11Fault) response.getSoapBody().getFault();
assertEquals("Invalid fault code on fault",
SoapVersion.SOAP_11.getClientOrSenderFaultName(),
assertEquals("Invalid fault code on fault", SoapVersion.SOAP_11.getClientOrSenderFaultName(),
fault.getFaultCode());
assertEquals("Invalid fault string on fault", "faultstring", fault.getFaultString());
assertNull("Detail on fault", fault.getFaultDetail());

View File

@@ -27,6 +27,7 @@ import org.apache.log4j.Logger;
import org.apache.log4j.spi.LoggingEvent;
import org.springframework.ws.mock.MockTransportRequest;
import org.springframework.ws.soap.saaj.SaajSoapMessageContext;
import org.springframework.ws.soap.saaj.saaj13.Saaj13SoapMessageContext;
public class SoapEnvelopeLoggingInterceptorTest extends TestCase {
@@ -43,7 +44,7 @@ public class SoapEnvelopeLoggingInterceptorTest extends TestCase {
Logger.getRootLogger().setLevel(Level.DEBUG);
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage saajMessage = messageFactory.createMessage();
messageContext = new SaajSoapMessageContext(saajMessage, new MockTransportRequest(), messageFactory);
messageContext = new Saaj13SoapMessageContext(saajMessage, new MockTransportRequest(), messageFactory);
appender.reset();
}

View File

@@ -1,82 +0,0 @@
/*
* Copyright 2006 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ws.soap.saaj;
import java.io.IOException;
import java.io.InputStream;
import javax.xml.soap.AttachmentPart;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
import junit.framework.TestCase;
import org.springframework.util.FileCopyUtils;
import org.springframework.ws.soap.Attachment;
/**
* @author Arjen Poutsma
*/
public class SaajAttachmentTest extends TestCase {
private static final String CONTENTS = "attachment contents";
private static final String CONTENT_ID = "contentId";
private AttachmentPart saajAttachment;
private Attachment attachment;
protected void setUp() throws Exception {
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage saajMessage = messageFactory.createMessage();
saajAttachment = saajMessage.createAttachmentPart(CONTENTS, "text/plain");
saajAttachment.setContentId(CONTENT_ID);
saajMessage.addAttachmentPart(saajAttachment);
SaajSoapMessage saajSoapMessage = new SaajSoapMessage(saajMessage);
attachment = saajSoapMessage.getAttachment(CONTENT_ID);
}
public void testGetSize() throws SOAPException {
assertEquals("Invalid size", saajAttachment.getSize(), attachment.getSize());
}
public void testContentId() {
assertEquals("Invalid content id", CONTENT_ID, attachment.getId());
String id = "123";
attachment.setId(id);
assertEquals("Invalid content id", id, attachment.getId());
}
public void testGetContentType() {
assertEquals("Invalid content type", "text/plain", attachment.getContentType());
}
public void testGetInputStream() throws IOException {
InputStream inputStream = attachment.getInputStream();
assertNotNull("Invalid input stream returned", inputStream);
byte[] bytes = FileCopyUtils.copyToByteArray(inputStream);
assertEquals("Invalid size", CONTENTS.getBytes().length, bytes.length);
}
public void testGetEmptyInputStream() throws IOException {
saajAttachment.clearContent();
InputStream inputStream = attachment.getInputStream();
assertNotNull("Invalid input stream returned", inputStream);
byte[] bytes = FileCopyUtils.copyToByteArray(inputStream);
assertEquals("Invalid size", 0, bytes.length);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2005 the original author or authors.
* Copyright 2006 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
package org.springframework.ws.soap.saaj;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPMessage;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
@@ -26,16 +27,18 @@ import org.springframework.ws.soap.soap11.AbstractSoap11MessageTestCase;
import org.springframework.xml.transform.StringResult;
import org.springframework.xml.transform.StringSource;
public class SaajSoap11MessageTest extends AbstractSoap11MessageTestCase {
public abstract class SaajSoap11MessageTestCase extends AbstractSoap11MessageTestCase {
private SOAPMessage saajMessage;
protected SoapMessage createSoapMessage() throws Exception {
MessageFactory messageFactory = MessageFactory.newInstance();
protected final SoapMessage createSoapMessage() throws Exception {
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
saajMessage = messageFactory.createMessage();
return new SaajSoapMessage(saajMessage);
return createSaajSoapMessage(saajMessage);
}
protected abstract SaajSoapMessage createSaajSoapMessage(SOAPMessage saajMessage);
public void testGetPayloadSource() throws Exception {
saajMessage.getSOAPBody().addChildElement("child");
Source source = soapMessage.getPayloadSource();
@@ -61,4 +64,4 @@ public class SaajSoap11MessageTest extends AbstractSoap11MessageTestCase {
assertEquals("Invalid child node created", "child", saajMessage.getSOAPBody().getFirstChild().getLocalName());
}
}
}

View File

@@ -1,20 +0,0 @@
package org.springframework.ws.soap.saaj;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPMessage;
import org.springframework.ws.soap.SoapBody;
import org.springframework.ws.soap.soap12.AbstractSoap12BodyTestCase;
public class SaajSoap12BodyTest extends AbstractSoap12BodyTestCase {
protected SoapBody createSoapBody() throws Exception {
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
SOAPMessage saajMessage = messageFactory.createMessage();
saajMessage.getSOAPPart().getEnvelope().setPrefix("soapenv");
SaajSoapMessage saajSoapMessage = new SaajSoapMessage(saajMessage);
return saajSoapMessage.getSoapBody();
}
}

View File

@@ -1,18 +0,0 @@
package org.springframework.ws.soap.saaj;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPMessage;
import org.springframework.ws.soap.SoapEnvelope;
import org.springframework.ws.soap.soap12.AbstractSoap12EnvelopeTestCase;
public class SaajSoap12EnvelopeTest extends AbstractSoap12EnvelopeTestCase {
protected SoapEnvelope createSoapEnvelope() throws Exception {
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
SOAPMessage saajMessage = messageFactory.createMessage();
SaajSoapMessage saajSoapMessage = new SaajSoapMessage(saajMessage);
return saajSoapMessage.getEnvelope();
}
}

View File

@@ -1,18 +0,0 @@
package org.springframework.ws.soap.saaj;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPMessage;
import org.springframework.ws.soap.SoapHeader;
import org.springframework.ws.soap.soap12.AbstractSoap12HeaderTestCase;
public class SaajSoap12HeaderTest extends AbstractSoap12HeaderTestCase {
protected SoapHeader createSoapHeader() throws Exception {
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
SOAPMessage saajMessage = messageFactory.createMessage();
SaajSoapMessage saajSoapMessage = new SaajSoapMessage(saajMessage);
return saajSoapMessage.getSoapHeader();
}
}

View File

@@ -0,0 +1,33 @@
/*
* Copyright 2006 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ws.soap.saaj.saaj12;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPMessage;
import org.springframework.ws.soap.AbstractAttachmentTestCase;
import org.springframework.ws.soap.SoapMessage;
public class Saaj12AttachmentTest extends AbstractAttachmentTestCase {
protected SoapMessage createMessage() throws Exception {
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
SOAPMessage saajMessage = messageFactory.createMessage();
return new Saaj12SoapMessage(saajMessage);
}
}

View File

@@ -14,21 +14,21 @@
* limitations under the License.
*/
package org.springframework.ws.soap.saaj;
package org.springframework.ws.soap.saaj.saaj12;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPMessage;
import org.springframework.ws.soap.SoapBody;
import org.springframework.ws.soap.soap11.AbstractSoap11BodyTestCase;
public class SaajSoap11BodyTest extends AbstractSoap11BodyTestCase {
public class Saaj12Soap11BodyTest extends AbstractSoap11BodyTestCase {
protected SoapBody createSoapBody() throws Exception {
MessageFactory messageFactory = MessageFactory.newInstance();
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
SOAPMessage saajMessage = messageFactory.createMessage();
SaajSoapMessage saajSoapMessage = new SaajSoapMessage(saajMessage);
return saajSoapMessage.getSoapBody();
return new Saaj12Soap11Body(saajMessage.getSOAPBody());
}
}

View File

@@ -14,20 +14,20 @@
* limitations under the License.
*/
package org.springframework.ws.soap.saaj;
package org.springframework.ws.soap.saaj.saaj12;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPMessage;
import org.springframework.ws.soap.SoapEnvelope;
import org.springframework.ws.soap.soap11.AbstractSoap11EnvelopeTestCase;
public class SaajSoap11EnvelopeTest extends AbstractSoap11EnvelopeTestCase {
public class Saaj12Soap11EnvelopeTest extends AbstractSoap11EnvelopeTestCase {
protected SoapEnvelope createSoapEnvelope() throws Exception {
MessageFactory messageFactory = MessageFactory.newInstance();
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
SOAPMessage saajMessage = messageFactory.createMessage();
SaajSoapMessage saajSoapMessage = new SaajSoapMessage(saajMessage);
return saajSoapMessage.getEnvelope();
return new Saaj12SoapEnvelope(saajMessage.getSOAPPart().getEnvelope());
}
}

View File

@@ -14,20 +14,20 @@
* limitations under the License.
*/
package org.springframework.ws.soap.saaj;
package org.springframework.ws.soap.saaj.saaj12;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPMessage;
import org.springframework.ws.soap.SoapHeader;
import org.springframework.ws.soap.soap11.AbstractSoap11HeaderTestCase;
public class SaajSoap11HeaderTest extends AbstractSoap11HeaderTestCase {
public class Saaj12Soap11HeaderTest extends AbstractSoap11HeaderTestCase {
protected SoapHeader createSoapHeader() throws Exception {
MessageFactory messageFactory = MessageFactory.newInstance();
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
SOAPMessage saajMessage = messageFactory.createMessage();
SaajSoapMessage saajSoapMessage = new SaajSoapMessage(saajMessage);
return saajSoapMessage.getSoapHeader();
return new Saaj12SoapHeader(saajMessage.getSOAPHeader());
}
}

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.ws.soap.saaj;
package org.springframework.ws.soap.saaj.saaj12;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPConstants;
@@ -24,10 +24,10 @@ import org.springframework.ws.soap.context.AbstractSoap11MessageContextTestCase;
import org.springframework.ws.soap.context.SoapMessageContext;
import org.springframework.ws.transport.TransportRequest;
public class SaajSoap11MessageContextTest extends AbstractSoap11MessageContextTestCase {
public class Saaj12Soap11MessageContextTest extends AbstractSoap11MessageContextTestCase {
protected SoapMessageContext createMessageContext(TransportRequest transportRequest) throws SOAPException {
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
return new SaajSoapMessageContext(messageFactory.createMessage(), transportRequest, messageFactory);
return new Saaj12SoapMessageContext(messageFactory.createMessage(), transportRequest, messageFactory);
}
}

View File

@@ -0,0 +1,30 @@
/*
* Copyright 2005 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ws.soap.saaj.saaj12;
import javax.xml.soap.SOAPMessage;
import org.springframework.ws.soap.saaj.SaajSoap11MessageTestCase;
import org.springframework.ws.soap.saaj.SaajSoapMessage;
public class Saaj12Soap11MessageTest extends SaajSoap11MessageTestCase {
protected SaajSoapMessage createSaajSoapMessage(SOAPMessage saajMessage) {
return new Saaj12SoapMessage(saajMessage);
}
}

View File

@@ -0,0 +1,33 @@
/*
* Copyright 2006 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ws.soap.saaj.saaj13;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPMessage;
import org.springframework.ws.soap.AbstractAttachmentTestCase;
import org.springframework.ws.soap.SoapMessage;
public class Saaj13AttachmentTest extends AbstractAttachmentTestCase {
protected SoapMessage createMessage() throws Exception {
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
SOAPMessage saajMessage = messageFactory.createMessage();
return new Saaj13SoapMessage(saajMessage);
}
}

View File

@@ -0,0 +1,34 @@
/*
* Copyright 2006 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ws.soap.saaj.saaj13;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPMessage;
import org.springframework.ws.soap.SoapBody;
import org.springframework.ws.soap.soap11.AbstractSoap11BodyTestCase;
public class Saaj13Soap11BodyTest extends AbstractSoap11BodyTestCase {
protected SoapBody createSoapBody() throws Exception {
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
SOAPMessage saajMessage = messageFactory.createMessage();
return new Saaj13Soap11Body(saajMessage.getSOAPBody());
}
}

View File

@@ -0,0 +1,33 @@
/*
* Copyright 2006 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ws.soap.saaj.saaj13;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPMessage;
import org.springframework.ws.soap.SoapEnvelope;
import org.springframework.ws.soap.soap11.AbstractSoap11EnvelopeTestCase;
public class Saaj13Soap11EnvelopeTest extends AbstractSoap11EnvelopeTestCase {
protected SoapEnvelope createSoapEnvelope() throws Exception {
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
SOAPMessage saajMessage = messageFactory.createMessage();
return new Saaj13SoapEnvelope(saajMessage.getSOAPPart().getEnvelope());
}
}

View File

@@ -0,0 +1,33 @@
/*
* Copyright 2006 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ws.soap.saaj.saaj13;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPMessage;
import org.springframework.ws.soap.SoapHeader;
import org.springframework.ws.soap.soap11.AbstractSoap11HeaderTestCase;
public class Saaj13Soap11HeaderTest extends AbstractSoap11HeaderTestCase {
protected SoapHeader createSoapHeader() throws Exception {
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
SOAPMessage saajMessage = messageFactory.createMessage();
return new Saaj13SoapHeader(saajMessage.getSOAPHeader());
}
}

View File

@@ -0,0 +1,33 @@
/*
* Copyright 2006 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ws.soap.saaj.saaj13;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPException;
import org.springframework.ws.soap.context.AbstractSoap11MessageContextTestCase;
import org.springframework.ws.soap.context.SoapMessageContext;
import org.springframework.ws.transport.TransportRequest;
public class Saaj13Soap11MessageContextTest extends AbstractSoap11MessageContextTestCase {
protected SoapMessageContext createMessageContext(TransportRequest transportRequest) throws SOAPException {
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
return new Saaj13SoapMessageContext(messageFactory.createMessage(), transportRequest, messageFactory);
}
}

View File

@@ -0,0 +1,30 @@
/*
* Copyright 2006 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ws.soap.saaj.saaj13;
import javax.xml.soap.SOAPMessage;
import org.springframework.ws.soap.saaj.SaajSoap11MessageTestCase;
import org.springframework.ws.soap.saaj.SaajSoapMessage;
public class Saaj13Soap11MessageTest extends SaajSoap11MessageTestCase {
protected SaajSoapMessage createSaajSoapMessage(SOAPMessage saajMessage) {
return new Saaj13SoapMessage(saajMessage);
}
}

View File

@@ -0,0 +1,34 @@
/*
* Copyright 2006 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ws.soap.saaj.saaj13;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPMessage;
import org.springframework.ws.soap.SoapBody;
import org.springframework.ws.soap.soap12.AbstractSoap12BodyTestCase;
public class Saaj13Soap12BodyTest extends AbstractSoap12BodyTestCase {
protected SoapBody createSoapBody() throws Exception {
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
SOAPMessage saajMessage = messageFactory.createMessage();
return new Saaj13Soap12Body(saajMessage.getSOAPBody());
}
}

View File

@@ -0,0 +1,33 @@
/*
* Copyright 2006 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ws.soap.saaj.saaj13;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPMessage;
import org.springframework.ws.soap.SoapEnvelope;
import org.springframework.ws.soap.soap12.AbstractSoap12EnvelopeTestCase;
public class Saaj13Soap12EnvelopeTest extends AbstractSoap12EnvelopeTestCase {
protected SoapEnvelope createSoapEnvelope() throws Exception {
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
SOAPMessage saajMessage = messageFactory.createMessage();
return new Saaj13SoapEnvelope(saajMessage.getSOAPPart().getEnvelope());
}
}

View File

@@ -0,0 +1,33 @@
/*
* Copyright 2006 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ws.soap.saaj.saaj13;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPMessage;
import org.springframework.ws.soap.SoapHeader;
import org.springframework.ws.soap.soap12.AbstractSoap12HeaderTestCase;
public class Saaj13Soap12HeaderTest extends AbstractSoap12HeaderTestCase {
protected SoapHeader createSoapHeader() throws Exception {
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
SOAPMessage saajMessage = messageFactory.createMessage();
return new Saaj13Soap12Header(saajMessage.getSOAPHeader());
}
}

View File

@@ -0,0 +1,33 @@
/*
* Copyright 2006 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ws.soap.saaj.saaj13;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPException;
import org.springframework.ws.soap.context.AbstractSoap12MessageContextTestCase;
import org.springframework.ws.soap.context.SoapMessageContext;
import org.springframework.ws.transport.TransportRequest;
public class Saaj13Soap12MessageContextTest extends AbstractSoap12MessageContextTestCase {
protected SoapMessageContext createMessageContext(TransportRequest transportRequest) throws SOAPException {
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
return new Saaj13SoapMessageContext(messageFactory.createMessage(), transportRequest, messageFactory);
}
}

View File

@@ -1,4 +1,4 @@
package org.springframework.ws.soap.saaj;
package org.springframework.ws.soap.saaj.saaj13;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPConstants;
@@ -11,14 +11,14 @@ import org.springframework.ws.soap.soap12.AbstractSoap12MessageTestCase;
import org.springframework.xml.transform.StringResult;
import org.springframework.xml.transform.StringSource;
public class SaajSoap12MessageTest extends AbstractSoap12MessageTestCase {
public class Saaj13Soap12MessageTest extends AbstractSoap12MessageTestCase {
private SOAPMessage saajMessage;
protected SoapMessage createSoapMessage() throws Exception {
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
saajMessage = messageFactory.createMessage();
return new SaajSoapMessage(saajMessage);
return new Saaj13SoapMessage(saajMessage);
}
public void testGetPayloadSource() throws Exception {

View File

@@ -25,8 +25,9 @@ import javax.xml.soap.SOAPMessage;
import junit.framework.TestCase;
import org.springframework.ws.soap.saaj.SaajSoapMessageContext;
import org.springframework.ws.transport.TransportRequest;
import org.springframework.ws.soap.saaj.saaj13.Saaj13SoapMessageContext;
import org.springframework.ws.transport.TransportException;
import org.springframework.ws.transport.TransportRequest;
public class XwsSecurityInterceptorTest extends TestCase {
@@ -52,7 +53,7 @@ public class XwsSecurityInterceptorTest extends TestCase {
};
SaajSoapMessageContext context =
new SaajSoapMessageContext(request, new DummyTransportRequest(), messageFactory);
new Saaj13SoapMessageContext(request, new DummyTransportRequest(), messageFactory);
interceptor.handleRequest(context, null);
assertEquals("Invalid request", validatedRequest, context.getSaajRequest());
}
@@ -74,7 +75,7 @@ public class XwsSecurityInterceptorTest extends TestCase {
};
SOAPMessage request = messageFactory.createMessage();
SaajSoapMessageContext context =
new SaajSoapMessageContext(request, new DummyTransportRequest(), messageFactory);
new Saaj13SoapMessageContext(request, new DummyTransportRequest(), messageFactory);
context.setSaajResponse(response);
interceptor.handleResponse(context, null);
assertEquals("Invalid response", securedResponse, context.getSaajResponse());