diff --git a/core/src/main/java/org/springframework/ws/soap/SoapFaultDetail.java b/core/src/main/java/org/springframework/ws/soap/SoapFaultDetail.java
index 4fb077dd..a21a72e0 100644
--- a/core/src/main/java/org/springframework/ws/soap/SoapFaultDetail.java
+++ b/core/src/main/java/org/springframework/ws/soap/SoapFaultDetail.java
@@ -38,7 +38,7 @@ public interface SoapFaultDetail extends SoapElement {
SoapFaultDetailElement addFaultDetailElement(QName name);
/**
- * Returns the Source of this element. This result does not include the element itself.
+ * Returns a Result that represents the concents of the detail.
*
Header element in a SOAP message. A SOAP header contains SoapHeaderElements,
@@ -29,6 +30,15 @@ import javax.xml.namespace.QName;
*/
public interface SoapHeader extends SoapElement {
+ /**
+ * Returns a Result that represents the concents of the header.
+ *
+ * The result can be used for marshalling.
+ *
+ * @return the Result of this element
+ */
+ Result getResult();
+
/**
* Adds a new SoapHeaderElement with the specified qualified name to this header.
*
diff --git a/core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapHeader.java b/core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapHeader.java
index b7d2f09a..73a596fe 100644
--- a/core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapHeader.java
+++ b/core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapHeader.java
@@ -18,7 +18,9 @@ package org.springframework.ws.soap.axiom;
import java.util.Iterator;
import javax.xml.namespace.QName;
+import javax.xml.transform.Result;
import javax.xml.transform.Source;
+import javax.xml.transform.sax.SAXResult;
import org.apache.axiom.om.OMException;
import org.apache.axiom.om.OMNamespace;
@@ -57,6 +59,10 @@ class AxiomSoapHeader implements SoapHeader {
return new StaxSource(axiomHeader.getXMLStreamReader());
}
+ public Result getResult() {
+ return new SAXResult(new AxiomContentHandler(axiomHeader));
+ }
+
public SoapHeaderElement addHeaderElement(QName name) {
try {
OMNamespace namespace = axiomFactory.createOMNamespace(name.getNamespaceURI(), QNameUtils.getPrefix(name));
diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/Saaj12Implementation.java b/core/src/main/java/org/springframework/ws/soap/saaj/Saaj12Implementation.java
index 185ba4ec..26757aff 100644
--- a/core/src/main/java/org/springframework/ws/soap/saaj/Saaj12Implementation.java
+++ b/core/src/main/java/org/springframework/ws/soap/saaj/Saaj12Implementation.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006 the original author or authors.
+ * Copyright 2007 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.
@@ -36,7 +36,7 @@ import org.springframework.ws.soap.saaj.support.SaajUtils;
*
* @author Arjen Poutsma
*/
-public class Saaj12Implementation extends SaajImplementation {
+class Saaj12Implementation extends SaajImplementation {
private static final Saaj12Implementation INSTANCE = new Saaj12Implementation();
diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/Saaj13Implementation.java b/core/src/main/java/org/springframework/ws/soap/saaj/Saaj13Implementation.java
index 2bd0396c..ea764467 100644
--- a/core/src/main/java/org/springframework/ws/soap/saaj/Saaj13Implementation.java
+++ b/core/src/main/java/org/springframework/ws/soap/saaj/Saaj13Implementation.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006 the original author or authors.
+ * Copyright 2007 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.
@@ -34,7 +34,7 @@ import javax.xml.soap.SOAPHeaderElement;
*
* @author Arjen Poutsma
*/
-public class Saaj13Implementation extends SaajImplementation {
+class Saaj13Implementation extends SaajImplementation {
private static final Saaj13Implementation INSTANCE = new Saaj13Implementation();
diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/SaajImplementation.java b/core/src/main/java/org/springframework/ws/soap/saaj/SaajImplementation.java
index f1d935b9..1b1f4dc0 100644
--- a/core/src/main/java/org/springframework/ws/soap/saaj/SaajImplementation.java
+++ b/core/src/main/java/org/springframework/ws/soap/saaj/SaajImplementation.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006 the original author or authors.
+ * Copyright 2007 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.
@@ -55,12 +55,11 @@ import org.springframework.ws.transport.TransportOutputStream;
*/
abstract class SaajImplementation {
+ /** Protected constructor to prevent instantiation. */
protected SaajImplementation() {
}
- /**
- * Returns the singleton instance for the version of SAAJ in use.
- */
+ /** Returns the singleton instance for the version of SAAJ in use. */
public static SaajImplementation getImplementation() {
if (SaajUtils.getSaajVersion() == SaajUtils.SAAJ_12) {
return Saaj12Implementation.getInstance();
@@ -73,58 +72,121 @@ abstract class SaajImplementation {
}
}
+ /** Returns the name of the given element. */
public abstract QName getName(SOAPElement element);
+ /** Returns the readable Source of the given element. */
public Source getSource(SOAPElement element) {
return new DOMSource(element);
}
+ /** Returns the writable Result of the given element. */
public Result getResult(SOAPElement element) {
return new DOMResult(element);
}
+ /** Returns the envelope of the given message. */
public SOAPEnvelope getEnvelope(SOAPMessage message) throws SOAPException {
return message.getSOAPPart().getEnvelope();
}
+ /** Returns the header of the given envelope. */
public SOAPHeader getHeader(SOAPEnvelope envelope) throws SOAPException {
return envelope.getHeader();
}
+ /** Returns the body of the given envelope. */
public SOAPBody getBody(SOAPEnvelope envelope) throws SOAPException {
return envelope.getBody();
}
+ /** Returns all header elements. */
+ public Iterator examineAllHeaderElements(SOAPHeader header) {
+ return header.examineAllHeaderElements();
+ }
+
+ /** Returns all header elements for which the must understand attribute is true, given the actor or role. */
+ public Iterator examineMustUnderstandHeaderElements(SOAPHeader header, String actorOrRole) {
+ return header.examineMustUnderstandHeaderElements(actorOrRole);
+ }
+
+ public abstract SOAPHeaderElement addHeaderElement(SOAPHeader header, QName name) throws SOAPException;
+
+ /** Returns the SOAP 1.1 actor or SOAP 1.2 role attribute for the given header element. */
public String getActorOrRole(SOAPHeaderElement headerElement) {
return headerElement.getActor();
}
+ /** Sets the SOAP 1.1 actor or SOAP 1.2 role attribute for the given header element. */
public void setActorOrRole(SOAPHeaderElement headerElement, String actorOrRole) {
headerElement.setActor(actorOrRole);
}
+ /** Gets the must understand attribute for the given header element. */
public boolean getMustUnderstand(SOAPHeaderElement headerElement) {
return headerElement.getMustUnderstand();
}
+ /** Sets the must understand attribute for the given header element. */
public void setMustUnderstand(SOAPHeaderElement headerElement, boolean mustUnderstand) {
headerElement.setMustUnderstand(mustUnderstand);
}
+ /** Returns true if the body has a fault, false otherwise. */
+ public boolean hasFault(SOAPBody body) {
+ return body.hasFault();
+ }
+
+ /** Returns the fault for the given body, if any. */
+ public SOAPFault getFault(SOAPBody body) {
+ return body.getFault();
+ }
+
+ /** Adds a fault to the given body. */
+ public abstract SOAPFault addFault(SOAPBody body, QName faultCode, String faultString, Locale locale)
+ throws SOAPException;
+
+ /** Returns the fault code for the given fault. */
public abstract QName getFaultCode(SOAPFault fault);
+ /** Returns the actor for the given fault. */
public String getFaultActor(SOAPFault fault) {
return fault.getFaultActor();
}
+ /** Sets the actor for the given fault. */
public void setFaultActor(SOAPFault fault, String actorOrRole) throws SOAPException {
fault.setFaultActor(actorOrRole);
}
+ /** Returns the fault string for the given fault. */
+ public String getFaultString(SOAPFault fault) {
+ return fault.getFaultString();
+ }
+
+ /** Returns the fault string language for the given fault. */
+ public Locale getFaultStringLocale(SOAPFault fault) {
+ return fault.getFaultStringLocale();
+ }
+
+ /** Returns the fault detail for the given fault. */
+ public Detail getFaultDetail(SOAPFault fault) {
+ return fault.getDetail();
+ }
+
+ /** Adds a fault detail for the given fault. */
+ public Detail addFaultDetail(SOAPFault fault) throws SOAPException {
+ return fault.addDetail();
+ }
+
+ /** Adds a detail entry to the given detail. */
+ public abstract DetailEntry addDetailEntry(Detail detail, QName name) throws SOAPException;
+
public void addTextNode(DetailEntry detailEntry, String text) throws SOAPException {
detailEntry.addTextNode(text);
}
+ /** Returns an iteration over all detail entries. */
public Iterator getDetailEntries(Detail detail) {
return detail.getDetailEntries();
}
@@ -139,32 +201,12 @@ abstract class SaajImplementation {
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;
@@ -174,22 +216,6 @@ abstract class SaajImplementation {
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;
@@ -202,9 +228,6 @@ abstract class SaajImplementation {
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();
diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap12Body.java b/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap12Body.java
index 96eec751..8d938d56 100644
--- a/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap12Body.java
+++ b/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap12Body.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006 the original author or authors.
+ * Copyright 2007 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.
diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap12Header.java b/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap12Header.java
index 493f7b9e..3aefdbdb 100644
--- a/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap12Header.java
+++ b/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap12Header.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006 the original author or authors.
+ * Copyright 2007 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.
diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapBody.java b/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapBody.java
index 596bbbed..65e058ac 100644
--- a/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapBody.java
+++ b/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapBody.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006 the original author or authors.
+ * Copyright 2007 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.
diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapFaultDetail.java b/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapFaultDetail.java
index 5ad966c2..3b9d351d 100644
--- a/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapFaultDetail.java
+++ b/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapFaultDetail.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006 the original author or authors.
+ * Copyright 2007 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.
diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapHeader.java b/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapHeader.java
index cbe6fd01..620358f1 100644
--- a/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapHeader.java
+++ b/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapHeader.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006 the original author or authors.
+ * Copyright 2007 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.
@@ -21,6 +21,7 @@ import javax.xml.namespace.QName;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPHeaderElement;
+import javax.xml.transform.Result;
import org.springframework.util.Assert;
import org.springframework.ws.soap.SoapHeader;
@@ -62,6 +63,10 @@ class SaajSoapHeader extends SaajSoapElement implements SoapHeader {
return (SOAPHeader) getSaajElement();
}
+ public Result getResult() {
+ return getImplementation().getResult(getSaajHeader());
+ }
+
private static class SaajSoapHeaderElementIterator implements Iterator {
private final Iterator iterator;
diff --git a/core/src/test/java/org/springframework/ws/soap/AbstractSoapHeaderTestCase.java b/core/src/test/java/org/springframework/ws/soap/AbstractSoapHeaderTestCase.java
index 070fc323..9ba3a509 100644
--- a/core/src/test/java/org/springframework/ws/soap/AbstractSoapHeaderTestCase.java
+++ b/core/src/test/java/org/springframework/ws/soap/AbstractSoapHeaderTestCase.java
@@ -89,12 +89,21 @@ public abstract class AbstractSoapHeaderTestCase extends XMLTestCase {
assertFalse("header element iterator has too many elements", iterator.hasNext());
}
+ public void testGetResult() throws Exception {
+ String content =
+ "