Refactored SAAJ implementation from two separate class hierarchies (SAAJ 1.2 and SAAJ 1.3) into one single hierarchy, using bridge pattern (SaajImplementation).

This commit is contained in:
Arjen Poutsma
2006-12-31 20:38:40 +00:00
parent 785f6e854c
commit a8e2af7f92
37 changed files with 1260 additions and 1560 deletions

View File

@@ -0,0 +1,58 @@
/*
* 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 java.io.OutputStream;
import javax.activation.DataSource;
import org.springframework.core.io.InputStreamSource;
/**
* Activation framework <code>DataSource</code> that wraps a Spring <code>InputStreamSource</code>.
*
* @author Arjen Poutsma
*/
class InputStreamSourceDataSource implements DataSource {
private final InputStreamSource inputStreamSource;
private final String contentType;
public InputStreamSourceDataSource(InputStreamSource inputStreamSource, String contentType) {
this.inputStreamSource = inputStreamSource;
this.contentType = contentType;
}
public InputStream getInputStream() throws IOException {
return inputStreamSource.getInputStream();
}
public OutputStream getOutputStream() {
throw new UnsupportedOperationException("Read-only javax.activation.DataSource");
}
public String getContentType() {
return contentType;
}
public String getName() {
throw new UnsupportedOperationException("DataSource name not available");
}
}

View File

@@ -0,0 +1,126 @@
/*
* 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.util.Iterator;
import java.util.Locale;
import javax.xml.namespace.QName;
import javax.xml.soap.Detail;
import javax.xml.soap.DetailEntry;
import javax.xml.soap.Name;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFault;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPHeaderElement;
import org.springframework.ws.soap.saaj.support.SaajUtils;
/**
* SAAJ 1.2 specific implementation of the <code>SaajImplementation</code> interface.
*
* @author Arjen Poutsma
*/
public class Saaj12Implementation extends SaajImplementation {
private static final Saaj12Implementation INSTANCE = new Saaj12Implementation();
private Saaj12Implementation() {
}
public static Saaj12Implementation getInstance() {
return INSTANCE;
}
public QName getName(SOAPElement element) {
return SaajUtils.toQName(element.getElementName());
}
public QName getFaultCode(SOAPFault fault) {
return SaajUtils.toQName(fault.getFaultCodeAsName());
}
public boolean isSoap11(SOAPElement element) {
return true;
}
public DetailEntry addDetailEntry(Detail detail, QName name) throws SOAPException {
Name detailEntryName = SaajUtils.toName(name, detail);
return detail.addDetailEntry(detailEntryName);
}
public SOAPHeaderElement addHeaderElement(SOAPHeader header, QName name) throws SOAPException {
Name saajName = SaajUtils.toName(name, header);
return header.addHeaderElement(saajName);
}
public SOAPFault addFault(SOAPBody body, QName faultCode, String faultString, Locale locale) throws SOAPException {
Name name = SaajUtils.toName(faultCode, body);
if (locale == null) {
return body.addFault(name, faultString);
}
else {
return body.addFault(name, faultString, locale);
}
}
//
// SOAP 1.2
//
public String getFaultRole(SOAPFault fault) {
throw new UnsupportedOperationException("SAAJ 1.2 does not support SOAP 1.2");
}
public void setFaultRole(SOAPFault fault, String role) {
throw new UnsupportedOperationException("SAAJ 1.2 does not support SOAP 1.2");
}
public SOAPHeaderElement addNotUnderstoodHeaderElement(SOAPHeader header, QName name) {
throw new UnsupportedOperationException("SAAJ 1.2 does not support SOAP 1.2");
}
public SOAPHeaderElement addUpgradeHeaderElement(SOAPHeader header, String[] supportedSoapUris) {
throw new UnsupportedOperationException("SAAJ 1.2 does not support SOAP 1.2");
}
public Iterator getFaultSubcodes(SOAPFault fault) {
throw new UnsupportedOperationException("SAAJ 1.2 does not support SOAP 1.2");
}
public void appendFaultSubcode(SOAPFault fault, QName subcode) {
throw new UnsupportedOperationException("SAAJ 1.2 does not support SOAP 1.2");
}
public String getFaultNode(SOAPFault fault) {
throw new UnsupportedOperationException("SAAJ 1.2 does not support SOAP 1.2");
}
public void setFaultNode(SOAPFault fault, String uri) {
throw new UnsupportedOperationException("SAAJ 1.2 does not support SOAP 1.2");
}
public String getFaultReasonText(SOAPFault fault, Locale locale) {
throw new UnsupportedOperationException("SAAJ 1.2 does not support SOAP 1.2");
}
public void setFaultReasonText(SOAPFault fault, Locale locale, String text) {
throw new UnsupportedOperationException("SAAJ 1.2 does not support SOAP 1.2");
}
}

View File

@@ -0,0 +1,117 @@
/*
* 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.util.Iterator;
import java.util.Locale;
import javax.xml.namespace.QName;
import javax.xml.soap.Detail;
import javax.xml.soap.DetailEntry;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFault;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPHeaderElement;
/**
* SAAJ 1.3 specific implementation of the <code>SaajImplementation</code> interface.
*
* @author Arjen Poutsma
*/
public class Saaj13Implementation extends SaajImplementation {
private static final Saaj13Implementation INSTANCE = new Saaj13Implementation();
private Saaj13Implementation() {
}
public static Saaj13Implementation getInstance() {
return INSTANCE;
}
public QName getName(SOAPElement element) {
return element.getElementQName();
}
public QName getFaultCode(SOAPFault fault) {
return fault.getFaultCodeAsQName();
}
public boolean isSoap11(SOAPElement element) {
return SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE.equals(element.getNamespaceURI());
}
public DetailEntry addDetailEntry(Detail detail, QName name) throws SOAPException {
return detail.addDetailEntry(name);
}
public SOAPHeaderElement addHeaderElement(SOAPHeader header, QName name) throws SOAPException {
return header.addHeaderElement(name);
}
public String getFaultRole(SOAPFault fault) {
return fault.getFaultRole();
}
public void setFaultRole(SOAPFault fault, String role) throws SOAPException {
fault.setFaultRole(role);
}
public SOAPHeaderElement addNotUnderstoodHeaderElement(SOAPHeader header, QName name) throws SOAPException {
return header.addNotUnderstoodHeaderElement(name);
}
public SOAPHeaderElement addUpgradeHeaderElement(SOAPHeader header, String[] supportedSoapUris)
throws SOAPException {
return header.addUpgradeHeaderElement(supportedSoapUris);
}
public Iterator getFaultSubcodes(SOAPFault fault) {
return fault.getFaultSubcodes();
}
public void appendFaultSubcode(SOAPFault fault, QName subcode) throws SOAPException {
fault.appendFaultSubcode(subcode);
}
public String getFaultNode(SOAPFault fault) {
return fault.getFaultNode();
}
public void setFaultNode(SOAPFault fault, String uri) throws SOAPException {
fault.setFaultNode(uri);
}
public String getFaultReasonText(SOAPFault fault, Locale locale) throws SOAPException {
return fault.getFaultReasonText(locale);
}
public void setFaultReasonText(SOAPFault fault, Locale locale, String text) throws SOAPException {
fault.addFaultReasonText(text, locale);
}
public SOAPFault addFault(SOAPBody body, QName faultCode, String faultString, Locale locale) throws SOAPException {
if (locale == null) {
return body.addFault(faultCode, faultString);
}
else {
return body.addFault(faultCode, faultString, locale);
}
}
}

View File

@@ -0,0 +1,75 @@
/*
* 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.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import javax.xml.soap.AttachmentPart;
import javax.xml.soap.SOAPException;
import org.springframework.util.Assert;
import org.springframework.ws.soap.Attachment;
/**
* SAAJ-specific implementation of the <code>Attachment</code> interface. Wraps a {@link
* javax.xml.soap.AttachmentPart}.
*
* @author Arjen Poutsma
*/
class SaajAttachment implements Attachment {
private final AttachmentPart saajAttachment;
public SaajAttachment(AttachmentPart saajAttachment) {
Assert.notNull(saajAttachment, "saajAttachment must not be null");
this.saajAttachment = saajAttachment;
}
public String getId() {
return saajAttachment.getContentId();
}
public void setId(String id) {
saajAttachment.setContentId(id);
}
public String getContentType() {
return saajAttachment.getContentType();
}
public InputStream getInputStream() throws IOException {
try {
return saajAttachment.getDataHandler().getInputStream();
}
catch (SOAPException e) {
return new ByteArrayInputStream(new byte[0]);
}
}
public long getSize() {
try {
int result = saajAttachment.getSize();
// SAAJ returns -1 when the size cannot be determined
return result != -1 ? result : 0;
}
catch (SOAPException ex) {
throw new SaajAttachmentException(ex);
}
}
}

View File

@@ -0,0 +1,249 @@
/*
* 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.OutputStream;
import java.util.Iterator;
import java.util.Locale;
import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.xml.namespace.QName;
import javax.xml.soap.AttachmentPart;
import javax.xml.soap.Detail;
import javax.xml.soap.DetailEntry;
import javax.xml.soap.MimeHeader;
import javax.xml.soap.MimeHeaders;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPBodyElement;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFault;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPHeaderElement;
import javax.xml.soap.SOAPMessage;
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.ObjectUtils;
import org.springframework.ws.soap.SoapVersion;
import org.springframework.ws.soap.saaj.support.SaajUtils;
import org.springframework.ws.transport.TransportOutputStream;
/**
* Forms bridge between the <code>SoapMessage</code> hierarchy and specific version of SAAJ. Various <code>Saaj*</code>
* classes delegate to this implementation to remain independent of SAAJ versions.
*
* @author Arjen Poutsma
*/
abstract class SaajImplementation {
protected SaajImplementation() {
}
/**
* Returns the singleton instance for the version of SAAJ in use.
*/
public static SaajImplementation getImplementation() {
if (SaajUtils.getSaajVersion() == SaajUtils.SAAJ_12) {
return Saaj12Implementation.getInstance();
}
else if (SaajUtils.getSaajVersion() == SaajUtils.SAAJ_13) {
return Saaj13Implementation.getInstance();
}
else {
throw new IllegalStateException("Could not find SAAJ 1.2 or SAAJ 1.3 on the classpath");
}
}
public abstract QName getName(SOAPElement element);
public Source getSource(SOAPElement element) {
return new DOMSource(element);
}
public Result getResult(SOAPElement element) {
return new DOMResult(element);
}
public SOAPEnvelope getEnvelope(SOAPMessage message) throws SOAPException {
return message.getSOAPPart().getEnvelope();
}
public SOAPHeader getHeader(SOAPEnvelope envelope) throws SOAPException {
return envelope.getHeader();
}
public SOAPBody getBody(SOAPEnvelope envelope) throws SOAPException {
return envelope.getBody();
}
public String getActorOrRole(SOAPHeaderElement headerElement) {
return headerElement.getActor();
}
public void setActorOrRole(SOAPHeaderElement headerElement, String actorOrRole) {
headerElement.setActor(actorOrRole);
}
public boolean getMustUnderstand(SOAPHeaderElement headerElement) {
return headerElement.getMustUnderstand();
}
public void setMustUnderstand(SOAPHeaderElement headerElement, boolean mustUnderstand) {
headerElement.setMustUnderstand(mustUnderstand);
}
public abstract QName getFaultCode(SOAPFault fault);
public String getFaultActor(SOAPFault fault) {
return fault.getFaultActor();
}
public void setFaultActor(SOAPFault fault, String actorOrRole) throws SOAPException {
fault.setFaultActor(actorOrRole);
}
public void addTextNode(DetailEntry detailEntry, String text) throws SOAPException {
detailEntry.addTextNode(text);
}
public Iterator getDetailEntries(Detail detail) {
return detail.getDetailEntries();
}
public SOAPBodyElement getFirstBodyElement(SOAPBody body) {
for (Iterator iterator = body.getChildElements(); iterator.hasNext();) {
Object child = iterator.next();
if (child instanceof SOAPBodyElement) {
return (SOAPBodyElement) child;
}
}
return null;
}
public boolean hasFault(SOAPBody body) {
return body.hasFault();
}
public SOAPFault getFault(SOAPBody body) {
return body.getFault();
}
public abstract boolean isSoap11(SOAPElement element);
public void removeContents(SOAPElement element) {
element.removeContents();
}
public abstract DetailEntry addDetailEntry(Detail detail, QName name) throws SOAPException;
public Iterator examineAllHeaderElements(SOAPHeader header) {
return header.examineAllHeaderElements();
}
public Iterator examineMustUnderstandHeaderElements(SOAPHeader header, String actorOrRole) {
return header.examineMustUnderstandHeaderElements(actorOrRole);
}
public abstract SOAPHeaderElement addHeaderElement(SOAPHeader header, QName name) throws SOAPException;
public abstract String getFaultRole(SOAPFault fault);
public abstract void setFaultRole(SOAPFault fault, String role) throws SOAPException;
public abstract SOAPHeaderElement addNotUnderstoodHeaderElement(SOAPHeader header, QName name) throws SOAPException;
public abstract SOAPHeaderElement addUpgradeHeaderElement(SOAPHeader header, String[] supportedSoapUris)
throws SOAPException;
public Detail getFaultDetail(SOAPFault fault) {
return fault.getDetail();
}
public Detail addFaultDetail(SOAPFault fault) throws SOAPException {
return fault.addDetail();
}
public String getFaultString(SOAPFault fault) {
return fault.getFaultString();
}
public Locale getFaultStringLocale(SOAPFault fault) {
return fault.getFaultStringLocale();
}
public abstract Iterator getFaultSubcodes(SOAPFault fault);
public abstract void appendFaultSubcode(SOAPFault fault, QName subcode) throws SOAPException;
public abstract String getFaultNode(SOAPFault fault);
public abstract void setFaultNode(SOAPFault fault, String uri) throws SOAPException;
public abstract String getFaultReasonText(SOAPFault fault, Locale locale) throws SOAPException;
public abstract void setFaultReasonText(SOAPFault fault, Locale locale, String text) throws SOAPException;
public abstract SOAPFault addFault(SOAPBody body, QName faultCode, String faultString, Locale locale)
throws SOAPException;
public void writeTo(SOAPMessage message, OutputStream outputStream) throws SOAPException, IOException {
if (message.saveRequired()) {
message.saveChanges();
}
if (outputStream instanceof TransportOutputStream) {
TransportOutputStream transportOutputStream = (TransportOutputStream) outputStream;
// some SAAJ implementations (Axis 1) do not have a Content-Type header by default
MimeHeaders headers = message.getMimeHeaders();
if (ObjectUtils.isEmpty(headers.getHeader("Content-Type"))) {
if (isSoap11(getEnvelope(message))) {
headers.addHeader("Content-Type", SoapVersion.SOAP_11.getContentType());
}
else {
headers.addHeader("Content-Type", SoapVersion.SOAP_12.getContentType());
}
if (message.saveRequired()) {
message.saveChanges();
}
}
for (Iterator iterator = headers.getAllHeaders(); iterator.hasNext();) {
MimeHeader mimeHeader = (MimeHeader) iterator.next();
transportOutputStream.addHeader(mimeHeader.getName(), mimeHeader.getValue());
}
}
message.writeTo(outputStream);
}
public Iterator getAttachments(SOAPMessage message) {
return message.getAttachments();
}
public Iterator getAttachment(SOAPMessage message, MimeHeaders mimeHeaders) {
return message.getAttachments(mimeHeaders);
}
public AttachmentPart addAttachmentPart(SOAPMessage message, DataSource dataSource) {
AttachmentPart attachmentPart = message.createAttachmentPart(new DataHandler(dataSource));
message.addAttachmentPart(attachmentPart);
return attachmentPart;
}
}

View File

@@ -0,0 +1,79 @@
/*
* 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.util.Locale;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFault;
import org.springframework.util.Assert;
import org.springframework.ws.soap.SoapFault;
import org.springframework.ws.soap.SoapVersion;
import org.springframework.ws.soap.soap11.Soap11Body;
import org.springframework.ws.soap.soap11.Soap11Fault;
/**
* SAAJ-specific implementation of the <code>Soap11Body</code> interface. Wraps a {@link javax.xml.soap.SOAPBody}.
*
* @author Arjen Poutsma
*/
class SaajSoap11Body extends SaajSoapBody implements Soap11Body {
public SaajSoap11Body(SOAPBody body) {
super(body);
}
public SoapFault getFault() {
SOAPFault fault = getImplementation().getFault(getSaajBody());
return new SaajSoap11Fault(fault);
}
public Soap11Fault addFault(QName faultCode, String faultString, Locale faultStringLocale) {
Assert.notNull(faultCode, "No faultCode given");
Assert.hasLength(faultString, "faultString cannot be empty");
Assert.hasLength(faultCode.getLocalPart(), "faultCode's localPart cannot be empty");
Assert.hasLength(faultCode.getNamespaceURI(), "faultCode's namespaceUri cannot be empty");
try {
getImplementation().removeContents(getSaajBody());
SOAPFault saajFault =
getImplementation().addFault(getSaajBody(), faultCode, faultString, faultStringLocale);
return new SaajSoap11Fault(saajFault);
}
catch (SOAPException ex) {
throw new SaajSoapFaultException(ex);
}
}
public SoapFault addClientOrSenderFault(String faultString, Locale locale) {
return addFault(SoapVersion.SOAP_11.getClientOrSenderFaultName(), faultString, locale);
}
public SoapFault addMustUnderstandFault(String faultString, Locale locale) {
return addFault(SoapVersion.SOAP_11.getMustUnderstandFaultName(), faultString, locale);
}
public SoapFault addServerOrReceiverFault(String faultString, Locale locale) {
return addFault(SoapVersion.SOAP_11.getServerOrReceiverFaultName(), faultString, locale);
}
public SoapFault addVersionMismatchFault(String faultString, Locale locale) {
return addFault(SoapVersion.SOAP_11.getVersionMismatchFaultName(), faultString, locale);
}
}

View File

@@ -0,0 +1,56 @@
/*
* 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.util.Locale;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFault;
import org.springframework.ws.soap.soap11.Soap11Fault;
/**
* SAAJ-specific implementation of the <code>Soap11Fault</code> interface. Wraps a {@link javax.xml.soap.SOAPFault}.
*
* @author Arjen Poutsma
*/
class SaajSoap11Fault extends SaajSoapFault implements Soap11Fault {
SaajSoap11Fault(SOAPFault fault) {
super(fault);
}
public String getFaultActorOrRole() {
return getImplementation().getFaultActor(getSaajFault());
}
public void setFaultActorOrRole(String faultActor) {
try {
getImplementation().setFaultActor(getSaajFault(), faultActor);
}
catch (SOAPException ex) {
throw new SaajSoapFaultException(ex);
}
}
public String getFaultString() {
return getImplementation().getFaultString(getSaajFault());
}
public Locale getFaultStringLocale() {
return getImplementation().getFaultStringLocale(getSaajFault());
}
}

View File

@@ -0,0 +1,88 @@
/*
* 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.util.Locale;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFault;
import org.springframework.util.Assert;
import org.springframework.ws.soap.SoapFault;
import org.springframework.ws.soap.SoapVersion;
import org.springframework.ws.soap.soap12.Soap12Body;
import org.springframework.ws.soap.soap12.Soap12Fault;
/**
* SAAJ-specific implementation of the <code>Soap12Body</code> interface. Wraps a {@link javax.xml.soap.SOAPBody}.
*
* @author Arjen Poutsma
*/
class SaajSoap12Body extends SaajSoapBody implements Soap12Body {
public SaajSoap12Body(SOAPBody body) {
super(body);
}
public SoapFault getFault() {
SOAPFault fault = getImplementation().getFault(getSaajBody());
return new SaajSoap12Fault(fault);
}
public SoapFault addClientOrSenderFault(String faultString, Locale locale) {
return addFault(SoapVersion.SOAP_12.getClientOrSenderFaultName(), faultString, locale);
}
public SoapFault addMustUnderstandFault(String faultString, Locale locale) {
return addFault(SoapVersion.SOAP_12.getMustUnderstandFaultName(), faultString, locale);
}
public SoapFault addServerOrReceiverFault(String faultString, Locale locale) {
return addFault(SoapVersion.SOAP_12.getServerOrReceiverFaultName(), faultString, locale);
}
public SoapFault addVersionMismatchFault(String faultString, Locale locale) {
return addFault(SoapVersion.SOAP_12.getVersionMismatchFaultName(), faultString, locale);
}
public Soap12Fault addDataEncodingUnknownFault(QName[] subcodes, String reason, Locale locale) {
QName name = new QName(SoapVersion.SOAP_12.getEnvelopeNamespaceUri(), "DataEncodingUnknown");
Soap12Fault fault = addFault(name, reason, locale);
for (int i = 0; i < subcodes.length; i++) {
fault.addFaultSubcode(subcodes[i]);
}
return fault;
}
protected Soap12Fault addFault(QName faultCode, String faultString, Locale faultStringLocale) {
Assert.notNull(faultCode, "No faultCode given");
Assert.hasLength(faultString, "faultString cannot be empty");
Assert.hasLength(faultCode.getLocalPart(), "faultCode's localPart cannot be empty");
Assert.hasLength(faultCode.getNamespaceURI(), "faultCode's namespaceUri cannot be empty");
try {
getImplementation().removeContents(getSaajBody());
SOAPFault saajFault =
getImplementation().addFault(getSaajBody(), faultCode, faultString, faultStringLocale);
return new SaajSoap12Fault(saajFault);
}
catch (SOAPException ex) {
throw new SaajSoapFaultException(ex);
}
}
}

View File

@@ -14,55 +14,32 @@
* limitations under the License.
*/
package org.springframework.ws.soap.saaj.saaj13;
package org.springframework.ws.soap.saaj;
import java.util.Iterator;
import java.util.Locale;
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.ws.soap.SoapFaultDetail;
import org.springframework.ws.soap.saaj.SaajSoapFaultException;
import org.springframework.ws.soap.soap12.Soap12Fault;
/**
* Internal class that uses SAAJ 1.3 to implement the <code>Soap12Fault</code> interface.
*
* @author Arjen Poutsma
*/
class Saaj13Soap12Fault implements Soap12Fault {
class SaajSoap12Fault extends SaajSoapFault implements Soap12Fault {
private final SOAPFault saajFault;
Saaj13Soap12Fault(SOAPFault saajFault) {
this.saajFault = saajFault;
public SaajSoap12Fault(SOAPFault fault) {
super(fault);
}
public QName getName() {
return saajFault.getElementQName();
public String getFaultActorOrRole() {
return getImplementation().getFaultRole(getSaajFault());
}
public Source getSource() {
return new DOMSource(saajFault);
}
public QName getFaultCode() {
return saajFault.getFaultCodeAsQName();
}
public SoapFaultDetail getFaultDetail() {
Detail saajDetail = saajFault.getDetail();
return saajDetail != null ? new Saaj13SoapFaultDetail(saajDetail) : null;
}
public SoapFaultDetail addFaultDetail() {
public void setFaultActorOrRole(String faultRole) {
try {
Detail saajDetail = saajFault.addDetail();
return saajDetail != null ? new Saaj13SoapFaultDetail(saajDetail) : null;
getImplementation().setFaultRole(getSaajFault(), faultRole);
}
catch (SOAPException ex) {
throw new SaajSoapFaultException(ex);
@@ -70,25 +47,12 @@ class Saaj13Soap12Fault implements Soap12Fault {
}
public Iterator getFaultSubcodes() {
return saajFault.getFaultSubcodes();
return getImplementation().getFaultSubcodes(getSaajFault());
}
public void addFaultSubcode(QName subcode) {
try {
saajFault.appendFaultSubcode(subcode);
}
catch (SOAPException ex) {
throw new SaajSoapFaultException(ex);
}
}
public String getFaultActorOrRole() {
return saajFault.getFaultRole();
}
public void setFaultActorOrRole(String uri) {
try {
saajFault.setFaultRole(uri);
getImplementation().appendFaultSubcode(getSaajFault(), subcode);
}
catch (SOAPException ex) {
throw new SaajSoapFaultException(ex);
@@ -96,33 +60,36 @@ class Saaj13Soap12Fault implements Soap12Fault {
}
public String getFaultNode() {
return saajFault.getFaultNode();
return getImplementation().getFaultNode(getSaajFault());
}
public void setFaultNode(String uri) {
try {
saajFault.setFaultNode(uri);
getImplementation().setFaultNode(getSaajFault(), uri);
}
catch (SOAPException ex) {
throw new SaajSoapFaultException(ex);
}
}
public void setFaultReasonText(Locale locale, String text) {
try {
saajFault.addFaultReasonText(text, locale);
getImplementation().setFaultReasonText(getSaajFault(), locale, text);
}
catch (SOAPException ex) {
throw new SaajSoapFaultException(ex);
}
}
public String getFaultReasonText(Locale locale) {
try {
return saajFault.getFaultReasonText(locale);
return getImplementation().getFaultReasonText(getSaajFault(), locale);
}
catch (SOAPException ex) {
throw new SaajSoapFaultException(ex);
}
}
}

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.ws.soap.saaj.saaj13;
package org.springframework.ws.soap.saaj;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPException;
@@ -22,24 +22,24 @@ import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPHeaderElement;
import org.springframework.ws.soap.SoapHeaderElement;
import org.springframework.ws.soap.saaj.SaajSoapHeaderException;
import org.springframework.ws.soap.soap12.Soap12Header;
/**
* Internal class that uses SAAJ 1.3 to implement the <code>Soap12Header</code> interface.
* SAAJ-specific implementation of the <code>Soap12Header</code> interface. Wraps a {@link javax.xml.soap.SOAPHeader}.
*
* @author Arjen Poutsma
*/
class Saaj13Soap12Header extends Saaj13SoapHeader implements Soap12Header {
class SaajSoap12Header extends SaajSoapHeader implements Soap12Header {
Saaj13Soap12Header(SOAPHeader saajHeader) {
super(saajHeader);
SaajSoap12Header(SOAPHeader header) {
super(header);
}
public SoapHeaderElement addNotUnderstoodHeaderElement(QName headerName) {
try {
SOAPHeaderElement saajHeaderElement = getSaajHeader().addNotUnderstoodHeaderElement(headerName);
return new Saaj13SoapHeaderElement(saajHeaderElement);
SOAPHeaderElement headerElement =
getImplementation().addNotUnderstoodHeaderElement(getSaajHeader(), headerName);
return new SaajSoapHeaderElement(headerElement);
}
catch (SOAPException ex) {
throw new SaajSoapHeaderException(ex);
@@ -48,8 +48,9 @@ class Saaj13Soap12Header extends Saaj13SoapHeader implements Soap12Header {
public SoapHeaderElement addUpgradeHeaderElement(String[] supportedSoapUris) {
try {
SOAPHeaderElement saajHeaderElement = getSaajHeader().addUpgradeHeaderElement(supportedSoapUris);
return new Saaj13SoapHeaderElement(saajHeaderElement);
SOAPHeaderElement headerElement =
getImplementation().addUpgradeHeaderElement(getSaajHeader(), supportedSoapUris);
return new SaajSoapHeaderElement(headerElement);
}
catch (SOAPException ex) {
throw new SaajSoapHeaderException(ex);

View File

@@ -0,0 +1,55 @@
/*
* 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 javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPBodyElement;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import org.springframework.ws.soap.SoapBody;
/**
* SAAJ-specific abstract base class of the <code>SoapBody</code> interface. Wraps a {@link javax.xml.soap.SOAPBody}.
*
* @author Arjen Poutsma
*/
abstract class SaajSoapBody extends SaajSoapElement implements SoapBody {
public SaajSoapBody(SOAPBody body) {
super(body);
}
public Source getPayloadSource() {
SOAPBodyElement bodyElement = getImplementation().getFirstBodyElement(getSaajBody());
return bodyElement == null ? null : getImplementation().getSource(bodyElement);
}
public Result getPayloadResult() {
getImplementation().removeContents(getSaajBody());
return getImplementation().getResult(getSaajBody());
}
public boolean hasFault() {
return getImplementation().hasFault(getSaajBody());
}
protected SOAPBody getSaajBody() {
return (SOAPBody) getSaajElement();
}
}

View File

@@ -14,35 +14,42 @@
* limitations under the License.
*/
package org.springframework.ws.soap.saaj.saaj12;
package org.springframework.ws.soap.saaj;
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 {
/**
* SAAJ-specific implementation of the <code>SoapElement</code> interface. Wraps a {@link javax.xml.soap.SOAPElement}.
*
* @author Arjen Poutsma
*/
class SaajSoapElement implements SoapElement {
private final SOAPElement saajElement;
private final SOAPElement element;
protected Saaj12SoapElement(SOAPElement saajElement) {
Assert.notNull(saajElement, "No saajElement given");
this.saajElement = saajElement;
public SaajSoapElement(SOAPElement element) {
Assert.notNull(element, "element must not be null");
this.element = element;
}
public Source getSource() {
return getImplementation().getSource(element);
}
public QName getName() {
return getImplementation().getName(element);
}
protected SOAPElement getSaajElement() {
return saajElement;
return element;
}
public final QName getName() {
return SaajUtils.toQName(saajElement.getElementName());
}
public final Source getSource() {
return new DOMSource(saajElement);
protected SaajImplementation getImplementation() {
return SaajImplementation.getImplementation();
}
}

View File

@@ -14,8 +14,9 @@
* limitations under the License.
*/
package org.springframework.ws.soap.saaj.saaj12;
package org.springframework.ws.soap.saaj;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPHeader;
@@ -23,29 +24,33 @@ 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.SaajSoapHeaderException;
/**
* Internal class that uses SAAJ 1.2 to implement the <code>SoapEnvelope</code> interface. Used by
* <code>SaajSoapMessage</code>.
* SAAJ-specific implementation of the <code>SoapEnvelope</code> interface. Wraps a {@link
* javax.xml.soap.SOAPEnvelope}.
*
* @author Arjen Poutsma
*/
class Saaj12SoapEnvelope extends Saaj12SoapElement implements SoapEnvelope {
class SaajSoapEnvelope extends SaajSoapElement implements SoapEnvelope {
private Saaj12Soap11Body body;
private SaajSoapBody body;
private Saaj12SoapHeader header;
private SaajSoapHeader header;
public Saaj12SoapEnvelope(SOAPEnvelope saajEnvelope) {
super(saajEnvelope);
public SaajSoapEnvelope(SOAPEnvelope envelope) {
super(envelope);
}
public final SoapBody getBody() {
public SoapBody getBody() {
if (body == null) {
try {
body = new Saaj12Soap11Body(getSaajEnvelope().getBody());
SOAPBody saajBody = getImplementation().getBody(getSaajEnvelope());
if (getImplementation().isSoap11(saajBody)) {
body = new SaajSoap11Body(saajBody);
}
else {
body = new SaajSoap12Body(saajBody);
}
}
catch (SOAPException ex) {
throw new SaajSoapBodyException(ex);
@@ -54,12 +59,17 @@ class Saaj12SoapEnvelope extends Saaj12SoapElement implements SoapEnvelope {
return body;
}
public final SoapHeader getHeader() {
public SoapHeader getHeader() {
if (header == null) {
try {
SOAPHeader saajHeader = getSaajEnvelope().getHeader();
SOAPHeader saajHeader = getImplementation().getHeader(getSaajEnvelope());
if (saajHeader != null) {
header = new Saaj12SoapHeader(saajHeader);
if (getImplementation().isSoap11(saajHeader)) {
header = new SaajSoapHeader(saajHeader);
}
else {
header = new SaajSoap12Header(saajHeader);
}
}
else {
header = null;
@@ -75,4 +85,5 @@ class Saaj12SoapEnvelope extends Saaj12SoapElement implements SoapEnvelope {
protected SOAPEnvelope getSaajEnvelope() {
return (SOAPEnvelope) getSaajElement();
}
}

View File

@@ -0,0 +1,60 @@
/*
* 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 javax.xml.namespace.QName;
import javax.xml.soap.Detail;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFault;
import org.springframework.ws.soap.SoapFault;
import org.springframework.ws.soap.SoapFaultDetail;
/**
* SAAJ-specific abstract base class of the <code>SoapFault</code> interface. Wraps a {@link javax.xml.soap.SOAPFault}.
*
* @author Arjen Poutsma
*/
abstract class SaajSoapFault extends SaajSoapElement implements SoapFault {
protected SaajSoapFault(SOAPFault fault) {
super(fault);
}
public QName getFaultCode() {
return getImplementation().getFaultCode(getSaajFault());
}
protected SOAPFault getSaajFault() {
return (SOAPFault) getSaajElement();
}
public SoapFaultDetail getFaultDetail() {
Detail saajDetail = getImplementation().getFaultDetail(getSaajFault());
return saajDetail == null ? null : new SaajSoapFaultDetail(saajDetail);
}
public SoapFaultDetail addFaultDetail() {
try {
Detail saajDetail = getImplementation().addFaultDetail(getSaajFault());
return new SaajSoapFaultDetail(saajDetail);
}
catch (SOAPException ex) {
throw new SaajSoapFaultException(ex);
}
}
}

View File

@@ -14,39 +14,40 @@
* limitations under the License.
*/
package org.springframework.ws.soap.saaj.saaj12;
package org.springframework.ws.soap.saaj;
import java.util.Iterator;
import javax.xml.namespace.QName;
import javax.xml.soap.Detail;
import javax.xml.soap.DetailEntry;
import javax.xml.soap.Name;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFaultElement;
import javax.xml.transform.Result;
import javax.xml.transform.dom.DOMResult;
import org.springframework.util.Assert;
import org.springframework.ws.soap.SoapFaultDetail;
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>SoapFaultDetail</code> interface.
* SAAJ-specific implementation of the <code>SoapFaultDetail</code> interface. Wraps a {@link
* javax.xml.soap.SOAPFaultElement}.
*
* @author Arjen Poutsma
*/
class Saaj12SoapFaultDetail extends Saaj12SoapElement implements SoapFaultDetail {
class SaajSoapFaultDetail extends SaajSoapElement implements SoapFaultDetail {
Saaj12SoapFaultDetail(Detail saajDetail) {
super(saajDetail);
public SaajSoapFaultDetail(SOAPFaultElement faultElement) {
super(faultElement);
}
public Result getResult() {
return getImplementation().getResult(getSaajDetail());
}
public SoapFaultDetailElement addFaultDetailElement(QName name) {
try {
Name detailEntryName = SaajUtils.toName(name, getSaajDetail());
DetailEntry saajDetailEntry = getSaajDetail().addDetailEntry(detailEntryName);
return new Saaj12SoapFaultDetailElement(saajDetailEntry);
DetailEntry detailEntry = getImplementation().addDetailEntry(getSaajDetail(), name);
return new SaajSoapFaultDetailElement(detailEntry);
}
catch (SOAPException ex) {
throw new SaajSoapFaultException(ex);
@@ -54,37 +55,36 @@ class Saaj12SoapFaultDetail extends Saaj12SoapElement implements SoapFaultDetail
}
public Iterator getDetailEntries() {
return new Saaj12SoapFaultDetailIterator(getSaajDetail().getDetailEntries());
Iterator iterator = getImplementation().getDetailEntries(getSaajDetail());
return new SaajSoapFaultDetailElementIterator(iterator);
}
public Result getResult() {
return new DOMResult(getSaajDetail());
}
private Detail getSaajDetail() {
protected Detail getSaajDetail() {
return (Detail) getSaajElement();
}
private static class Saaj12SoapFaultDetailIterator implements Iterator {
private static class SaajSoapFaultDetailElementIterator implements Iterator {
private final Iterator saajIterator;
private final Iterator iterator;
public Saaj12SoapFaultDetailIterator(Iterator saajIterator) {
Assert.notNull(saajIterator, "No saajIterator given");
this.saajIterator = saajIterator;
private SaajSoapFaultDetailElementIterator(Iterator iterator) {
Assert.notNull(iterator, "No iterator given");
this.iterator = iterator;
}
public boolean hasNext() {
return saajIterator.hasNext();
return iterator.hasNext();
}
public Object next() {
DetailEntry saajDetailEntry = (DetailEntry) saajIterator.next();
return new Saaj12SoapFaultDetailElement(saajDetailEntry);
DetailEntry saajDetailEntry = (DetailEntry) iterator.next();
return new SaajSoapFaultDetailElement(saajDetailEntry);
}
public void remove() {
saajIterator.remove();
iterator.remove();
}
}
}

View File

@@ -14,42 +14,41 @@
* limitations under the License.
*/
package org.springframework.ws.soap.saaj.saaj12;
package org.springframework.ws.soap.saaj;
import javax.xml.soap.DetailEntry;
import javax.xml.soap.SOAPException;
import javax.xml.transform.Result;
import javax.xml.transform.dom.DOMResult;
import org.springframework.ws.soap.SoapFaultDetailElement;
import org.springframework.ws.soap.saaj.SaajSoapFaultException;
/**
* Internal class that uses SAAJ 1.2 to implement the <code>SoapFaultDetailElement</code> interface.
* SAAJ-specific implementation of the <code>SoapFaultDetailElement</code> interface. Wraps a {@link
* javax.xml.soap.DetailEntry}.
*
* @author Arjen Poutsma
*/
class Saaj12SoapFaultDetailElement extends Saaj12SoapElement implements SoapFaultDetailElement {
class SaajSoapFaultDetailElement extends SaajSoapElement implements SoapFaultDetailElement {
Saaj12SoapFaultDetailElement(DetailEntry saajDetailEntry) {
super(saajDetailEntry);
SaajSoapFaultDetailElement(DetailEntry entry) {
super(entry);
}
public Result getResult() {
return new DOMResult(getSaajDetailEntry());
}
private DetailEntry getSaajDetailEntry() {
return (DetailEntry) getSaajElement();
return getImplementation().getResult(getSaajDetailEntry());
}
public void addText(String text) {
try {
getSaajDetailEntry().addTextNode(text);
getImplementation().addTextNode(getSaajDetailEntry(), text);
}
catch (SOAPException ex) {
throw new SaajSoapFaultException(ex);
}
}
protected DetailEntry getSaajDetailEntry() {
return (DetailEntry) getSaajElement();
}
}

View File

@@ -0,0 +1,88 @@
/*
* 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.util.Iterator;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPHeaderElement;
import org.springframework.util.Assert;
import org.springframework.ws.soap.SoapHeader;
import org.springframework.ws.soap.SoapHeaderElement;
import org.springframework.ws.soap.SoapHeaderException;
/**
* SAAJ-specific implementation of the <code>SoapHeader</code> interface. Wraps a {@link javax.xml.soap.SOAPHeader}.
*
* @author Arjen Poutsma
*/
class SaajSoapHeader extends SaajSoapElement implements SoapHeader {
SaajSoapHeader(SOAPHeader header) {
super(header);
}
public Iterator examineAllHeaderElements() throws SoapHeaderException {
Iterator iterator = getImplementation().examineAllHeaderElements(getSaajHeader());
return new SaajSoapHeaderElementIterator(iterator);
}
public Iterator examineMustUnderstandHeaderElements(String actorOrRole) throws SoapHeaderException {
Iterator iterator = getImplementation().examineMustUnderstandHeaderElements(getSaajHeader(), actorOrRole);
return new SaajSoapHeaderElementIterator(iterator);
}
public SoapHeaderElement addHeaderElement(QName name) throws SoapHeaderException {
try {
SOAPHeaderElement headerElement = getImplementation().addHeaderElement(getSaajHeader(), name);
return new SaajSoapHeaderElement(headerElement);
}
catch (SOAPException ex) {
throw new SaajSoapHeaderException(ex);
}
}
protected SOAPHeader getSaajHeader() {
return (SOAPHeader) getSaajElement();
}
private static class SaajSoapHeaderElementIterator implements Iterator {
private final Iterator iterator;
private SaajSoapHeaderElementIterator(Iterator iterator) {
Assert.notNull(iterator, "iterator must not be null");
this.iterator = iterator;
}
public boolean hasNext() {
return iterator.hasNext();
}
public Object next() {
SOAPHeaderElement saajHeaderElement = (SOAPHeaderElement) iterator.next();
return new SaajSoapHeaderElement(saajHeaderElement);
}
public void remove() {
iterator.remove();
}
}
}

View File

@@ -0,0 +1,61 @@
/*
* 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 javax.xml.soap.SOAPHeaderElement;
import javax.xml.transform.Result;
import org.springframework.ws.soap.SoapHeaderElement;
import org.springframework.ws.soap.SoapHeaderException;
/**
* SAAJ-specific implementation of the <code>SoapHeaderElement</code> interface. Wraps a {@link
* javax.xml.soap.SOAPHeaderElement}.
*
* @author Arjen Poutsma
*/
class SaajSoapHeaderElement extends SaajSoapElement implements SoapHeaderElement {
SaajSoapHeaderElement(SOAPHeaderElement headerElement) {
super(headerElement);
}
public Result getResult() throws SoapHeaderException {
return getImplementation().getResult(getSaajElement());
}
public String getActorOrRole() throws SoapHeaderException {
return getImplementation().getActorOrRole(getSaajHeaderElement());
}
public void setActorOrRole(String actorOrRole) throws SoapHeaderException {
getImplementation().setActorOrRole(getSaajHeaderElement(), actorOrRole);
}
public boolean getMustUnderstand() throws SoapHeaderException {
return getImplementation().getMustUnderstand(getSaajHeaderElement());
}
public void setMustUnderstand(boolean mustUnderstand) throws SoapHeaderException {
getImplementation().setMustUnderstand(getSaajHeaderElement(), mustUnderstand);
}
protected SOAPHeaderElement getSaajHeaderElement() {
return (SOAPHeaderElement) getSaajElement();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2005, 2006 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.
@@ -16,17 +16,13 @@
package org.springframework.ws.soap.saaj;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Iterator;
import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.activation.FileDataSource;
import javax.xml.soap.AttachmentPart;
import javax.xml.soap.MimeHeader;
import javax.xml.soap.MimeHeaders;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
@@ -35,12 +31,10 @@ import javax.xml.soap.SOAPMessage;
import org.springframework.core.io.InputStreamSource;
import org.springframework.core.io.Resource;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
import org.springframework.ws.soap.AbstractSoapMessage;
import org.springframework.ws.soap.Attachment;
import org.springframework.ws.soap.AttachmentException;
import org.springframework.ws.soap.SoapEnvelope;
import org.springframework.ws.transport.TransportOutputStream;
/**
* SAAJ-specific implementation of the <code>SoapMessage</code> interface. Accessed via the
@@ -49,7 +43,7 @@ import org.springframework.ws.transport.TransportOutputStream;
* @author Arjen Poutsma
* @see javax.xml.soap.SOAPMessage
*/
public abstract class SaajSoapMessage extends AbstractSoapMessage {
public class SaajSoapMessage extends AbstractSoapMessage {
private SOAPMessage saajMessage;
@@ -60,7 +54,7 @@ public abstract class SaajSoapMessage extends AbstractSoapMessage {
*
* @param soapMessage the SAAJ SOAPMessage
*/
protected SaajSoapMessage(SOAPMessage soapMessage) {
public SaajSoapMessage(SOAPMessage soapMessage) {
Assert.notNull(soapMessage, "soapMessage must not be null");
saajMessage = soapMessage;
}
@@ -68,23 +62,23 @@ public abstract class SaajSoapMessage extends AbstractSoapMessage {
/**
* Return the SAAJ <code>SOAPMessage</code> that this <code>SaajSoapMessage</code> is based on.
*/
public final SOAPMessage getSaajMessage() {
public SOAPMessage getSaajMessage() {
return saajMessage;
}
/**
* Sets the SAAJ <code>SOAPMessage</code> that this <code>SaajSoapMessage</code> is based on.
*/
public final void setSaajMessage(SOAPMessage soapMessage) {
public void setSaajMessage(SOAPMessage soapMessage) {
Assert.notNull(soapMessage, "soapMessage must not be null");
saajMessage = soapMessage;
}
public final SoapEnvelope getEnvelope() {
public SoapEnvelope getEnvelope() {
if (envelope == null) {
try {
SOAPEnvelope saajEnvelope = saajMessage.getSOAPPart().getEnvelope();
envelope = createSaajSoapEnvelope(saajEnvelope);
SOAPEnvelope saajEnvelope = getImplementation().getEnvelope(saajMessage);
envelope = new SaajSoapEnvelope(saajEnvelope);
}
catch (SOAPException ex) {
throw new SaajSoapEnvelopeException(ex);
@@ -93,39 +87,24 @@ public abstract class SaajSoapMessage extends AbstractSoapMessage {
return envelope;
}
protected abstract SoapEnvelope createSaajSoapEnvelope(SOAPEnvelope saajEnvelope);
public final void writeTo(OutputStream outputStream) throws IOException {
public void writeTo(OutputStream outputStream) throws IOException {
try {
if (saajMessage.saveRequired()) {
saajMessage.saveChanges();
}
if (outputStream instanceof TransportOutputStream) {
TransportOutputStream transportOutputStream = (TransportOutputStream) outputStream;
// some SAAJ implementations (Axis 1) do not have a Content-Type header by default
MimeHeaders headers = saajMessage.getMimeHeaders();
if (ObjectUtils.isEmpty(headers.getHeader("Content-Type"))) {
headers.addHeader("Content-Type", getVersion().getContentType());
if (saajMessage.saveRequired()) {
saajMessage.saveChanges();
}
}
for (Iterator iterator = headers.getAllHeaders(); iterator.hasNext();) {
MimeHeader mimeHeader = (MimeHeader) iterator.next();
transportOutputStream.addHeader(mimeHeader.getName(), mimeHeader.getValue());
}
}
saajMessage.writeTo(outputStream);
getImplementation().writeTo(saajMessage, outputStream);
}
catch (SOAPException ex) {
throw new SaajSoapMessageException("Could not write message to OutputStream: " + ex.getMessage(), ex);
}
}
public Iterator getAttachments() throws AttachmentException {
Iterator iterator = getImplementation().getAttachments(saajMessage);
return new SaajAttachmentIterator(iterator);
}
public Attachment getAttachment(String contentId) {
MimeHeaders mimeHeaders = new MimeHeaders();
mimeHeaders.addHeader("Content-Id", contentId);
Iterator iterator = saajMessage.getAttachments(mimeHeaders);
Iterator iterator = getImplementation().getAttachment(saajMessage, mimeHeaders);
if (!iterator.hasNext()) {
return null;
}
@@ -135,17 +114,11 @@ public abstract class SaajSoapMessage extends AbstractSoapMessage {
}
}
public Iterator getAttachments() {
Iterator saajAttachmentIterator = saajMessage.getAttachments();
return new SaajAttachmentIterator(saajAttachmentIterator);
}
public Attachment addAttachment(File file) throws AttachmentException {
Assert.notNull(file, "File must not be null");
FileDataSource dataSource = new FileDataSource(file);
AttachmentPart saajAttachment = saajMessage.createAttachmentPart(new DataHandler(dataSource));
saajMessage.addAttachmentPart(saajAttachment);
return new SaajAttachment(saajAttachment);
DataSource dataSource = new FileDataSource(file);
AttachmentPart attachmentPart = getImplementation().addAttachmentPart(saajMessage, dataSource);
return new SaajAttachment(attachmentPart);
}
public Attachment addAttachment(InputStreamSource inputStreamSource, String contentType) {
@@ -154,82 +127,13 @@ public abstract class SaajSoapMessage extends AbstractSoapMessage {
throw new IllegalArgumentException("Passed-in Resource contains an open stream: invalid argument. " +
"SAAJ requires an InputStreamSource that creates a fresh stream for every call.");
}
DataSource dataSource = createDataSource(inputStreamSource, contentType);
AttachmentPart saajAttachment = saajMessage.createAttachmentPart(new DataHandler(dataSource));
saajMessage.addAttachmentPart(saajAttachment);
DataSource dataSource = new InputStreamSourceDataSource(inputStreamSource, contentType);
AttachmentPart saajAttachment = getImplementation().addAttachmentPart(saajMessage, dataSource);
return new SaajAttachment(saajAttachment);
}
/**
* Create an Activation Framework DataSource for the given InputStreamSource.
*
* @param inputStreamSource the InputStreamSource (typically a Spring Resource)
* @param contentType the content type
* @return the Activation Framework DataSource
*/
private DataSource createDataSource(final InputStreamSource inputStreamSource, final String contentType) {
return new DataSource() {
public InputStream getInputStream() throws IOException {
return inputStreamSource.getInputStream();
}
public OutputStream getOutputStream() {
throw new UnsupportedOperationException("Read-only javax.activation.DataSource");
}
public String getContentType() {
return contentType;
}
public String getName() {
throw new UnsupportedOperationException("DataSource name not available");
}
};
}
/**
* SAAJ-specific implementation of <code>org.springframework.ws.soap.Attachment</code>
*/
private static class SaajAttachment implements Attachment {
private final AttachmentPart saajAttachment;
public SaajAttachment(AttachmentPart saajAttachment) {
this.saajAttachment = saajAttachment;
}
public String getId() {
return saajAttachment.getContentId();
}
public void setId(String id) {
saajAttachment.setContentId(id);
}
public String getContentType() {
return saajAttachment.getContentType();
}
public InputStream getInputStream() throws IOException {
try {
return saajAttachment.getDataHandler().getInputStream();
}
catch (SOAPException e) {
return new ByteArrayInputStream(new byte[0]);
}
}
public long getSize() {
try {
int result = saajAttachment.getSize();
// SAAJ returns -1 when the size cannot be determined
return result != -1 ? result : 0;
}
catch (SOAPException ex) {
throw new SaajAttachmentException(ex);
}
}
protected SaajImplementation getImplementation() {
return SaajImplementation.getImplementation();
}
private static class SaajAttachmentIterator implements Iterator {
@@ -254,5 +158,4 @@ public abstract class SaajSoapMessage extends AbstractSoapMessage {
}
}
}

View File

@@ -24,7 +24,6 @@ import javax.xml.soap.MessageFactory;
import javax.xml.soap.MimeHeaders;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -33,8 +32,6 @@ import org.springframework.util.StringUtils;
import org.springframework.ws.WebServiceMessage;
import org.springframework.ws.WebServiceMessageFactory;
import org.springframework.ws.soap.SoapMessageCreationException;
import org.springframework.ws.soap.saaj.saaj12.Saaj12SoapMessage;
import org.springframework.ws.soap.saaj.saaj13.Saaj13SoapMessage;
import org.springframework.ws.soap.saaj.support.SaajUtils;
import org.springframework.ws.transport.TransportInputStream;
@@ -66,6 +63,13 @@ public class SaajSoapMessageFactory implements WebServiceMessageFactory, Initial
this.messageFactory = messageFactory;
}
/**
* Sets the SAAJ <code>MessageFactory</code>.
*/
public void setMessageFactory(MessageFactory messageFactory) {
this.messageFactory = messageFactory;
}
/**
* Returns the SAAJ <code>MessageFactory</code> used.
*/
@@ -95,7 +99,7 @@ public class SaajSoapMessageFactory implements WebServiceMessageFactory, Initial
}
else {
throw new IllegalStateException(
"SaajSoapMessageContextFactory requires SAAJ 1.2, which was not" + "found on the classpath");
"SaajSoapMessageFactory requires SAAJ 1.2, which was not" + "found on the classpath");
}
}
catch (SOAPException ex) {
@@ -105,7 +109,7 @@ public class SaajSoapMessageFactory implements WebServiceMessageFactory, Initial
public WebServiceMessage createWebServiceMessage() {
try {
return createSaajSoapMessage(messageFactory.createMessage());
return new SaajSoapMessage(messageFactory.createMessage());
}
catch (SOAPException ex) {
throw new SoapMessageCreationException("Could not create empty message: " + ex.getMessage(), ex);
@@ -128,26 +132,13 @@ public class SaajSoapMessageFactory implements WebServiceMessageFactory, Initial
}
}
try {
return createSaajSoapMessage(messageFactory.createMessage(mimeHeaders, inputStream));
return new SaajSoapMessage(messageFactory.createMessage(mimeHeaders, inputStream));
}
catch (SOAPException ex) {
throw new SoapMessageCreationException("Could not create message from InputStream: " + ex.getMessage(), ex);
}
}
private WebServiceMessage createSaajSoapMessage(SOAPMessage requestMessage) {
if (SaajUtils.getSaajVersion() >= SaajUtils.SAAJ_13) {
return new Saaj13SoapMessage(requestMessage);
}
else if (SaajUtils.getSaajVersion() == SaajUtils.SAAJ_12) {
return new Saaj12SoapMessage(requestMessage);
}
else {
throw new IllegalStateException(
"SaajSoapMessageContextFactory requires SAAJ 1.2, which was not" + "found on the classpath");
}
}
/**
* Sets the protocol for the <code>MessageFactory</code>. Only used for SAAJ 1.3+, defaults to
* <code>SOAPConstants.DEFAULT_SOAP_PROTOCOL</code> (i.e. SOAP 1.1).

View File

@@ -1,153 +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.saaj12;
import java.util.Iterator;
import java.util.Locale;
import javax.xml.namespace.QName;
import javax.xml.soap.Name;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPBodyElement;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFault;
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.util.StringUtils;
import org.springframework.ws.soap.SoapFault;
import org.springframework.ws.soap.saaj.SaajSoapFaultException;
import org.springframework.ws.soap.saaj.support.SaajUtils;
import org.springframework.ws.soap.soap11.Soap11Body;
import org.springframework.ws.soap.soap11.Soap11Fault;
/**
* Internal class that uses SAAJ 1.2 to implement the <code>Soap11Body</code> interface.
*
* @author Arjen Poutsma
*/
class Saaj12Soap11Body extends Saaj12SoapElement implements Soap11Body {
Saaj12Soap11Body(SOAPBody saajBody) {
super(saajBody);
}
public Soap11Fault addFault(QName faultCode, String faultString, Locale faultStringLocale) {
Assert.notNull(faultCode, "No faultCode given");
Assert.hasLength(faultString, "faultString cannot be empty");
if (!StringUtils.hasLength(faultCode.getNamespaceURI())) {
throw new IllegalArgumentException(
"A fault code with namespace and local part must be specific for a custom fault code");
}
try {
Name name = SaajUtils.toName(faultCode, getSaajBody());
getSaajBody().removeContents();
SOAPFault saajFault;
if (faultStringLocale == null) {
saajFault = getSaajBody().addFault(name, faultString);
}
else {
saajFault = getSaajBody().addFault(name, faultString, faultStringLocale);
}
return new Saaj12Soap11Fault(saajFault);
}
catch (SOAPException ex) {
throw new SaajSoapFaultException(ex);
}
}
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);
}
public SoapFault addVersionMismatchFault(String faultString, Locale locale) {
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, getSaajBody().getElementName().getPrefix(),
getSaajBody().getElementName().getURI());
getSaajBody().removeContents();
SOAPFault saajFault;
if (locale == null) {
saajFault = getSaajBody().addFault(faultCode, faultString);
}
else {
saajFault = getSaajBody().addFault(faultCode, faultString, locale);
}
return new Saaj12Soap11Fault(saajFault);
}
catch (SOAPException ex) {
throw new SaajSoapFaultException(ex);
}
}
private SOAPEnvelope getEnvelope() {
return (SOAPEnvelope) getSaajBody().getParentElement();
}
/**
* Retrieves the payload of the wrapped SAAJ message as a single DOM element. The payload of a message is the
* contents of the SOAP body.
*
* @return the message payload, or <code>null</code> if none is set.
*/
private SOAPBodyElement getPayloadElement() {
for (Iterator iterator = getSaajBody().getChildElements(); iterator.hasNext();) {
Object child = iterator.next();
if (child instanceof SOAPBodyElement) {
return (SOAPBodyElement) child;
}
}
return null;
}
protected final SOAPBody getSaajBody() {
return (SOAPBody) getSaajElement();
}
}

View File

@@ -1,84 +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.saaj12;
import java.util.Locale;
import javax.xml.namespace.QName;
import javax.xml.soap.Detail;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFault;
import org.springframework.ws.soap.SoapFaultDetail;
import org.springframework.ws.soap.saaj.SaajSoapFaultException;
import org.springframework.ws.soap.saaj.support.SaajUtils;
import org.springframework.ws.soap.soap11.Soap11Fault;
/**
* Internal class that uses SAAJ 1.2 to implement the <code>Soap11Fault</code> interface.
*
* @author Arjen Poutsma
*/
class Saaj12Soap11Fault extends Saaj12SoapElement implements Soap11Fault {
Saaj12Soap11Fault(SOAPFault saajFault) {
super(saajFault);
}
public String getFaultString() {
return getSaajFault().getFaultString();
}
public Locale getFaultStringLocale() {
return getSaajFault().getFaultStringLocale();
}
public SoapFaultDetail addFaultDetail() {
try {
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

@@ -1,86 +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.saaj12;
import java.util.Iterator;
import javax.xml.namespace.QName;
import javax.xml.soap.Name;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPHeaderElement;
import org.springframework.ws.soap.SoapHeader;
import org.springframework.ws.soap.SoapHeaderElement;
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>SoapHeader</code> interface.
*
* @author Arjen Poutsma
*/
class Saaj12SoapHeader extends Saaj12SoapElement implements SoapHeader {
Saaj12SoapHeader(SOAPHeader saajHeader) {
super(saajHeader);
}
public SoapHeaderElement addHeaderElement(QName name) {
try {
Name saajName = SaajUtils.toName(name, getSaajHeader());
SOAPHeaderElement saajHeaderElement = getSaajHeader().addHeaderElement(saajName);
return new Saaj12SoapHeaderElement(saajHeaderElement);
}
catch (SOAPException ex) {
throw new SaajSoapHeaderException(ex);
}
}
public Iterator examineAllHeaderElements() {
return new Saaj12SoapHeaderElementIterator(getSaajHeader().examineAllHeaderElements());
}
public Iterator examineMustUnderstandHeaderElements(String role) {
return new Saaj12SoapHeaderElementIterator(getSaajHeader().examineMustUnderstandHeaderElements(role));
}
private SOAPHeader getSaajHeader() {
return (SOAPHeader) getSaajElement();
}
private static class Saaj12SoapHeaderElementIterator implements Iterator {
private final Iterator saajIterator;
private Saaj12SoapHeaderElementIterator(Iterator saajIterator) {
this.saajIterator = saajIterator;
}
public boolean hasNext() {
return saajIterator.hasNext();
}
public Object next() {
SOAPHeaderElement saajHeaderElement = (SOAPHeaderElement) saajIterator.next();
return new Saaj12SoapHeaderElement(saajHeaderElement);
}
public void remove() {
saajIterator.remove();
}
}
}

View File

@@ -1,75 +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.saaj12;
import javax.xml.namespace.QName;
import javax.xml.soap.Name;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPHeaderElement;
import javax.xml.transform.Result;
import javax.xml.transform.dom.DOMResult;
import org.springframework.ws.soap.SoapHeaderElement;
import org.springframework.ws.soap.SoapHeaderException;
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>SoapHeaderElement</code> interface.
*
* @author Arjen Poutsma
*/
class Saaj12SoapHeaderElement extends Saaj12SoapElement implements SoapHeaderElement {
Saaj12SoapHeaderElement(SOAPHeaderElement saajHeaderElement) {
super(saajHeaderElement);
}
public String getActorOrRole() {
return getSaajHeaderElement().getActor();
}
public boolean getMustUnderstand() {
return getSaajHeaderElement().getMustUnderstand();
}
public Result getResult() {
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, getSaajHeaderElement());
getSaajHeaderElement().addAttribute(saajName, value);
}
catch (SOAPException ex) {
throw new SaajSoapHeaderException(ex);
}
}
private SOAPHeaderElement getSaajHeaderElement() {
return (SOAPHeaderElement) getSaajElement();
}
}

View File

@@ -1,45 +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.saaj12;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPMessage;
import org.springframework.ws.soap.SoapEnvelope;
import org.springframework.ws.soap.SoapVersion;
import org.springframework.ws.soap.saaj.SaajSoapMessage;
/**
* SAAJ 1.2 specific implementation of the <code>SoapMessage</code> interface.
*
* @author Arjen Poutsma
* @see javax.xml.soap.SOAPMessage
*/
public class Saaj12SoapMessage extends SaajSoapMessage {
public Saaj12SoapMessage(SOAPMessage soapMessage) {
super(soapMessage);
}
protected SoapEnvelope createSaajSoapEnvelope(SOAPEnvelope saajEnvelope) {
return new Saaj12SoapEnvelope(saajEnvelope);
}
public SoapVersion getVersion() {
return SoapVersion.SOAP_11;
}
}

View File

@@ -1,5 +0,0 @@
<html>
<body>
SAAJ 1.2 support for Spring-WS soap message infrastructure.
</body>
</html>

View File

@@ -1,102 +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.saaj13;
import java.util.Locale;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFault;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.ws.soap.SoapFault;
import org.springframework.ws.soap.saaj.SaajSoapFaultException;
import org.springframework.ws.soap.soap11.Soap11Body;
import org.springframework.ws.soap.soap11.Soap11Fault;
import org.springframework.xml.namespace.QNameUtils;
/**
* Internal class that uses SAAJ 1.3 to implement the <code>Soap11Body</code> interface. Used by
* <code>Saaj13SoapEnvelope</code>.
*
* @author Arjen Poutsma
*/
class Saaj13Soap11Body extends Saaj13SoapBody implements Soap11Body {
Saaj13Soap11Body(SOAPBody saajBody) {
super(saajBody);
}
public Soap11Fault addFault(QName faultCode, String faultString, Locale faultStringLocale) {
Assert.notNull(faultCode, "No faultCode given");
Assert.notNull(faultString, "No faultString given");
if (!StringUtils.hasLength(faultCode.getNamespaceURI())) {
throw new IllegalArgumentException("fault code has no namespace");
}
try {
getSaajBody().removeContents();
SOAPFault saajFault;
if (faultStringLocale == null) {
saajFault = getSaajBody().addFault(faultCode, faultString);
}
else {
saajFault = getSaajBody().addFault(faultCode, faultString, faultStringLocale);
}
return new Saaj13Soap11Fault(saajFault);
}
catch (SOAPException ex) {
throw new SaajSoapFaultException(ex);
}
}
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 addServerOrReceiverFault(String faultString, Locale locale) {
return addStandardFault("Server", faultString, locale);
}
public SoapFault addVersionMismatchFault(String faultString, Locale locale) {
return addStandardFault("VersionMismatch", faultString, locale);
}
private Soap11Fault addStandardFault(String localName, String faultString, Locale faultStringLocale) {
try {
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) {
throw new SaajSoapFaultException(ex);
}
}
public SoapFault getFault() {
return new Saaj13Soap11Fault(getSaajBody().getFault());
}
}

View File

@@ -1,83 +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.saaj13;
import java.util.Locale;
import javax.xml.namespace.QName;
import javax.xml.soap.Detail;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFault;
import org.springframework.ws.soap.SoapFaultDetail;
import org.springframework.ws.soap.saaj.SaajSoapFaultException;
import org.springframework.ws.soap.soap11.Soap11Fault;
/**
* Internal class that uses SAAJ 1.3 to implement the <code>Soap11Fault</code> interface.
*
* @author Arjen Poutsma
*/
class Saaj13Soap11Fault extends Saaj13SoapElement implements Soap11Fault {
Saaj13Soap11Fault(SOAPFault saajFault) {
super(saajFault);
}
public String getFaultString() {
return getSaajFault().getFaultString();
}
public Locale getFaultStringLocale() {
return getSaajFault().getFaultStringLocale();
}
public SoapFaultDetail addFaultDetail() {
try {
Detail saajDetail = getSaajFault().addDetail();
return saajDetail != null ? new Saaj13SoapFaultDetail(saajDetail) : null;
}
catch (SOAPException ex) {
throw new SaajSoapFaultException(ex);
}
}
public String getFaultActorOrRole() {
return getSaajFault().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 {
getSaajFault().setFaultActor(faultActor);
}
catch (SOAPException ex) {
throw new SaajSoapFaultException(ex);
}
}
private SOAPFault getSaajFault() {
return (SOAPFault) getSaajElement();
}
}

View File

@@ -1,86 +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.saaj13;
import java.util.Locale;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFault;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.ws.soap.SoapFault;
import org.springframework.ws.soap.saaj.SaajSoapFaultException;
import org.springframework.ws.soap.soap12.Soap12Body;
import org.springframework.ws.soap.soap12.Soap12Fault;
/**
* Internal class that uses SAAJ 1.3 to implement the <code>Soap12Body</code> interface. Used by
* <code>Saaj13SoapEnvelope</code>.
*
* @author Arjen Poutsma
*/
class Saaj13Soap12Body extends Saaj13SoapBody implements Soap12Body {
Saaj13Soap12Body(SOAPBody saajBody) {
super(saajBody);
}
private Soap12Fault addFault(QName code, String reason, Locale locale) {
Assert.notNull(code, "No code given");
Assert.hasLength(reason, "reason cannot be empty");
Assert.notNull(locale, "No locale given");
if (!StringUtils.hasLength(code.getNamespaceURI())) {
throw new IllegalArgumentException(
"A code with namespace and local part must be specific for a custom fault code");
}
try {
getSaajBody().removeContents();
SOAPFault saajFault = getSaajBody().addFault(code, reason, locale);
return new Saaj13Soap12Fault(saajFault);
}
catch (SOAPException ex) {
throw new SaajSoapFaultException(ex);
}
}
public SoapFault addMustUnderstandFault(String reason, Locale locale) {
return addFault(SOAPConstants.SOAP_MUSTUNDERSTAND_FAULT, reason, locale);
}
public SoapFault addClientOrSenderFault(String reason, Locale locale) {
return addFault(SOAPConstants.SOAP_SENDER_FAULT, reason, locale);
}
public SoapFault addServerOrReceiverFault(String reason, Locale reasonLocale) {
return addFault(SOAPConstants.SOAP_RECEIVER_FAULT, reason, reasonLocale);
}
public SoapFault addVersionMismatchFault(String reason, Locale locale) {
return addFault(SOAPConstants.SOAP_VERSIONMISMATCH_FAULT, reason, locale);
}
public Soap12Fault addDataEncodingUnknownFault(QName[] subcodes, String reason, Locale reasonLocale) {
return addFault(SOAPConstants.SOAP_DATAENCODINGUNKNOWN_FAULT, reason, reasonLocale);
}
public SoapFault getFault() {
return new Saaj13Soap12Fault(getSaajBody().getFault());
}
}

View File

@@ -1,74 +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.saaj13;
import java.util.Iterator;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPBodyElement;
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.ws.soap.SoapBody;
/**
* * Internal class that uses SAAJ 1.3 to implement the <code>SoapBody</code> interface. Used by
* <code>Saaj13SoapEnvelope</code>.
*
* @author Arjen Poutsma
*/
abstract class Saaj13SoapBody extends Saaj13SoapElement implements SoapBody {
protected Saaj13SoapBody(SOAPBody saajBody) {
super(saajBody);
}
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();
}
/**
* Retrieves the payload of the wrapped SAAJ message as a single DOM element. The payload of a message is the
* contents of the SOAP body.
*
* @return the message payload, or <code>null</code> if none is set.
*/
private SOAPBodyElement getPayloadElement() {
for (Iterator iterator = getSaajBody().getChildElements(); iterator.hasNext();) {
Object child = iterator.next();
if (child instanceof SOAPBodyElement) {
return (SOAPBodyElement) child;
}
}
return null;
}
protected final SOAPBody getSaajBody() {
return (SOAPBody) getSaajElement();
}
}

View File

@@ -1,46 +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.saaj13;
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;
abstract class Saaj13SoapElement {
private final SOAPElement saajElement;
protected Saaj13SoapElement(SOAPElement saajElement) {
Assert.notNull(saajElement, "No saajElement given");
this.saajElement = saajElement;
}
protected SOAPElement getSaajElement() {
return saajElement;
}
public final QName getName() {
return saajElement.getElementQName();
}
public final Source getSource() {
return new DOMSource(saajElement);
}
}

View File

@@ -1,110 +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.saaj13;
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.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.SaajSoapHeaderException;
/**
* Internal class that uses SAAJ 1.3 to implement the <code>SoapEnvelope</code> interface. Used by
* <code>SaajSoapMessage</code>.
*
* @author Arjen Poutsma
*/
class Saaj13SoapEnvelope extends Saaj13SoapElement implements SoapEnvelope {
private Saaj13SoapBody body;
private Saaj13SoapHeader header;
public Saaj13SoapEnvelope(SOAPEnvelope saajEnvelope) {
super(saajEnvelope);
}
public final SoapBody getBody() {
if (body == null) {
try {
SOAPBody saajBody = getSaajEnvelope().getBody();
Saaj13SoapBody result;
if (isSoap11()) {
result = new Saaj13Soap11Body(saajBody);
}
else {
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 {
header = new Saaj13Soap12Header(saajHeader);
}
}
else {
header = null;
}
}
catch (SOAPException ex) {
throw new SaajSoapHeaderException(ex);
}
}
return header;
}
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

@@ -1,127 +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.saaj13;
import java.util.Iterator;
import javax.xml.namespace.QName;
import javax.xml.soap.Detail;
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.SoapFaultDetail;
import org.springframework.ws.soap.SoapFaultDetailElement;
import org.springframework.ws.soap.saaj.SaajSoapFaultException;
/**
* @author Arjen Poutsma
*/
class Saaj13SoapFaultDetail implements SoapFaultDetail {
private Detail saajDetail;
Saaj13SoapFaultDetail(Detail saajDetail) {
Assert.notNull(saajDetail, "No saajDetail given");
this.saajDetail = saajDetail;
}
public QName getName() {
return saajDetail.getElementQName();
}
public Source getSource() {
return new DOMSource(saajDetail);
}
public Result getResult() {
return new DOMResult(saajDetail);
}
public SoapFaultDetailElement addFaultDetailElement(QName name) {
try {
DetailEntry saajDetailEntry = saajDetail.addDetailEntry(name);
return new Saaj13SoapFaultDetailElement(saajDetailEntry);
}
catch (SOAPException ex) {
throw new SaajSoapFaultException(ex);
}
}
public Iterator getDetailEntries() {
return new Saaj13SoapFaultDetailIterator(saajDetail.getDetailEntries());
}
private static class Saaj13SoapFaultDetailElement implements SoapFaultDetailElement {
private DetailEntry saajDetailEntry;
private Saaj13SoapFaultDetailElement(DetailEntry saajDetailEntry) {
Assert.notNull(saajDetailEntry, "No saajDetailEntry given");
this.saajDetailEntry = saajDetailEntry;
}
public Result getResult() {
return new DOMResult(saajDetailEntry);
}
public void addText(String text) {
try {
saajDetailEntry.addTextNode(text);
}
catch (SOAPException ex) {
throw new SaajSoapFaultException(ex);
}
}
public QName getName() {
return saajDetailEntry.getElementQName();
}
public Source getSource() {
return new DOMSource(saajDetailEntry);
}
}
private static class Saaj13SoapFaultDetailIterator implements Iterator {
private final Iterator saajIterator;
public Saaj13SoapFaultDetailIterator(Iterator saajIterator) {
Assert.notNull(saajIterator, "No saajIterator given");
this.saajIterator = saajIterator;
}
public boolean hasNext() {
return saajIterator.hasNext();
}
public Object next() {
DetailEntry saajDetailEntry = (DetailEntry) saajIterator.next();
return new Saaj13SoapFaultDetailElement(saajDetailEntry);
}
public void remove() {
saajIterator.remove();
}
}
}

View File

@@ -1,83 +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.saaj13;
import java.util.Iterator;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPHeaderElement;
import org.springframework.ws.soap.SoapHeader;
import org.springframework.ws.soap.SoapHeaderElement;
import org.springframework.ws.soap.saaj.SaajSoapHeaderException;
/**
* Internal class that uses SAAJ 1.3 to implement the <code>SoapHeader</code> interface.
*
* @author Arjen Poutsma
*/
class Saaj13SoapHeader extends Saaj13SoapElement implements SoapHeader {
Saaj13SoapHeader(SOAPHeader saajHeader) {
super(saajHeader);
}
protected final SOAPHeader getSaajHeader() {
return (SOAPHeader) getSaajElement();
}
public SoapHeaderElement addHeaderElement(QName name) {
try {
SOAPHeaderElement saajHeaderElement = getSaajHeader().addHeaderElement(name);
return new Saaj13SoapHeaderElement(saajHeaderElement);
}
catch (SOAPException ex) {
throw new SaajSoapHeaderException(ex);
}
}
public Iterator examineMustUnderstandHeaderElements(String role) {
return new SaajSoapHeaderElementIterator(getSaajHeader().examineMustUnderstandHeaderElements(role));
}
public Iterator examineAllHeaderElements() {
return new SaajSoapHeaderElementIterator(getSaajHeader().examineAllHeaderElements());
}
private static class SaajSoapHeaderElementIterator implements Iterator {
private final Iterator saajIterator;
private SaajSoapHeaderElementIterator(Iterator saajIterator) {
this.saajIterator = saajIterator;
}
public boolean hasNext() {
return saajIterator.hasNext();
}
public Object next() {
SOAPHeaderElement saajHeaderElement = (SOAPHeaderElement) saajIterator.next();
return new Saaj13SoapHeaderElement(saajHeaderElement);
}
public void remove() {
saajIterator.remove();
}
}
}

View File

@@ -1,83 +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.saaj13;
import javax.xml.namespace.QName;
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;
/**
* Internal class that uses SAAJ 1.3 to implement the <code>SoapHeaderElement</code> interface.
*
* @author Arjen Poutsma
*/
class Saaj13SoapHeaderElement implements SoapHeaderElement {
private final SOAPHeaderElement saajHeaderElement;
Saaj13SoapHeaderElement(SOAPHeaderElement saajHeaderElement) {
Assert.notNull(saajHeaderElement, "No saajHeaderElement given");
this.saajHeaderElement = saajHeaderElement;
}
public QName getName() {
return saajHeaderElement.getElementQName();
}
public Source getSource() {
return new DOMSource(saajHeaderElement);
}
public String getActorOrRole() {
return saajHeaderElement.getActor();
}
public void setActorOrRole(String role) {
saajHeaderElement.setActor(role);
}
public boolean getMustUnderstand() {
return saajHeaderElement.getMustUnderstand();
}
public void setMustUnderstand(boolean mustUnderstand) {
saajHeaderElement.setMustUnderstand(mustUnderstand);
}
public Result getResult() {
return new DOMResult(saajHeaderElement);
}
public void addAttribute(QName name, String value) throws SoapHeaderException {
try {
saajHeaderElement.addAttribute(name, value);
}
catch (SOAPException ex) {
throw new SaajSoapHeaderException(ex);
}
}
}

View File

@@ -1,44 +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.saaj13;
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.3 specific implementation of the <code>SoapMessage</code> interface.
*
* @author Arjen Poutsma
*/
public class Saaj13SoapMessage extends SaajSoapMessage {
/**
* Create a new <code>SaajSoapMessage</code> based on the given SAAJ <code>SOAPMessage</code>.
*
* @param soapMessage the SAAJ SOAPMessage
*/
public Saaj13SoapMessage(SOAPMessage soapMessage) {
super(soapMessage);
}
protected SoapEnvelope createSaajSoapEnvelope(SOAPEnvelope saajEnvelope) {
return new Saaj13SoapEnvelope(saajEnvelope);
}
}

View File

@@ -1,5 +0,0 @@
<html>
<body>
SAAJ 1.3 support for Spring-WS soap message infrastructure.
</body>
</html>