diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapMessage.java b/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapMessage.java
index ab3c0433..0a1de34f 100644
--- a/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapMessage.java
+++ b/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapMessage.java
@@ -27,7 +27,6 @@ import javax.activation.DataSource;
import javax.activation.FileDataSource;
import javax.xml.soap.AttachmentPart;
import javax.xml.soap.MimeHeaders;
-import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
@@ -73,18 +72,12 @@ public abstract class SaajSoapMessage extends AbstractSoapMessage {
public final SoapEnvelope getEnvelope() {
if (envelope == null) {
- try {
- SOAPEnvelope saajEnvelope = saajMessage.getSOAPPart().getEnvelope();
- envelope = createSaajSoapEnvelope(saajEnvelope);
- }
- catch (SOAPException ex) {
- throw new SaajSoapEnvelopeException(ex);
- }
+ envelope = createSaajSoapEnvelope(saajMessage);
}
return envelope;
}
- protected abstract SoapEnvelope createSaajSoapEnvelope(SOAPEnvelope saajEnvelope);
+ protected abstract SoapEnvelope createSaajSoapEnvelope(SOAPMessage saajMessage);
public final void writeTo(OutputStream outputStream) throws IOException {
try {
diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/saaj11/Saaj11Soap11Body.java b/core/src/main/java/org/springframework/ws/soap/saaj/saaj11/Saaj11Soap11Body.java
new file mode 100644
index 00000000..5eee5ebe
--- /dev/null
+++ b/core/src/main/java/org/springframework/ws/soap/saaj/saaj11/Saaj11Soap11Body.java
@@ -0,0 +1,150 @@
+/*
+ * 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.saaj11;
+
+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.SOAPElement;
+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.sax.SAXSource;
+
+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;
+import org.xml.sax.InputSource;
+
+class Saaj11Soap11Body extends Saaj11SoapElement implements Soap11Body {
+
+ public Saaj11Soap11Body(SOAPElement saajElement) {
+ super(saajElement);
+ }
+
+ 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(), getEnvelope());
+ getSaajBody().removeContents();
+ SOAPFault saajFault;
+ if (faultStringLocale == null) {
+ saajFault = getSaajBody().addFault(name, faultString);
+ }
+ else {
+ saajFault = getSaajBody().addFault(name, faultString, faultStringLocale);
+ }
+ return new Saaj11Soap11Fault(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 Saaj11Soap11Fault(getSaajBody().getFault());
+ }
+
+ public final Result getPayloadResult() {
+ getSaajBody().removeContents();
+ return new DOMResult(getSaajBody());
+ }
+
+ public final Source getPayloadSource() {
+ SOAPBodyElement payloadElement = getPayloadElement();
+ return payloadElement != null ? new SAXSource(new Saaj12XmlReader(payloadElement), new InputSource()) : 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 Saaj11Soap11Fault(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 null 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();
+ }
+}
diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/saaj11/Saaj11Soap11Fault.java b/core/src/main/java/org/springframework/ws/soap/saaj/saaj11/Saaj11Soap11Fault.java
new file mode 100644
index 00000000..c731da41
--- /dev/null
+++ b/core/src/main/java/org/springframework/ws/soap/saaj/saaj11/Saaj11Soap11Fault.java
@@ -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.saaj11;
+
+import java.util.Locale;
+import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPFault;
+import javax.xml.transform.Source;
+
+import org.springframework.ws.soap.SoapFaultDetail;
+import org.springframework.ws.soap.soap11.Soap11Fault;
+
+/**
+ * @author Arjen Poutsma
+ */
+public class Saaj11Soap11Fault implements Soap11Fault {
+
+ public Saaj11Soap11Fault(SOAPFault saajFault) {
+ }
+
+ public String getFaultString() {
+ //TODO implement
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public Locale getFaultStringLocale() {
+ //TODO implement
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public QName getFaultCode() {
+ //TODO implement
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public String getFaultActorOrRole() {
+ //TODO implement
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public void setFaultActorOrRole(String faultActor) {
+ //TODO implement
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public SoapFaultDetail getFaultDetail() {
+ //TODO implement
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public SoapFaultDetail addFaultDetail() {
+ //TODO implement
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public QName getName() {
+ //TODO implement
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public Source getSource() {
+ //TODO implement
+ throw new UnsupportedOperationException("Not implemented");
+ }
+}
diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/saaj11/Saaj11SoapElement.java b/core/src/main/java/org/springframework/ws/soap/saaj/saaj11/Saaj11SoapElement.java
new file mode 100644
index 00000000..acbdcc7d
--- /dev/null
+++ b/core/src/main/java/org/springframework/ws/soap/saaj/saaj11/Saaj11SoapElement.java
@@ -0,0 +1,50 @@
+/*
+ * 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.saaj11;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPElement;
+import javax.xml.transform.Source;
+import javax.xml.transform.sax.SAXSource;
+
+import org.springframework.util.Assert;
+import org.springframework.ws.soap.SoapElement;
+import org.springframework.ws.soap.saaj.support.SaajUtils;
+import org.xml.sax.InputSource;
+
+abstract class Saaj11SoapElement implements SoapElement {
+
+ private final SOAPElement saajElement;
+
+ protected Saaj11SoapElement(SOAPElement saajElement) {
+ Assert.notNull(saajElement, "No saajElement given");
+ this.saajElement = saajElement;
+ }
+
+ protected SOAPElement getSaajElement() {
+ return saajElement;
+ }
+
+ public final Source getSource() {
+ return new SAXSource(new Saaj12XmlReader(saajElement), new InputSource());
+ }
+
+ public final QName getName() {
+ return SaajUtils.toQName(saajElement.getElementName());
+ }
+
+}
diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/saaj11/Saaj11SoapEnvelope.java b/core/src/main/java/org/springframework/ws/soap/saaj/saaj11/Saaj11SoapEnvelope.java
new file mode 100644
index 00000000..2f7d0efd
--- /dev/null
+++ b/core/src/main/java/org/springframework/ws/soap/saaj/saaj11/Saaj11SoapEnvelope.java
@@ -0,0 +1,84 @@
+/*
+ * 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.saaj11;
+
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPPart;
+
+import org.springframework.util.Assert;
+import org.springframework.ws.soap.SoapBody;
+import org.springframework.ws.soap.SoapEnvelope;
+import org.springframework.ws.soap.SoapHeader;
+import org.springframework.ws.soap.saaj.SaajSoapBodyException;
+
+/**
+ * @author Arjen Poutsma
+ */
+public class Saaj11SoapEnvelope extends Saaj11SoapElement implements SoapEnvelope {
+
+ private Saaj11Soap11Body body;
+
+// private Saaj11SoapHeader header;
+
+ private final SOAPPart saajPart;
+
+ public Saaj11SoapEnvelope(SOAPEnvelope saajEnvelope, SOAPPart saajPart) throws SOAPException {
+ super(saajEnvelope);
+ Assert.notNull(saajPart, "saajPart must not be null");
+ this.saajPart = saajPart;
+ }
+
+ public final SoapBody getBody() {
+ if (body == null) {
+ try {
+ SOAPBody saajBody = getSaajEnvelope().getBody();
+ body = new Saaj11Soap11Body(saajBody);
+ }
+ catch (SOAPException ex) {
+ throw new SaajSoapBodyException(ex);
+ }
+ }
+ return body;
+ }
+
+ public final SoapHeader getHeader() {
+ return null;
+/*
+ if (header == null) {
+ try {
+ SOAPHeader saajHeader = getSaajEnvelope().getHeader();
+ if (saajHeader != null) {
+ header = new Saaj11SoapHeader(saajHeader);
+ }
+ else {
+ header = null;
+ }
+ }
+ catch (SOAPException ex) {
+ throw new SaajSoapHeaderException(ex);
+ }
+ }
+ return header;
+*/
+ }
+
+ protected SOAPEnvelope getSaajEnvelope() {
+ return (SOAPEnvelope) getSaajElement();
+ }
+}
diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/saaj11/Saaj11SoapMessage.java b/core/src/main/java/org/springframework/ws/soap/saaj/saaj11/Saaj11SoapMessage.java
new file mode 100644
index 00000000..66af03fc
--- /dev/null
+++ b/core/src/main/java/org/springframework/ws/soap/saaj/saaj11/Saaj11SoapMessage.java
@@ -0,0 +1,51 @@
+/*
+ * 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.saaj11;
+
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.soap.SOAPPart;
+
+import org.springframework.ws.soap.SoapEnvelope;
+import org.springframework.ws.soap.saaj.SaajSoapEnvelopeException;
+import org.springframework.ws.soap.saaj.SaajSoapMessage;
+
+/**
+ * SAAJ 1.1 specific implementation of the SoapMessage interface. Accessed via the
+ * SaajSoapMessageContext.
+ *
+ * @author Arjen Poutsma
+ * @see javax.xml.soap.SOAPMessage
+ * @see org.springframework.ws.soap.saaj.SaajSoapMessageContext
+ */
+class Saaj11SoapMessage extends SaajSoapMessage {
+
+ public Saaj11SoapMessage(SOAPMessage soapMessage) {
+ super(soapMessage);
+ }
+
+ protected SoapEnvelope createSaajSoapEnvelope(SOAPMessage saajMessage) {
+ try {
+ SOAPPart saajPart = saajMessage.getSOAPPart();
+ return new Saaj11SoapEnvelope(saajPart.getEnvelope(), saajPart);
+ }
+ catch (SOAPException ex) {
+ throw new SaajSoapEnvelopeException(ex);
+ }
+ }
+
+}
diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/saaj11/Saaj12XmlReader.java b/core/src/main/java/org/springframework/ws/soap/saaj/saaj11/Saaj12XmlReader.java
new file mode 100644
index 00000000..dadefd55
--- /dev/null
+++ b/core/src/main/java/org/springframework/ws/soap/saaj/saaj11/Saaj12XmlReader.java
@@ -0,0 +1,111 @@
+/*
+ * 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.saaj11;
+
+import java.util.Iterator;
+import javax.xml.soap.Name;
+import javax.xml.soap.Node;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.Text;
+
+import org.springframework.xml.sax.AbstractXmlReader;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+
+/**
+ * @author Arjen Poutsma
+ */
+public class Saaj12XmlReader extends AbstractXmlReader {
+
+ private SOAPElement element;
+
+ public Saaj12XmlReader(SOAPElement element) {
+ this.element = element;
+ }
+
+ /**
+ * Parses the StAX XML reader passed at construction-time.
+ *
InputSource is not read, but ignored.
+ *
+ * @param ignored is ignored
+ * @throws SAXException A SAX exception, possibly wrapping a XMLStreamException
+ */
+ public final void parse(InputSource ignored) throws SAXException {
+ handleNode(element);
+ }
+
+ /**
+ * Parses the StAX XML reader passed at construction-time.
+ *
+ * Note that the given system identifier is not read, but ignored.
+ *
+ * @param ignored is ignored
+ * @throws SAXException A SAX exception, possibly wrapping a XMLStreamException
+ */
+ public final void parse(String ignored) throws SAXException {
+ handleNode(element);
+ }
+
+ private void handleNode(Node node) throws SAXException {
+ if (node instanceof SOAPElement) {
+ SOAPElement soapElement = (SOAPElement) node;
+ handleSoapElement(soapElement);
+ }
+ else if (node instanceof Text) {
+ Text text = (Text) node;
+ handleText(text);
+ }
+ }
+
+ private void handleText(Text text) throws SAXException {
+ if (!text.isComment() && getContentHandler() != null) {
+ char[] ch = text.getValue().toCharArray();
+ getContentHandler().characters(ch, 0, ch.length);
+ }
+ }
+
+ private void handleSoapElement(SOAPElement soapElement) throws SAXException {
+ if (getContentHandler() != null) {
+ for (Iterator i = soapElement.getNamespacePrefixes(); i.hasNext();) {
+ String prefix = (String) i.next();
+ getContentHandler().startPrefixMapping(prefix, soapElement.getNamespaceURI(prefix));
+ }
+ Name name = soapElement.getElementName();
+ getContentHandler().startElement(name.getURI(), name.getLocalName(), name.getQualifiedName(),
+ getAttributes(soapElement));
+ for (Iterator i = soapElement.getChildElements(); i.hasNext();) {
+ Node child = (Node) i.next();
+ handleNode(child);
+ }
+ getContentHandler().endElement(name.getURI(), name.getLocalName(), name.getQualifiedName());
+ }
+ }
+
+ private Attributes getAttributes(SOAPElement soapElement) {
+ AttributesImpl attributes = new AttributesImpl();
+
+ for (Iterator i = soapElement.getAllAttributes(); i.hasNext();) {
+ Name name = (Name) i.next();
+ attributes.addAttribute(name.getURI(), name.getLocalName(), name.getQualifiedName(), null,
+ soapElement.getAttributeValue(name));
+ }
+ return attributes;
+ }
+}
diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/saaj12/Saaj12SoapMessage.java b/core/src/main/java/org/springframework/ws/soap/saaj/saaj12/Saaj12SoapMessage.java
index 9a416c74..4b0f7beb 100644
--- a/core/src/main/java/org/springframework/ws/soap/saaj/saaj12/Saaj12SoapMessage.java
+++ b/core/src/main/java/org/springframework/ws/soap/saaj/saaj12/Saaj12SoapMessage.java
@@ -16,10 +16,11 @@
package org.springframework.ws.soap.saaj.saaj12;
-import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
import org.springframework.ws.soap.SoapEnvelope;
+import org.springframework.ws.soap.saaj.SaajSoapEnvelopeException;
import org.springframework.ws.soap.saaj.SaajSoapMessage;
/**
@@ -36,8 +37,13 @@ class Saaj12SoapMessage extends SaajSoapMessage {
super(soapMessage);
}
- protected SoapEnvelope createSaajSoapEnvelope(SOAPEnvelope saajEnvelope) {
- return new Saaj12SoapEnvelope(saajEnvelope);
+ protected SoapEnvelope createSaajSoapEnvelope(SOAPMessage saajMessage) {
+ try {
+ return new Saaj12SoapEnvelope(saajMessage.getSOAPPart().getEnvelope());
+ }
+ catch (SOAPException ex) {
+ throw new SaajSoapEnvelopeException(ex);
+ }
}
}
diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/saaj13/Saaj13SoapMessage.java b/core/src/main/java/org/springframework/ws/soap/saaj/saaj13/Saaj13SoapMessage.java
index 0a96a428..7513eac7 100644
--- a/core/src/main/java/org/springframework/ws/soap/saaj/saaj13/Saaj13SoapMessage.java
+++ b/core/src/main/java/org/springframework/ws/soap/saaj/saaj13/Saaj13SoapMessage.java
@@ -16,10 +16,11 @@
package org.springframework.ws.soap.saaj.saaj13;
-import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
import org.springframework.ws.soap.SoapEnvelope;
+import org.springframework.ws.soap.saaj.SaajSoapEnvelopeException;
import org.springframework.ws.soap.saaj.SaajSoapMessage;
class Saaj13SoapMessage extends SaajSoapMessage {
@@ -33,7 +34,12 @@ class Saaj13SoapMessage extends SaajSoapMessage {
super(soapMessage);
}
- protected SoapEnvelope createSaajSoapEnvelope(SOAPEnvelope saajEnvelope) {
- return new Saaj13SoapEnvelope(saajEnvelope);
+ protected SoapEnvelope createSaajSoapEnvelope(SOAPMessage saajMessage) {
+ try {
+ return new Saaj13SoapEnvelope(saajMessage.getSOAPPart().getEnvelope());
+ }
+ catch (SOAPException ex) {
+ throw new SaajSoapEnvelopeException(ex);
+ }
}
}
diff --git a/core/src/test/java/org/springframework/ws/soap/saaj/saaj11/Saaj11Soap11BodyTest.java b/core/src/test/java/org/springframework/ws/soap/saaj/saaj11/Saaj11Soap11BodyTest.java
new file mode 100644
index 00000000..de58d3b5
--- /dev/null
+++ b/core/src/test/java/org/springframework/ws/soap/saaj/saaj11/Saaj11Soap11BodyTest.java
@@ -0,0 +1,40 @@
+/*
+ * 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.saaj11;
+
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPConstants;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+
+import junit.framework.TestCase;
+
+public class Saaj11Soap11BodyTest extends TestCase {
+
+ public void testIt() throws Exception {
+ MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
+ SOAPMessage saajMessage = messageFactory.createMessage();
+ Source source = saajMessage.getSOAPPart().getContent();
+ Transformer transformer = TransformerFactory.newInstance().newTransformer();
+ transformer.transform(source, new StreamResult(System.out));
+
+ }
+
+}
diff --git a/core/src/test/java/org/springframework/ws/soap/saaj/saaj11/Saaj11Soap11EnvelopeTest.java b/core/src/test/java/org/springframework/ws/soap/saaj/saaj11/Saaj11Soap11EnvelopeTest.java
new file mode 100644
index 00000000..d02b260b
--- /dev/null
+++ b/core/src/test/java/org/springframework/ws/soap/saaj/saaj11/Saaj11Soap11EnvelopeTest.java
@@ -0,0 +1,35 @@
+/*
+ * 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.saaj11;
+
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPConstants;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.soap.SOAPPart;
+
+import org.springframework.ws.soap.SoapEnvelope;
+import org.springframework.ws.soap.soap11.AbstractSoap11EnvelopeTestCase;
+
+public class Saaj11Soap11EnvelopeTest extends AbstractSoap11EnvelopeTestCase {
+
+ protected SoapEnvelope createSoapEnvelope() throws Exception {
+ MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
+ SOAPMessage saajMessage = messageFactory.createMessage();
+ SOAPPart saajPart = saajMessage.getSOAPPart();
+ return new Saaj11SoapEnvelope(saajPart.getEnvelope(), saajPart);
+ }
+}
diff --git a/core/src/test/java/org/springframework/ws/soap/saaj/saaj11/Saaj11Soap11MessageTest.java b/core/src/test/java/org/springframework/ws/soap/saaj/saaj11/Saaj11Soap11MessageTest.java
new file mode 100644
index 00000000..80c53d72
--- /dev/null
+++ b/core/src/test/java/org/springframework/ws/soap/saaj/saaj11/Saaj11Soap11MessageTest.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.ws.soap.saaj.saaj11;
+
+import javax.xml.soap.SOAPMessage;
+
+import org.springframework.ws.soap.saaj.SaajSoap11MessageTestCase;
+import org.springframework.ws.soap.saaj.SaajSoapMessage;
+
+public class Saaj11Soap11MessageTest extends SaajSoap11MessageTestCase {
+
+ protected SaajSoapMessage createSaajSoapMessage(SOAPMessage saajMessage) {
+ return new Saaj11SoapMessage(saajMessage);
+ }
+
+}
diff --git a/core/src/test/java/org/springframework/ws/soap/saaj/saaj11/Saaj12XmlReaderTest.java b/core/src/test/java/org/springframework/ws/soap/saaj/saaj11/Saaj12XmlReaderTest.java
new file mode 100644
index 00000000..c5efda10
--- /dev/null
+++ b/core/src/test/java/org/springframework/ws/soap/saaj/saaj11/Saaj12XmlReaderTest.java
@@ -0,0 +1,72 @@
+/*
+ * 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.saaj11;
+
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPConstants;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.sax.SAXSource;
+
+import org.custommonkey.xmlunit.XMLTestCase;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.ws.soap.saaj.support.SaajUtils;
+import org.springframework.xml.transform.StringResult;
+import org.xml.sax.InputSource;
+
+public class Saaj12XmlReaderTest extends XMLTestCase {
+
+ private Transformer transformer;
+
+ private MessageFactory messageFactory;
+
+ protected void setUp() throws Exception {
+ messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
+ transformer = TransformerFactory.newInstance().newTransformer();
+ }
+
+ public void testReader() throws Exception {
+ SOAPMessage message = messageFactory.createMessage();
+ SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
+ Saaj12XmlReader reader = new Saaj12XmlReader(envelope);
+ DOMSource domSource = new DOMSource(envelope);
+ StringResult expected = new StringResult();
+ transformer.transform(domSource, expected);
+
+ StringResult result = new StringResult();
+ transformer.transform(new SAXSource(reader, new InputSource()), result);
+ assertXMLEqual(expected.toString(), result.toString());
+ }
+
+ public void testReader2() throws Exception {
+ SOAPMessage message =
+ SaajUtils.loadMessage(new ClassPathResource("org/springframework/ws/soap/context/soap11.xml"));
+ SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
+ Saaj12XmlReader reader = new Saaj12XmlReader(envelope);
+ DOMSource domSource = new DOMSource(envelope);
+ StringResult expected = new StringResult();
+ transformer.transform(domSource, expected);
+
+ StringResult result = new StringResult();
+ transformer.transform(new SAXSource(reader, new InputSource()), result);
+ assertXMLEqual(expected.toString(), result.toString());
+ }
+
+}
\ No newline at end of file
diff --git a/xml/src/main/java/org/springframework/xml/sax/AbstractXmlReader.java b/xml/src/main/java/org/springframework/xml/sax/AbstractXmlReader.java
new file mode 100644
index 00000000..a411b087
--- /dev/null
+++ b/xml/src/main/java/org/springframework/xml/sax/AbstractXmlReader.java
@@ -0,0 +1,116 @@
+/*
+ * 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.xml.sax;
+
+import org.xml.sax.ContentHandler;
+import org.xml.sax.DTDHandler;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXNotRecognizedException;
+import org.xml.sax.XMLReader;
+
+/**
+ * Abstract base class for SAX XMLReader implementations.
+ *
+ * @author Arjen Poutsma
+ * @see #setContentHandler(org.xml.sax.ContentHandler)
+ * @see #setDTDHandler(org.xml.sax.DTDHandler)
+ * @see #setEntityResolver(org.xml.sax.EntityResolver)
+ * @see #setErrorHandler(org.xml.sax.ErrorHandler)
+ */
+public abstract class AbstractXmlReader implements XMLReader {
+
+ private DTDHandler dtdHandler;
+
+ protected ContentHandler contentHandler;
+
+ private EntityResolver entityResolver;
+
+ protected ErrorHandler errorHandler;
+
+ public ContentHandler getContentHandler() {
+ return contentHandler;
+ }
+
+ public void setContentHandler(ContentHandler contentHandler) {
+ this.contentHandler = contentHandler;
+ }
+
+ public void setDTDHandler(DTDHandler dtdHandler) {
+ this.dtdHandler = dtdHandler;
+ }
+
+ public DTDHandler getDTDHandler() {
+ return dtdHandler;
+ }
+
+ public EntityResolver getEntityResolver() {
+ return entityResolver;
+ }
+
+ public void setEntityResolver(EntityResolver entityResolver) {
+ this.entityResolver = entityResolver;
+ }
+
+ public ErrorHandler getErrorHandler() {
+ return errorHandler;
+ }
+
+ public void setErrorHandler(ErrorHandler errorHandler) {
+ this.errorHandler = errorHandler;
+ }
+
+ /**
+ * Throws a SAXNotRecognizedException exception.
+ *
+ * @throws org.xml.sax.SAXNotRecognizedException
+ * always
+ */
+ public boolean getFeature(String name) throws SAXNotRecognizedException {
+ throw new SAXNotRecognizedException(name);
+ }
+
+ /**
+ * Throws a SAXNotRecognizedException exception.
+ *
+ * @throws org.xml.sax.SAXNotRecognizedException
+ * always
+ */
+ public void setFeature(String name, boolean value) throws SAXNotRecognizedException {
+ throw new SAXNotRecognizedException(name);
+ }
+
+ /**
+ * Throws a SAXNotRecognizedException exception.
+ *
+ * @throws org.xml.sax.SAXNotRecognizedException
+ * always
+ */
+ public Object getProperty(String name) throws SAXNotRecognizedException {
+ throw new SAXNotRecognizedException(name);
+ }
+
+ /**
+ * Throws a SAXNotRecognizedException exception.
+ *
+ * @throws org.xml.sax.SAXNotRecognizedException
+ * always
+ */
+ public void setProperty(String name, Object value) throws SAXNotRecognizedException {
+ throw new SAXNotRecognizedException(name);
+ }
+}
diff --git a/xml/src/main/java/org/springframework/xml/stream/StaxXmlReader.java b/xml/src/main/java/org/springframework/xml/stream/StaxXmlReader.java
index 62b79475..97dba09d 100644
--- a/xml/src/main/java/org/springframework/xml/stream/StaxXmlReader.java
+++ b/xml/src/main/java/org/springframework/xml/stream/StaxXmlReader.java
@@ -19,16 +19,12 @@ package org.springframework.xml.stream;
import javax.xml.stream.Location;
import javax.xml.stream.XMLStreamException;
+import org.springframework.xml.sax.AbstractXmlReader;
import org.xml.sax.ContentHandler;
-import org.xml.sax.DTDHandler;
-import org.xml.sax.EntityResolver;
-import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
-import org.xml.sax.SAXNotRecognizedException;
import org.xml.sax.SAXParseException;
-import org.xml.sax.XMLReader;
/**
* Abstract base class for SAX XMLReader implementations that use StAX as a basis.
@@ -39,83 +35,7 @@ import org.xml.sax.XMLReader;
* @see #setEntityResolver(org.xml.sax.EntityResolver)
* @see #setErrorHandler(org.xml.sax.ErrorHandler)
*/
-public abstract class StaxXmlReader implements XMLReader {
-
- private DTDHandler dtdHandler;
-
- private ContentHandler contentHandler;
-
- private EntityResolver entityResolver;
-
- private ErrorHandler errorHandler;
-
- public ContentHandler getContentHandler() {
- return contentHandler;
- }
-
- public void setContentHandler(ContentHandler contentHandler) {
- this.contentHandler = contentHandler;
- }
-
- public void setDTDHandler(DTDHandler dtdHandler) {
- this.dtdHandler = dtdHandler;
- }
-
- public DTDHandler getDTDHandler() {
- return dtdHandler;
- }
-
- public EntityResolver getEntityResolver() {
- return entityResolver;
- }
-
- public void setEntityResolver(EntityResolver entityResolver) {
- this.entityResolver = entityResolver;
- }
-
- public ErrorHandler getErrorHandler() {
- return errorHandler;
- }
-
- public void setErrorHandler(ErrorHandler errorHandler) {
- this.errorHandler = errorHandler;
- }
-
- /**
- * Throws a SAXNotRecognizedException exception.
- *
- * @throws SAXNotRecognizedException always
- */
- public boolean getFeature(String name) throws SAXNotRecognizedException {
- throw new SAXNotRecognizedException(name);
- }
-
- /**
- * Throws a SAXNotRecognizedException exception.
- *
- * @throws SAXNotRecognizedException always
- */
- public void setFeature(String name, boolean value) throws SAXNotRecognizedException {
- throw new SAXNotRecognizedException(name);
- }
-
- /**
- * Throws a SAXNotRecognizedException exception.
- *
- * @throws SAXNotRecognizedException always
- */
- public Object getProperty(String name) throws SAXNotRecognizedException {
- throw new SAXNotRecognizedException(name);
- }
-
- /**
- * Throws a SAXNotRecognizedException exception.
- *
- * @throws SAXNotRecognizedException always
- */
- public void setProperty(String name, Object value) throws SAXNotRecognizedException {
- throw new SAXNotRecognizedException(name);
- }
+public abstract class StaxXmlReader extends AbstractXmlReader {
/**
* Parses the StAX XML reader passed at construction-time.