From 1b29d8bdc6a3e37ace9819285bfb7f0fff1bb879 Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Thu, 19 Oct 2006 09:07:59 +0000 Subject: [PATCH] Rolled back to previous version of SAAJ. SAAJ 1.1 is never going to work, especially not under Weblogic 8.1. --- .../springframework/ws/soap/SoapHeader.java | 9 ++ .../saaj/Saaj11ImplementationStrategy.java | 121 -------------- .../saaj/Saaj12ImplementationStrategy.java | 57 ------- .../saaj/Saaj13ImplementationStrategy.java | 56 ------- .../soap/saaj/SaajImplementationStrategy.java | 62 -------- .../ws/soap/saaj/SaajSoap11Body.java | 87 ---------- .../ws/soap/saaj/SaajSoap11Fault.java | 37 ----- .../ws/soap/saaj/SaajSoap12Body.java | 36 ----- .../ws/soap/saaj/SaajSoap12Fault.java | 90 ----------- .../ws/soap/saaj/SaajSoapBody.java | 71 --------- .../ws/soap/saaj/SaajSoapElement.java | 54 ------- .../ws/soap/saaj/SaajSoapFault.java | 70 -------- .../ws/soap/saaj/SaajSoapFaultDetail.java | 81 ---------- .../soap/saaj/SaajSoapFaultDetailElement.java | 50 ------ .../ws/soap/saaj/SaajSoapHeader.java | 75 --------- .../ws/soap/saaj/SaajSoapHeaderElement.java | 54 ------- .../ws/soap/saaj/SaajSoapMessage.java | 11 +- .../ws/soap/saaj/saaj11/Saaj11Soap11Body.java | 150 ------------------ .../soap/saaj/saaj11/Saaj11Soap11Fault.java | 79 --------- .../soap/saaj/saaj11/Saaj11SoapElement.java | 50 ------ .../soap/saaj/saaj11/Saaj11SoapEnvelope.java | 84 ---------- .../soap/saaj/saaj11/Saaj11SoapMessage.java | 51 ------ .../ws/soap/saaj/saaj11/Saaj12XmlReader.java | 111 ------------- .../ws/soap/saaj/saaj12/Saaj12Soap11Body.java | 2 +- .../saaj/saaj12/Saaj12SoapFaultDetail.java | 7 +- .../ws/soap/saaj/saaj12/Saaj12SoapHeader.java | 7 +- .../saaj/saaj12/Saaj12SoapHeaderElement.java | 7 +- .../soap/saaj/saaj12/Saaj12SoapMessage.java | 12 +- .../soap/saaj/saaj13/Saaj13SoapMessage.java | 12 +- .../ws/soap/saaj/support/SaajUtils.java | 8 +- .../support/SoapElementContentHandler.java | 92 ----------- .../saaj/support/SoapElementXmlReader.java | 112 ------------- .../ws/soap/AbstractSoapHeaderTestCase.java | 22 ++- .../Saaj11ImplementationStrategyTest.java | 114 ------------- .../saaj/saaj11/Saaj11Soap11BodyTest.java | 40 ----- .../saaj/saaj11/Saaj11Soap11EnvelopeTest.java | 35 ---- .../saaj/saaj11/Saaj11Soap11MessageTest.java | 30 ---- .../soap/saaj/saaj11/Saaj12XmlReaderTest.java | 72 --------- .../ws/soap/saaj/support/SaajUtilsTest.java | 8 - .../SoapElementContentHandlerTest.java | 41 ----- .../support/SoapElementXmlReaderTest.java | 71 --------- 41 files changed, 52 insertions(+), 2186 deletions(-) delete mode 100644 core/src/main/java/org/springframework/ws/soap/saaj/Saaj11ImplementationStrategy.java delete mode 100644 core/src/main/java/org/springframework/ws/soap/saaj/Saaj12ImplementationStrategy.java delete mode 100644 core/src/main/java/org/springframework/ws/soap/saaj/Saaj13ImplementationStrategy.java delete mode 100644 core/src/main/java/org/springframework/ws/soap/saaj/SaajImplementationStrategy.java delete mode 100644 core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap11Body.java delete mode 100644 core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap11Fault.java delete mode 100644 core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap12Body.java delete mode 100644 core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap12Fault.java delete mode 100644 core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapBody.java delete mode 100644 core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapElement.java delete mode 100644 core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapFault.java delete mode 100644 core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapFaultDetail.java delete mode 100644 core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapFaultDetailElement.java delete mode 100644 core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapHeader.java delete mode 100644 core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapHeaderElement.java delete mode 100644 core/src/main/java/org/springframework/ws/soap/saaj/saaj11/Saaj11Soap11Body.java delete mode 100644 core/src/main/java/org/springframework/ws/soap/saaj/saaj11/Saaj11Soap11Fault.java delete mode 100644 core/src/main/java/org/springframework/ws/soap/saaj/saaj11/Saaj11SoapElement.java delete mode 100644 core/src/main/java/org/springframework/ws/soap/saaj/saaj11/Saaj11SoapEnvelope.java delete mode 100644 core/src/main/java/org/springframework/ws/soap/saaj/saaj11/Saaj11SoapMessage.java delete mode 100644 core/src/main/java/org/springframework/ws/soap/saaj/saaj11/Saaj12XmlReader.java delete mode 100644 core/src/main/java/org/springframework/ws/soap/saaj/support/SoapElementContentHandler.java delete mode 100644 core/src/main/java/org/springframework/ws/soap/saaj/support/SoapElementXmlReader.java delete mode 100644 core/src/test/java/org/springframework/ws/soap/saaj/Saaj11ImplementationStrategyTest.java delete mode 100644 core/src/test/java/org/springframework/ws/soap/saaj/saaj11/Saaj11Soap11BodyTest.java delete mode 100644 core/src/test/java/org/springframework/ws/soap/saaj/saaj11/Saaj11Soap11EnvelopeTest.java delete mode 100644 core/src/test/java/org/springframework/ws/soap/saaj/saaj11/Saaj11Soap11MessageTest.java delete mode 100644 core/src/test/java/org/springframework/ws/soap/saaj/saaj11/Saaj12XmlReaderTest.java delete mode 100644 core/src/test/java/org/springframework/ws/soap/saaj/support/SoapElementContentHandlerTest.java delete mode 100644 core/src/test/java/org/springframework/ws/soap/saaj/support/SoapElementXmlReaderTest.java diff --git a/core/src/main/java/org/springframework/ws/soap/SoapHeader.java b/core/src/main/java/org/springframework/ws/soap/SoapHeader.java index 65da2130..6a9e3a63 100644 --- a/core/src/main/java/org/springframework/ws/soap/SoapHeader.java +++ b/core/src/main/java/org/springframework/ws/soap/SoapHeader.java @@ -49,4 +49,13 @@ public interface SoapHeader extends SoapElement { * @see SoapHeaderElement */ Iterator examineMustUnderstandHeaderElements(String actorOrRole) throws SoapHeaderException; + + /** + * Returns an Iterator over all the SoapHeaderElements in this header. + * + * @return an iterator over all the header elements + * @throws SoapHeaderException if the header cannot be returned + * @see SoapHeaderElement + */ + Iterator examineAllHeaderElements() throws SoapHeaderException; } diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/Saaj11ImplementationStrategy.java b/core/src/main/java/org/springframework/ws/soap/saaj/Saaj11ImplementationStrategy.java deleted file mode 100644 index edc489fc..00000000 --- a/core/src/main/java/org/springframework/ws/soap/saaj/Saaj11ImplementationStrategy.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright 2006 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * * limitations under the License. - */ - -package org.springframework.ws.soap.saaj; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -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.Node; -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 javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.sax.SAXResult; -import javax.xml.transform.sax.SAXSource; - -import org.springframework.ws.soap.saaj.support.SaajUtils; -import org.springframework.ws.soap.saaj.support.SoapElementContentHandler; -import org.springframework.ws.soap.saaj.support.SoapElementXmlReader; -import org.springframework.xml.namespace.QNameUtils; -import org.xml.sax.InputSource; - -/** - * SAAJ 1.1 implementation of the SaajImplementationStrategy. - * - * @author Arjen Poutsma - */ -public class Saaj11ImplementationStrategy implements SaajImplementationStrategy { - - public QName getName(SOAPElement element) { - return SaajUtils.toQName(element.getElementName()); - } - - public Source getSource(SOAPElement element) { - return new SAXSource(new SoapElementXmlReader(element), new InputSource()); - } - - public Result getResult(SOAPElement element) { - return new SAXResult(new SoapElementContentHandler(element)); - } - - public QName getFaultCode(SOAPFault fault) { - String code = fault.getFaultCode(); - int idx = code.indexOf(':'); - if (idx == -1) { - return new QName(code); - } - else { - String prefix = code.substring(0, idx); - String localPart = code.substring(idx + 1); - String namespace = fault.getNamespaceURI(prefix); - return QNameUtils.createQName(namespace, localPart, prefix); - } - } - - public DetailEntry addDetailEntry(Detail detail, QName name) throws SOAPException { - return detail.addDetailEntry(SaajUtils.toName(name, detail)); - } - - public void removeContents(SOAPElement element) { - List children = new ArrayList(); - for (Iterator iterator = element.getChildElements(); iterator.hasNext();) { - Node node = (Node) iterator.next(); - children.add(node); - } - for (Iterator iterator = children.iterator(); iterator.hasNext();) { - Node node = (Node) iterator.next(); - node.detachNode(); - } - } - - public SOAPHeaderElement addHeaderElement(SOAPHeader header, QName name) throws SOAPException { - Name saajName = SaajUtils.toName(name, header); - return header.addHeaderElement(saajName); - } - - public Locale getFaultStringLocale(SOAPFault saajFault) { - return null; - } - - public SOAPFault addFault(SOAPBody saajBody, QName faultCode, String faultString, Locale faultStringLocale) throws SOAPException { - SOAPFault fault = saajBody.addFault(); - String faultCodeQName = QNameUtils.toQualifiedName(faultCode); - fault.setFaultCode(faultCodeQName); - fault.setFaultString(faultString); - return fault; - } - - public Iterator examineMustUnderstandHeaderElements(SOAPHeader header, String role) { - List result = new ArrayList(); - for (Iterator iterator = header.examineHeaderElements(role); iterator.hasNext();) { - SOAPHeaderElement headerElement = (SOAPHeaderElement) iterator.next(); - if (headerElement.getMustUnderstand()) { - result.add(headerElement); - } - } - return result.iterator(); - } -} diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/Saaj12ImplementationStrategy.java b/core/src/main/java/org/springframework/ws/soap/saaj/Saaj12ImplementationStrategy.java deleted file mode 100644 index d83bf08a..00000000 --- a/core/src/main/java/org/springframework/ws/soap/saaj/Saaj12ImplementationStrategy.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2006 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * * limitations under the License. - */ - -package org.springframework.ws.soap.saaj; - -import javax.xml.namespace.QName; -import javax.xml.soap.Detail; -import javax.xml.soap.DetailEntry; -import javax.xml.soap.SOAPElement; -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.ws.soap.saaj.support.SaajUtils; - -class Saaj12ImplementationStrategy extends SaajImplementationStrategy { - - public Source getSource(SOAPElement element) { - return new DOMSource(element); - } - - public Result getResult(SOAPElement element) { - return new DOMResult(element); - } - - public QName getName(SOAPElement element) { - return SaajUtils.toQName(element.getElementName()); - } - - public QName getFaultCode(SOAPFault fault) { - return SaajUtils.toQName(fault.getFaultCodeAsName()); - } - - public DetailEntry addDetailEntry(Detail detail, QName name) throws SOAPException { - return detail.addDetailEntry(SaajUtils.toName(name, detail)); - } - - public void removeContents(SOAPElement element) { - element.removeContents(); - } -} diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/Saaj13ImplementationStrategy.java b/core/src/main/java/org/springframework/ws/soap/saaj/Saaj13ImplementationStrategy.java deleted file mode 100644 index 478aa24c..00000000 --- a/core/src/main/java/org/springframework/ws/soap/saaj/Saaj13ImplementationStrategy.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2006 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * * limitations under the License. - */ - -package org.springframework.ws.soap.saaj; - -import javax.xml.namespace.QName; -import javax.xml.soap.Detail; -import javax.xml.soap.DetailEntry; -import javax.xml.soap.SOAPElement; -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; - -class Saaj13ImplementationStrategy extends SaajImplementationStrategy { - - public QName getName(SOAPElement element) { - return element.getElementQName(); - } - - public Source getSource(SOAPElement element) { - return new DOMSource(element); - } - - public Result getResult(SOAPElement element) { - return new DOMResult(element); - } - - public QName getFaultCode(SOAPFault fault) { - return fault.getFaultCodeAsQName(); - } - - public DetailEntry addDetailEntry(Detail detail, QName name) throws SOAPException { - return detail.addDetailEntry(name); - } - - public void removeContents(SOAPElement element) { - element.removeContents(); - } - -} diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/SaajImplementationStrategy.java b/core/src/main/java/org/springframework/ws/soap/saaj/SaajImplementationStrategy.java deleted file mode 100644 index 16f198f6..00000000 --- a/core/src/main/java/org/springframework/ws/soap/saaj/SaajImplementationStrategy.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2006 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * * limitations under the License. - */ - -package org.springframework.ws.soap.saaj; - -import java.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.SOAPElement; -import javax.xml.soap.SOAPException; -import javax.xml.soap.SOAPFault; -import javax.xml.soap.SOAPHeader; -import javax.xml.soap.SOAPHeaderElement; -import javax.xml.transform.Result; -import javax.xml.transform.Source; - -/** - * Defines the contract for different implementation versions of SAAJ. - *

- * This is pulled out into an interface as the various versions of SAAJ have different contracts with regard to naming, - * etc. - * - * @author Arjen Poutsma - */ -public interface SaajImplementationStrategy { - - public QName getName(SOAPElement element); - - public Source getSource(SOAPElement element); - - public Result getResult(SOAPElement element); - - public QName getFaultCode(SOAPFault fault); - - public DetailEntry addDetailEntry(Detail detail, QName name) throws SOAPException; - - public void removeContents(SOAPElement element); - - public SOAPHeaderElement addHeaderElement(SOAPHeader header, QName name) throws SOAPException; - - public Locale getFaultStringLocale(SOAPFault saajFault); - - public Iterator examineMustUnderstandHeaderElements(SOAPHeader header, String role); - - SOAPFault addFault(SOAPBody saajBody, QName faultCode, String faultString, Locale faultStringLocale) throws SOAPException; -} diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap11Body.java b/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap11Body.java deleted file mode 100644 index c18f4e17..00000000 --- a/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap11Body.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2006 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * * limitations under the License. - */ - -package org.springframework.ws.soap.saaj; - -import java.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.soap11.Soap11Body; -import org.springframework.ws.soap.soap11.Soap11Fault; -import org.springframework.xml.namespace.QNameUtils; - -class SaajSoap11Body extends SaajSoapBody implements Soap11Body { - - private static final String CLIENT = "Client"; - - private static final String MUST_UNDERSTAND = "MustUnderstand"; - - private static final String SERVER = "Server"; - - private static final String VERSION_MISMATCH = "VersionMismatch"; - - public SaajSoap11Body(SOAPBody body, SaajImplementationStrategy strategy) { - super(body, strategy); - } - - 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 { - getStrategy().removeContents(getSaajBody()); - SOAPFault saajFault = getStrategy().addFault(getSaajBody(), faultCode, faultString, faultStringLocale); - return new SaajSoap11Fault(saajFault, getStrategy()); - } - catch (SOAPException ex) { - throw new SaajSoapFaultException(ex); - } - } - - public SoapFault getFault() { - SOAPFault fault = getSaajBody().getFault(); - return fault == null ? null : new SaajSoap11Fault(fault, getStrategy()); - } - - public SoapFault addClientOrSenderFault(String faultString, Locale locale) { - return addFault(getStandardFaultCodeQName(CLIENT), faultString, locale); - } - - public SoapFault addMustUnderstandFault(String faultString, Locale locale) { - return addFault(getStandardFaultCodeQName(MUST_UNDERSTAND), faultString, locale); - } - - public SoapFault addServerOrReceiverFault(String faultString, Locale locale) { - return addFault(getStandardFaultCodeQName(SERVER), faultString, locale); - } - - public SoapFault addVersionMismatchFault(String faultString, Locale locale) { - return addFault(getStandardFaultCodeQName(VERSION_MISMATCH), faultString, locale); - } - - private QName getStandardFaultCodeQName(String localName) { - return QNameUtils.createQName(getSaajBody().getElementName().getURI(), localName, getSaajBody().getElementName().getPrefix()); - } -} diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap11Fault.java b/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap11Fault.java deleted file mode 100644 index fc910d97..00000000 --- a/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap11Fault.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2006 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * * limitations under the License. - */ - -package org.springframework.ws.soap.saaj; - -import java.util.Locale; -import javax.xml.soap.SOAPFault; - -import org.springframework.ws.soap.soap11.Soap11Fault; - -class SaajSoap11Fault extends SaajSoapFault implements Soap11Fault { - - public SaajSoap11Fault(SOAPFault fault, SaajImplementationStrategy strategy) { - super(fault, strategy); - } - - public String getFaultString() { - return getSaajFault().getFaultString(); - } - - public Locale getFaultStringLocale() { - return getStrategy().getFaultStringLocale(getSaajFault()); - } -} 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 deleted file mode 100644 index 1337495d..00000000 --- a/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap12Body.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2006 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * * limitations under the License. - */ - -package org.springframework.ws.soap.saaj; - -import javax.xml.soap.SOAPBody; -import javax.xml.soap.SOAPFault; - -import org.springframework.ws.soap.SoapFault; -import org.springframework.ws.soap.soap12.Soap12Body; - -class SaajSoap12Body extends SaajSoapBody implements Soap12Body { - - public SaajSoap12Body(SOAPBody body) { - super(body); - } - - public SoapFault getFault() { - SOAPFault fault = getSaajBody().getFault(); - return fault == null ? null : new SaajSoap12Fault(fault); - } - -} diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap12Fault.java b/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap12Fault.java deleted file mode 100644 index 5ce68c87..00000000 --- a/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap12Fault.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2006 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * * limitations under the License. - */ - -package org.springframework.ws.soap.saaj; - -import java.util.Iterator; -import java.util.Locale; -import javax.xml.namespace.QName; -import javax.xml.soap.SOAPException; -import javax.xml.soap.SOAPFault; - -import org.springframework.ws.soap.soap12.Soap12Fault; - -class SaajSoap12Fault extends SaajSoapFault implements Soap12Fault { - - public SaajSoap12Fault(SOAPFault saajFault) { - super(saajFault); - } - - public Iterator getFaultSubcodes() { - return getSaajFault().getFaultSubcodes(); - } - - public void addFaultSubcode(QName subcode) { - try { - getSaajFault().appendFaultSubcode(subcode); - } - catch (SOAPException ex) { - throw new SaajSoapFaultException(ex); - } - } - - public String getFaultActorOrRole() { - return getSaajFault().getFaultRole(); - } - - public void setFaultActorOrRole(String uri) { - try { - getSaajFault().setFaultRole(uri); - } - catch (SOAPException ex) { - throw new SaajSoapFaultException(ex); - } - } - - public String getFaultNode() { - return getSaajFault().getFaultNode(); - } - - public void setFaultNode(String uri) { - try { - getSaajFault().setFaultNode(uri); - } - catch (SOAPException ex) { - throw new SaajSoapFaultException(ex); - } - } - - public void setFaultReasonText(Locale locale, String text) { - try { - getSaajFault().addFaultReasonText(text, locale); - } - catch (SOAPException ex) { - throw new SaajSoapFaultException(ex); - } - } - - public String getFaultReasonText(Locale locale) { - try { - return getSaajFault().getFaultReasonText(locale); - } - catch (SOAPException ex) { - throw new SaajSoapFaultException(ex); - } - } - -} 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 deleted file mode 100644 index 365b2a5f..00000000 --- a/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapBody.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2006 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * * limitations under the License. - */ - -package org.springframework.ws.soap.saaj; - -import java.util.Iterator; -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; - -abstract class SaajSoapBody extends SaajSoapElement implements SoapBody { - - protected SaajSoapBody(SOAPBody body, SaajImplementationStrategy strategy) { - super(body, strategy); - } - - public boolean hasFault() { - return getSaajBody().hasFault(); - } - - public Source getPayloadSource() { - SOAPBodyElement payloadElement = getPayloadElement(); - if (payloadElement == null) { - return null; - } - else { - return getStrategy().getSource(payloadElement); - } - } - - public Result getPayloadResult() { - getStrategy().removeContents(getSaajBody()); - return getStrategy().getResult(getSaajBody()); - } - - /** - * 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. - */ - protected SOAPBodyElement getPayloadElement() { - for (Iterator iterator = getSaajBody().getChildElements(); iterator.hasNext();) { - Object child = iterator.next(); - if (child instanceof SOAPBodyElement) { - return (SOAPBodyElement) child; - } - } - return null; - } - - protected SOAPBody getSaajBody() { - return (SOAPBody) getSaajElement(); - } -} diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapElement.java b/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapElement.java deleted file mode 100644 index 2d7416e2..00000000 --- a/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapElement.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2006 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * * limitations under the License. - */ - -package org.springframework.ws.soap.saaj; - -import javax.xml.namespace.QName; -import javax.xml.soap.SOAPElement; -import javax.xml.transform.Source; - -import org.springframework.util.Assert; -import org.springframework.ws.soap.SoapElement; - -abstract class SaajSoapElement implements SoapElement { - - private final SOAPElement saajElement; - - private final SaajImplementationStrategy strategy; - - protected SaajSoapElement(SOAPElement saajElement, SaajImplementationStrategy strategy) { - Assert.notNull(saajElement, "No saajElement given"); - Assert.notNull(strategy, "No strategy given"); - this.saajElement = saajElement; - this.strategy = strategy; - } - - protected final SOAPElement getSaajElement() { - return saajElement; - } - - protected final SaajImplementationStrategy getStrategy() { - return strategy; - } - - public final QName getName() { - return getStrategy().getName(saajElement); - } - - public final Source getSource() { - return getStrategy().getSource(saajElement); - } -} diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapFault.java b/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapFault.java deleted file mode 100644 index 81741389..00000000 --- a/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapFault.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2006 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * * limitations under the License. - */ - -package org.springframework.ws.soap.saaj; - -import 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; - -abstract class SaajSoapFault extends SaajSoapElement implements SoapFault { - - protected SaajSoapFault(SOAPFault fault, SaajImplementationStrategy strategy) { - super(fault, strategy); - } - - public QName getFaultCode() { - return getStrategy().getFaultCode(getSaajFault()); - } - - public String getFaultActorOrRole() { - return getSaajFault().getFaultActor(); - } - - public void setFaultActorOrRole(String faultActor) { - try { - getSaajFault().setFaultActor(faultActor); - } - catch (SOAPException ex) { - throw new SaajSoapFaultException(ex); - } - } - - public SoapFaultDetail getFaultDetail() { - Detail saajDetail = getSaajFault().getDetail(); - return saajDetail == null ? null : new SaajSoapFaultDetail(saajDetail); - } - - public SoapFaultDetail addFaultDetail() { - try { - Detail saajDetail = getSaajFault().addDetail(); - return new SaajSoapFaultDetail(saajDetail); - } - catch (SOAPException ex) { - throw new SaajSoapFaultException(ex); - } - - } - - protected final SOAPFault getSaajFault() { - return (SOAPFault) getSaajElement(); - } - -} 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 deleted file mode 100644 index d8778d18..00000000 --- a/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapFaultDetail.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2006 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * * limitations under the License. - */ - -package org.springframework.ws.soap.saaj; - -import java.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 org.springframework.util.Assert; -import org.springframework.ws.soap.SoapFaultDetail; -import org.springframework.ws.soap.SoapFaultDetailElement; - -class SaajSoapFaultDetail extends SaajSoapElement implements SoapFaultDetail { - - public SaajSoapFaultDetail(Detail detail, SaajImplementationStrategy strategy) { - super(detail, strategy); - } - - public SoapFaultDetailElement addFaultDetailElement(QName name) { - try { - DetailEntry detailEntry = getStrategy().addDetailEntry(getSaajDetail(), name); - return new SaajSoapFaultDetailElement(detailEntry, getStrategy()); - } - catch (SOAPException ex) { - throw new SaajSoapFaultException(ex); - } - } - - public Result getResult() { - return getStrategy().getResult(getSaajDetail()); - } - - public Iterator getDetailEntries() { - return new SaajSoapFaultDetailIterator(getSaajDetail().getDetailEntries()); - } - - protected Detail getSaajDetail() { - return (Detail) getSaajElement(); - } - - private class SaajSoapFaultDetailIterator implements Iterator { - - private final Iterator saajIterator; - - public SaajSoapFaultDetailIterator(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 SaajSoapFaultDetailElement(saajDetailEntry, getStrategy()); - } - - public void remove() { - saajIterator.remove(); - } - } - -} diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapFaultDetailElement.java b/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapFaultDetailElement.java deleted file mode 100644 index f0dd903f..00000000 --- a/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapFaultDetailElement.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2006 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * * limitations under the License. - */ - -package org.springframework.ws.soap.saaj; - -import javax.xml.soap.DetailEntry; -import javax.xml.soap.SOAPException; -import javax.xml.transform.Result; - -import org.springframework.ws.soap.SoapFaultDetailElement; - -/** - * @author Arjen Poutsma - */ -public class SaajSoapFaultDetailElement extends SaajSoapElement implements SoapFaultDetailElement { - - public SaajSoapFaultDetailElement(DetailEntry detailEntry, SaajImplementationStrategy strategy) { - super(detailEntry, strategy); - } - - public Result getResult() { - return getStrategy().getResult(getSaajDetailEntry()); - } - - public void addText(String text) { - try { - getSaajDetailEntry().addTextNode(text); - } - catch (SOAPException ex) { - throw new SaajSoapFaultException(ex); - } - } - - protected DetailEntry getSaajDetailEntry() { - return (DetailEntry) getSaajElement(); - } -} 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 deleted file mode 100644 index 089316ae..00000000 --- a/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapHeader.java +++ /dev/null @@ -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; - -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.SoapHeaderException; - -class SaajSoapHeader extends SaajSoapElement implements SoapHeader { - - public SaajSoapHeader(SOAPHeader header, SaajImplementationStrategy strategy) { - super(header, strategy); - } - - public SoapHeaderElement addHeaderElement(QName name) throws SoapHeaderException { - try { - SOAPHeaderElement saajHeaderElement = getStrategy().addHeaderElement(getSaajHeader(), name); - return new SaajSoapHeaderElement(saajHeaderElement, getStrategy()); - } - catch (SOAPException ex) { - throw new SaajSoapHeaderException(ex); - } - } - - public Iterator examineMustUnderstandHeaderElements(String role) { - return new SaajSoapHeaderElementIterator(getStrategy().examineMustUnderstandHeaderElements(getSaajHeader(), role)); - } - - protected final SOAPHeader getSaajHeader() { - return (SOAPHeader) getSaajElement(); - } - - private 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 SaajSoapHeaderElement(saajHeaderElement, getStrategy()); - } - - public void remove() { - saajIterator.remove(); - } - } - -} diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapHeaderElement.java b/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapHeaderElement.java deleted file mode 100644 index 92199b07..00000000 --- a/core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapHeaderElement.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2006 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * * limitations under the License. - */ - -package org.springframework.ws.soap.saaj; - -import javax.xml.soap.SOAPHeaderElement; -import javax.xml.transform.Result; - -import org.springframework.ws.soap.SoapHeaderElement; -import org.springframework.ws.soap.SoapHeaderException; - -class SaajSoapHeaderElement extends SaajSoapElement implements SoapHeaderElement { - - public SaajSoapHeaderElement(SOAPHeaderElement headerElement, SaajImplementationStrategy strategy) { - super(headerElement, strategy); - } - - public String getActorOrRole() throws SoapHeaderException { - return getSaajHeaderElement().getActor(); - } - - public void setActorOrRole(String actorOrRole) throws SoapHeaderException { - getSaajHeaderElement().setActor(actorOrRole); - } - - public boolean getMustUnderstand() throws SoapHeaderException { - return getSaajHeaderElement().getMustUnderstand(); - } - - public void setMustUnderstand(boolean mustUnderstand) throws SoapHeaderException { - getSaajHeaderElement().setMustUnderstand(mustUnderstand); - } - - public Result getResult() throws SoapHeaderException { - return getStrategy().getResult(getSaajHeaderElement()); - } - - protected SOAPHeaderElement getSaajHeaderElement() { - return (SOAPHeaderElement) getSaajElement(); - } -} 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 0a1de34f..ab3c0433 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,6 +27,7 @@ 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; @@ -72,12 +73,18 @@ public abstract class SaajSoapMessage extends AbstractSoapMessage { public final SoapEnvelope getEnvelope() { if (envelope == null) { - envelope = createSaajSoapEnvelope(saajMessage); + try { + SOAPEnvelope saajEnvelope = saajMessage.getSOAPPart().getEnvelope(); + envelope = createSaajSoapEnvelope(saajEnvelope); + } + catch (SOAPException ex) { + throw new SaajSoapEnvelopeException(ex); + } } return envelope; } - protected abstract SoapEnvelope createSaajSoapEnvelope(SOAPMessage saajMessage); + protected abstract SoapEnvelope createSaajSoapEnvelope(SOAPEnvelope saajEnvelope); 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 deleted file mode 100644 index 5eee5ebe..00000000 --- a/core/src/main/java/org/springframework/ws/soap/saaj/saaj11/Saaj11Soap11Body.java +++ /dev/null @@ -1,150 +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.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 deleted file mode 100644 index c731da41..00000000 --- a/core/src/main/java/org/springframework/ws/soap/saaj/saaj11/Saaj11Soap11Fault.java +++ /dev/null @@ -1,79 +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.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 deleted file mode 100644 index acbdcc7d..00000000 --- a/core/src/main/java/org/springframework/ws/soap/saaj/saaj11/Saaj11SoapElement.java +++ /dev/null @@ -1,50 +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.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 deleted file mode 100644 index 2f7d0efd..00000000 --- a/core/src/main/java/org/springframework/ws/soap/saaj/saaj11/Saaj11SoapEnvelope.java +++ /dev/null @@ -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.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 deleted file mode 100644 index 66af03fc..00000000 --- a/core/src/main/java/org/springframework/ws/soap/saaj/saaj11/Saaj11SoapMessage.java +++ /dev/null @@ -1,51 +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.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 deleted file mode 100644 index dadefd55..00000000 --- a/core/src/main/java/org/springframework/ws/soap/saaj/saaj11/Saaj12XmlReader.java +++ /dev/null @@ -1,111 +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.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. - *

- * Note that the given 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/Saaj12Soap11Body.java b/core/src/main/java/org/springframework/ws/soap/saaj/saaj12/Saaj12Soap11Body.java index 129085ea..3ae17233 100644 --- a/core/src/main/java/org/springframework/ws/soap/saaj/saaj12/Saaj12Soap11Body.java +++ b/core/src/main/java/org/springframework/ws/soap/saaj/saaj12/Saaj12Soap11Body.java @@ -57,7 +57,7 @@ class Saaj12Soap11Body extends Saaj12SoapElement implements Soap11Body { "A fault code with namespace and local part must be specific for a custom fault code"); } try { - Name name = SaajUtils.toName(faultCode, getSaajBody(), getEnvelope()); + Name name = SaajUtils.toName(faultCode, getSaajBody()); getSaajBody().removeContents(); SOAPFault saajFault; if (faultStringLocale == null) { diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/saaj12/Saaj12SoapFaultDetail.java b/core/src/main/java/org/springframework/ws/soap/saaj/saaj12/Saaj12SoapFaultDetail.java index cc0f2210..db7575d2 100644 --- a/core/src/main/java/org/springframework/ws/soap/saaj/saaj12/Saaj12SoapFaultDetail.java +++ b/core/src/main/java/org/springframework/ws/soap/saaj/saaj12/Saaj12SoapFaultDetail.java @@ -21,7 +21,6 @@ import javax.xml.namespace.QName; import javax.xml.soap.Detail; import javax.xml.soap.DetailEntry; import javax.xml.soap.Name; -import javax.xml.soap.SOAPEnvelope; import javax.xml.soap.SOAPException; import javax.xml.transform.Result; import javax.xml.transform.dom.DOMResult; @@ -45,7 +44,7 @@ class Saaj12SoapFaultDetail extends Saaj12SoapElement implements SoapFaultDetail public SoapFaultDetailElement addFaultDetailElement(QName name) { try { - Name detailEntryName = SaajUtils.toName(name, getSaajDetail(), getEnvelope()); + Name detailEntryName = SaajUtils.toName(name, getSaajDetail()); DetailEntry saajDetailEntry = getSaajDetail().addDetailEntry(detailEntryName); return new Saaj12SoapFaultDetailElement(saajDetailEntry); } @@ -62,10 +61,6 @@ class Saaj12SoapFaultDetail extends Saaj12SoapElement implements SoapFaultDetail return new DOMResult(getSaajDetail()); } - private SOAPEnvelope getEnvelope() { - return (SOAPEnvelope) getSaajDetail().getParentElement().getParentElement().getParentElement(); - } - private Detail getSaajDetail() { return (Detail) getSaajElement(); } diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/saaj12/Saaj12SoapHeader.java b/core/src/main/java/org/springframework/ws/soap/saaj/saaj12/Saaj12SoapHeader.java index 2c91326b..8c2d1add 100644 --- a/core/src/main/java/org/springframework/ws/soap/saaj/saaj12/Saaj12SoapHeader.java +++ b/core/src/main/java/org/springframework/ws/soap/saaj/saaj12/Saaj12SoapHeader.java @@ -19,7 +19,6 @@ 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.SOAPEnvelope; import javax.xml.soap.SOAPException; import javax.xml.soap.SOAPHeader; import javax.xml.soap.SOAPHeaderElement; @@ -42,7 +41,7 @@ class Saaj12SoapHeader extends Saaj12SoapElement implements SoapHeader { public SoapHeaderElement addHeaderElement(QName name) { try { - Name saajName = SaajUtils.toName(name, getSaajHeader(), getEnvelope()); + Name saajName = SaajUtils.toName(name, getSaajHeader()); SOAPHeaderElement saajHeaderElement = getSaajHeader().addHeaderElement(saajName); return new Saaj12SoapHeaderElement(saajHeaderElement); } @@ -59,10 +58,6 @@ class Saaj12SoapHeader extends Saaj12SoapElement implements SoapHeader { return new Saaj12SoapHeaderElementIterator(getSaajHeader().examineMustUnderstandHeaderElements(role)); } - private SOAPEnvelope getEnvelope() { - return (SOAPEnvelope) getSaajHeader().getParentElement(); - } - private SOAPHeader getSaajHeader() { return (SOAPHeader) getSaajElement(); } diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/saaj12/Saaj12SoapHeaderElement.java b/core/src/main/java/org/springframework/ws/soap/saaj/saaj12/Saaj12SoapHeaderElement.java index 0bb7d504..a65e2b4d 100644 --- a/core/src/main/java/org/springframework/ws/soap/saaj/saaj12/Saaj12SoapHeaderElement.java +++ b/core/src/main/java/org/springframework/ws/soap/saaj/saaj12/Saaj12SoapHeaderElement.java @@ -18,7 +18,6 @@ package org.springframework.ws.soap.saaj.saaj12; import javax.xml.namespace.QName; import javax.xml.soap.Name; -import javax.xml.soap.SOAPEnvelope; import javax.xml.soap.SOAPException; import javax.xml.soap.SOAPHeaderElement; import javax.xml.transform.Result; @@ -62,7 +61,7 @@ class Saaj12SoapHeaderElement extends Saaj12SoapElement implements SoapHeaderEle public void addAttribute(QName name, String value) throws SoapHeaderException { try { - Name saajName = SaajUtils.toName(name, getSaajHeaderElement(), getEnvelope()); + Name saajName = SaajUtils.toName(name, getSaajHeaderElement()); getSaajHeaderElement().addAttribute(saajName, value); } catch (SOAPException ex) { @@ -70,10 +69,6 @@ class Saaj12SoapHeaderElement extends Saaj12SoapElement implements SoapHeaderEle } } - private SOAPEnvelope getEnvelope() { - return (SOAPEnvelope) getSaajHeaderElement().getParentElement().getParentElement(); - } - private SOAPHeaderElement getSaajHeaderElement() { return (SOAPHeaderElement) getSaajElement(); } 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 4b0f7beb..9a416c74 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,11 +16,10 @@ package org.springframework.ws.soap.saaj.saaj12; -import javax.xml.soap.SOAPException; +import javax.xml.soap.SOAPEnvelope; 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; /** @@ -37,13 +36,8 @@ class Saaj12SoapMessage extends SaajSoapMessage { super(soapMessage); } - protected SoapEnvelope createSaajSoapEnvelope(SOAPMessage saajMessage) { - try { - return new Saaj12SoapEnvelope(saajMessage.getSOAPPart().getEnvelope()); - } - catch (SOAPException ex) { - throw new SaajSoapEnvelopeException(ex); - } + protected SoapEnvelope createSaajSoapEnvelope(SOAPEnvelope saajEnvelope) { + return new Saaj12SoapEnvelope(saajEnvelope); } } 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 7513eac7..0a96a428 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,11 +16,10 @@ package org.springframework.ws.soap.saaj.saaj13; -import javax.xml.soap.SOAPException; +import javax.xml.soap.SOAPEnvelope; 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 { @@ -34,12 +33,7 @@ class Saaj13SoapMessage extends SaajSoapMessage { super(soapMessage); } - protected SoapEnvelope createSaajSoapEnvelope(SOAPMessage saajMessage) { - try { - return new Saaj13SoapEnvelope(saajMessage.getSOAPPart().getEnvelope()); - } - catch (SOAPException ex) { - throw new SaajSoapEnvelopeException(ex); - } + protected SoapEnvelope createSaajSoapEnvelope(SOAPEnvelope saajEnvelope) { + return new Saaj13SoapEnvelope(saajEnvelope); } } diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/support/SaajUtils.java b/core/src/main/java/org/springframework/ws/soap/saaj/support/SaajUtils.java index effc020b..5680f08b 100644 --- a/core/src/main/java/org/springframework/ws/soap/saaj/support/SaajUtils.java +++ b/core/src/main/java/org/springframework/ws/soap/saaj/support/SaajUtils.java @@ -60,7 +60,7 @@ public abstract class SaajUtils { saajVersion = SAAJ_13; } catch (ClassNotFoundException ex) { - if (Element.class.isAssignableFrom(SOAPElement.class)) { + if (Element.class.isAssignableFrom(SOAPElement.class) && !isWebLogic9Implementation()) { saajVersion = SAAJ_12; } else { @@ -73,7 +73,6 @@ public abstract class SaajUtils { * Checks whether we are dealing with a WebLogic 9 implementation of SAAJ. WebLogic 9 does implement SAAJ 1.2, but * throws UnsupportedOperationExceptions when a SAAJ 1.2 method is called. */ -/* private static boolean isWebLogic9Implementation() { try { MessageFactory messageFactory = MessageFactory.newInstance(); @@ -90,7 +89,6 @@ public abstract class SaajUtils { return false; } } -*/ /** * Gets the SAAJ version. @@ -120,14 +118,14 @@ public abstract class SaajUtils { return envelope.createName(qName.getLocalPart(), qNamePrefix, qName.getNamespaceURI()); } else if (StringUtils.hasLength(qName.getNamespaceURI())) { - Iterator prefixes = resolveElement.getNamespacePrefixes(); + Iterator prefixes = resolveElement.getVisibleNamespacePrefixes(); while (prefixes.hasNext()) { String prefix = (String) prefixes.next(); if (qName.getNamespaceURI().equals(resolveElement.getNamespaceURI(prefix))) { return envelope.createName(qName.getLocalPart(), prefix, qName.getNamespaceURI()); } } - throw new IllegalArgumentException("Could not resolve prefix of QName [" + qName + "]"); + throw new IllegalArgumentException("Could not resolve namespace of QName [" + qName + "]"); } else { return envelope.createName(qName.getLocalPart()); diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/support/SoapElementContentHandler.java b/core/src/main/java/org/springframework/ws/soap/saaj/support/SoapElementContentHandler.java deleted file mode 100644 index 094b0527..00000000 --- a/core/src/main/java/org/springframework/ws/soap/saaj/support/SoapElementContentHandler.java +++ /dev/null @@ -1,92 +0,0 @@ -package org.springframework.ws.soap.saaj.support; - -import javax.xml.soap.Name; -import javax.xml.soap.SOAPElement; -import javax.xml.soap.SOAPEnvelope; -import javax.xml.soap.SOAPException; - -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.DefaultHandler; - -/** - * @author Arjen Poutsma - */ -public class SoapElementContentHandler extends DefaultHandler { - - private final SOAPEnvelope envelope; - - private SOAPElement current; - - private static final String XMLNS = "xmlns"; - - public SoapElementContentHandler(SOAPElement element) { - this.envelope = SaajUtils.getEnvelope(element); - this.current = element; - } - - public void characters(char ch[], int start, int length) throws SAXException { - try { - current.addTextNode(new String(ch, start, length)); - } - catch (SOAPException ex) { - throw new SAXException(ex); - } - } - - public void endPrefixMapping(String prefix) throws SAXException { - current.removeNamespaceDeclaration(prefix); - } - - public void startPrefixMapping(String prefix, String uri) throws SAXException { - try { - current.addNamespaceDeclaration(prefix, uri); - } - catch (SOAPException ex) { - throw new SAXException(ex); - } - } - - public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { - try { - Name elementName = createName(uri, qName); - SOAPElement child = current.addChildElement(elementName); - for (int i = 0; i < attributes.getLength(); i++) { - Name attributeName = createName(attributes.getURI(i), attributes.getQName(i)); - if (attributeName != null) { - child.addAttribute(attributeName, attributes.getValue(i)); - } else { - int idx = attributes.getQName(i).indexOf(':'); - String prefix = attributes.getQName(i).substring(idx+1); - child.addNamespaceDeclaration(prefix, attributes.getValue(i)); - } - } - current = child; - } - catch (SOAPException ex) { - throw new SAXException(ex); - } - } - - private Name createName(String namespaceUri, String qualifiedName) throws SOAPException { - int idx = qualifiedName.indexOf(':'); - String localName = qualifiedName.substring(idx + 1); - if (idx == -1) { - return envelope.createName(localName, "", namespaceUri); - } - else { - String prefix = qualifiedName.substring(0, idx); - if (!XMLNS.equals(prefix)) { - return envelope.createName(localName, prefix, namespaceUri); - } - else { - return null; - } - } - - } - - public void endElement(String uri, String localName, String qName) throws SAXException { - current = current.getParentElement(); - } -} diff --git a/core/src/main/java/org/springframework/ws/soap/saaj/support/SoapElementXmlReader.java b/core/src/main/java/org/springframework/ws/soap/saaj/support/SoapElementXmlReader.java deleted file mode 100644 index 56dc0e38..00000000 --- a/core/src/main/java/org/springframework/ws/soap/saaj/support/SoapElementXmlReader.java +++ /dev/null @@ -1,112 +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.support; - -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; - -/** - * SAX XMLReader that can read from a SAAJ SOAPElement - * @author Arjen Poutsma - */ -public class SoapElementXmlReader extends AbstractXmlReader { - - private SOAPElement element; - - public SoapElementXmlReader(SOAPElement element) { - this.element = element; - } - - /** - * Parses the StAX XML reader passed at construction-time. - *

- * Note that the given 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/test/java/org/springframework/ws/soap/AbstractSoapHeaderTestCase.java b/core/src/test/java/org/springframework/ws/soap/AbstractSoapHeaderTestCase.java index 4acb4798..070fc323 100644 --- a/core/src/test/java/org/springframework/ws/soap/AbstractSoapHeaderTestCase.java +++ b/core/src/test/java/org/springframework/ws/soap/AbstractSoapHeaderTestCase.java @@ -43,13 +43,33 @@ public abstract class AbstractSoapHeaderTestCase extends XMLTestCase { QName qName = new QName("http://www.springframework.org", "localName", "spring"); SoapHeaderElement headerElement = soapHeader.addHeaderElement(qName); assertEquals("Invalid qName for element", qName, headerElement.getName()); - String payload = ""; assertNotNull("No SoapHeaderElement returned", headerElement); + String payload = ""; transformer.transform(new StringSource(payload), headerElement.getResult()); assertHeaderElementEqual(headerElement, ""); } + public void testExamineAllHeaderElement() throws Exception { + QName qName = new QName("http://www.springframework.org", "localName", "spring"); + SoapHeaderElement headerElement = soapHeader.addHeaderElement(qName); + assertEquals("Invalid qName for element", qName, headerElement.getName()); + assertNotNull("No SoapHeaderElement returned", headerElement); + String payload = ""; + transformer.transform(new StringSource(payload), headerElement.getResult()); + Iterator iterator = soapHeader.examineAllHeaderElements(); + assertNotNull("header element iterator is null", iterator); + assertTrue("header element iterator has no elements", iterator.hasNext()); + headerElement = (SoapHeaderElement) iterator.next(); + assertEquals("Invalid qName for element", qName, headerElement.getName()); + StringResult result = new StringResult(); + transformer.transform(headerElement.getSource(), result); + assertXMLEqual("Invalid contents of header element", + "", + result.toString()); + assertFalse("header element iterator has too many elements", iterator.hasNext()); + } + public void testExamineMustUnderstandHeaderElements() throws Exception { QName qName1 = new QName("http://www.springframework.org", "localName1", "spring"); SoapHeaderElement headerElement1 = soapHeader.addHeaderElement(qName1); diff --git a/core/src/test/java/org/springframework/ws/soap/saaj/Saaj11ImplementationStrategyTest.java b/core/src/test/java/org/springframework/ws/soap/saaj/Saaj11ImplementationStrategyTest.java deleted file mode 100644 index 02ce273e..00000000 --- a/core/src/test/java/org/springframework/ws/soap/saaj/Saaj11ImplementationStrategyTest.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2006 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * * limitations under the License. - */ - -package org.springframework.ws.soap.saaj; - -import javax.xml.namespace.QName; -import javax.xml.soap.Detail; -import javax.xml.soap.DetailEntry; -import javax.xml.soap.MessageFactory; -import javax.xml.soap.SOAPBody; -import javax.xml.soap.SOAPEnvelope; -import javax.xml.soap.SOAPFault; -import javax.xml.soap.SOAPHeader; -import javax.xml.soap.SOAPMessage; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerFactory; - -import org.custommonkey.xmlunit.XMLTestCase; -import org.springframework.ws.soap.SoapVersion; -import org.springframework.xml.transform.StringResult; -import org.springframework.xml.transform.StringSource; - -public class Saaj11ImplementationStrategyTest extends XMLTestCase { - - private Saaj11ImplementationStrategy strategy; - - private SOAPMessage message; - - private SOAPEnvelope envelope; - - private Transformer transformer; - - protected void setUp() throws Exception { - strategy = new Saaj11ImplementationStrategy(); - MessageFactory messageFactory = MessageFactory.newInstance(); - message = messageFactory.createMessage(); - envelope = message.getSOAPPart().getEnvelope(); - TransformerFactory transformerFactory = TransformerFactory.newInstance(); - transformer = transformerFactory.newTransformer(); - } - - public void testGetName() throws Exception { - QName name = strategy.getName(envelope); - assertEquals("Invalid name", SoapVersion.SOAP_11.getEnvelopeName(), name); - } - - public void testGetSource() throws Exception { - StringResult result = new StringResult(); - transformer.transform(strategy.getSource(envelope), result); - - assertXMLEqual("Invalid source", - "

", - result.toString()); - } - - public void testGetResult() throws Exception { - SOAPBody body = envelope.getBody(); - StringSource content = new StringSource(""); - transformer.transform(content, strategy.getResult(body)); - - StringResult result = new StringResult(); - transformer.transform(strategy.getSource(envelope), result); - assertXMLEqual("Invalid source", - "
", - result.toString()); - } - - public void testGetFaultCode() throws Exception { - SOAPBody body = envelope.getBody(); - SOAPFault fault = body.addFault(); - fault.setFaultCode(fault.getElementName().getPrefix() + ":Client"); - QName faultCode = strategy.getFaultCode(fault); - assertEquals("Invalid fault code", SoapVersion.SOAP_11.getClientOrSenderFaultName(), faultCode); - } - - public void testAddDetailEntry() throws Exception { - SOAPBody body = envelope.getBody(); - SOAPFault fault = body.addFault(); - QName name = new QName("http://springframework.org/spring-ws", "name", "spring-ws"); - - Detail detail = fault.addDetail(); - DetailEntry result = strategy.addDetailEntry(detail, name); - assertNotNull("No result returned", result); - assertEquals("Invalid namespace", result.getElementName().getURI(), name.getNamespaceURI()); - assertEquals("Invalid namespace", result.getElementName().getLocalName(), name.getLocalPart()); - } - - public void testRemoveContents() throws Exception { - SOAPBody body = envelope.getBody(); - body.addTextNode("bla"); - body.addChildElement("bla"); - strategy.removeContents(body); - assertFalse("Children not removed", body.getChildElements().hasNext()); - } - - public void testAddHeaderElement() throws Exception { - SOAPHeader header = envelope.getHeader(); - - fail("Test is not implemented"); - } -} \ No newline at end of file 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 deleted file mode 100644 index de58d3b5..00000000 --- a/core/src/test/java/org/springframework/ws/soap/saaj/saaj11/Saaj11Soap11BodyTest.java +++ /dev/null @@ -1,40 +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.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 deleted file mode 100644 index d02b260b..00000000 --- a/core/src/test/java/org/springframework/ws/soap/saaj/saaj11/Saaj11Soap11EnvelopeTest.java +++ /dev/null @@ -1,35 +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.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 deleted file mode 100644 index 80c53d72..00000000 --- a/core/src/test/java/org/springframework/ws/soap/saaj/saaj11/Saaj11Soap11MessageTest.java +++ /dev/null @@ -1,30 +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.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 deleted file mode 100644 index c5efda10..00000000 --- a/core/src/test/java/org/springframework/ws/soap/saaj/saaj11/Saaj12XmlReaderTest.java +++ /dev/null @@ -1,72 +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.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/core/src/test/java/org/springframework/ws/soap/saaj/support/SaajUtilsTest.java b/core/src/test/java/org/springframework/ws/soap/saaj/support/SaajUtilsTest.java index 668b5ae5..3ccc0642 100644 --- a/core/src/test/java/org/springframework/ws/soap/saaj/support/SaajUtilsTest.java +++ b/core/src/test/java/org/springframework/ws/soap/saaj/support/SaajUtilsTest.java @@ -114,12 +114,4 @@ public class SaajUtilsTest extends XMLTestCase { public void testGetSaajVersion() throws Exception { assertEquals("Invalid SAAJ version", SaajUtils.SAAJ_13, SaajUtils.getSaajVersion()); } - - public void testGetEnvelope() throws Exception { - SOAPMessage message = messageFactory.createMessage(); - SOAPEnvelope envelope = message.getSOAPPart().getEnvelope(); - assertSame("Invalid envelope returned", envelope, SaajUtils.getEnvelope(envelope)); - assertSame("Invalid envelope returned", envelope, SaajUtils.getEnvelope(envelope.getBody())); - assertSame("Invalid envelope returned", envelope, SaajUtils.getEnvelope(envelope.getHeader())); - } } \ No newline at end of file diff --git a/core/src/test/java/org/springframework/ws/soap/saaj/support/SoapElementContentHandlerTest.java b/core/src/test/java/org/springframework/ws/soap/saaj/support/SoapElementContentHandlerTest.java deleted file mode 100644 index 71e92c10..00000000 --- a/core/src/test/java/org/springframework/ws/soap/saaj/support/SoapElementContentHandlerTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.springframework.ws.soap.saaj.support; - -import javax.xml.soap.MessageFactory; -import javax.xml.soap.SOAPConstants; -import javax.xml.soap.SOAPMessage; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMResult; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.sax.SAXResult; - -import org.custommonkey.xmlunit.XMLTestCase; -import org.springframework.xml.transform.StringSource; - -public class SoapElementContentHandlerTest extends XMLTestCase { - - private SOAPMessage message; - - private Transformer transformer; - - private SOAPMessage expected; - - protected void setUp() throws Exception { - MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL); - message = messageFactory.createMessage(); - expected = messageFactory.createMessage(); - TransformerFactory transformerFactory = TransformerFactory.newInstance(); - transformer = transformerFactory.newTransformer(); - } - - public void testWriteToPayload() throws Exception { - StringSource contents = new StringSource( - "" + "DIS" + - ""); - transformer.transform(contents, new DOMResult(expected.getSOAPBody())); - SoapElementContentHandler handler = - new SoapElementContentHandler(message.getSOAPPart().getEnvelope(), message.getSOAPBody()); - transformer.transform(new DOMSource(expected.getSOAPBody().getFirstChild()), new SAXResult(handler)); - assertXMLEqual(expected.getSOAPPart(), message.getSOAPPart()); - } -} \ No newline at end of file diff --git a/core/src/test/java/org/springframework/ws/soap/saaj/support/SoapElementXmlReaderTest.java b/core/src/test/java/org/springframework/ws/soap/saaj/support/SoapElementXmlReaderTest.java deleted file mode 100644 index fb60f491..00000000 --- a/core/src/test/java/org/springframework/ws/soap/saaj/support/SoapElementXmlReaderTest.java +++ /dev/null @@ -1,71 +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.support; - -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.xml.transform.StringResult; -import org.xml.sax.InputSource; - -public class SoapElementXmlReaderTest 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(); - SoapElementXmlReader reader = new SoapElementXmlReader(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(); - SoapElementXmlReader reader = new SoapElementXmlReader(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