Rolled back to previous version of SAAJ. SAAJ 1.1 is never going to work, especially not under Weblogic 8.1.

This commit is contained in:
Arjen Poutsma
2006-10-19 09:07:59 +00:00
parent 4a112c85a8
commit 1b29d8bdc6
41 changed files with 52 additions and 2186 deletions

View File

@@ -49,4 +49,13 @@ public interface SoapHeader extends SoapElement {
* @see SoapHeaderElement
*/
Iterator examineMustUnderstandHeaderElements(String actorOrRole) throws SoapHeaderException;
/**
* Returns an <code>Iterator</code> over all the <code>SoapHeaderElement</code>s 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;
}

View File

@@ -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 <code>SaajImplementationStrategy</code>.
*
* @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();
}
}

View File

@@ -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();
}
}

View File

@@ -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();
}
}

View File

@@ -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.
* <p/>
* 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;
}

View File

@@ -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());
}
}

View File

@@ -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());
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}
}

View File

@@ -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 <code>null</code> 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();
}
}

View File

@@ -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);
}
}

View File

@@ -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();
}
}

View File

@@ -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();
}
}
}

View File

@@ -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();
}
}

View File

@@ -1,75 +0,0 @@
/*
* Copyright 2006 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* * limitations under the License.
*/
package org.springframework.ws.soap.saaj;
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();
}
}
}

View File

@@ -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();
}
}

View File

@@ -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 {

View File

@@ -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 <code>null</code> if none is set.
*/
private SOAPBodyElement getPayloadElement() {
for (Iterator iterator = getSaajBody().getChildElements(); iterator.hasNext();) {
Object child = iterator.next();
if (child instanceof SOAPBodyElement) {
return (SOAPBodyElement) child;
}
}
return null;
}
protected final SOAPBody getSaajBody() {
return (SOAPBody) getSaajElement();
}
}

View File

@@ -1,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");
}
}

View File

@@ -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());
}
}

View File

@@ -1,84 +0,0 @@
/*
* Copyright 2006 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ws.soap.saaj.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();
}
}

View File

@@ -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 <code>SoapMessage</code> interface. Accessed via the
* <code>SaajSoapMessageContext</code>.
*
* @author Arjen Poutsma
* @see javax.xml.soap.SOAPMessage
* @see org.springframework.ws.soap.saaj.SaajSoapMessageContext
*/
class 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);
}
}
}

View File

@@ -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.
* <p/>
* <strong>Note</strong> that the given <code>InputSource</code> is not read, but ignored.
*
* @param ignored is ignored
* @throws SAXException A SAX exception, possibly wrapping a <code>XMLStreamException</code>
*/
public final void parse(InputSource ignored) throws SAXException {
handleNode(element);
}
/**
* Parses the StAX XML reader passed at construction-time.
* <p/>
* <strong>Note</strong> that the given system identifier is not read, but ignored.
*
* @param ignored is ignored
* @throws SAXException A SAX exception, possibly wrapping a <code>XMLStreamException</code>
*/
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;
}
}

View File

@@ -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) {

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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());

View File

@@ -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();
}
}

View File

@@ -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 <code>XMLReader</code> that can read from a SAAJ <code>SOAPElement</code>
* @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.
* <p/>
* <strong>Note</strong> that the given <code>InputSource</code> is not read, but ignored.
*
* @param ignored is ignored
* @throws SAXException A SAX exception, possibly wrapping a <code>XMLStreamException</code>
*/
public final void parse(InputSource ignored) throws SAXException {
handleNode(element);
}
/**
* Parses the StAX XML reader passed at construction-time.
* <p/>
* <strong>Note</strong> that the given system identifier is not read, but ignored.
*
* @param ignored is ignored
* @throws SAXException A SAX exception, possibly wrapping a <code>XMLStreamException</code>
*/
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;
}
}

View File

@@ -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 = "<content xmlns='http://www.springframework.org'/>";
assertNotNull("No SoapHeaderElement returned", headerElement);
String payload = "<content xmlns='http://www.springframework.org'/>";
transformer.transform(new StringSource(payload), headerElement.getResult());
assertHeaderElementEqual(headerElement,
"<spring:localName xmlns:spring='http://www.springframework.org'><spring:content/></spring:localName>");
}
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 = "<content xmlns='http://www.springframework.org'/>";
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",
"<spring:localName xmlns:spring='http://www.springframework.org'><spring:content/></spring:localName>",
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);

View File

@@ -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",
"<Envelope xmlns='http://schemas.xmlsoap.org/soap/envelope/'><Header/><Body/></Envelope>",
result.toString());
}
public void testGetResult() throws Exception {
SOAPBody body = envelope.getBody();
StringSource content = new StringSource("<content xmlns='http://springframework.org/spring-ws'/>");
transformer.transform(content, strategy.getResult(body));
StringResult result = new StringResult();
transformer.transform(strategy.getSource(envelope), result);
assertXMLEqual("Invalid source",
"<Envelope xmlns='http://schemas.xmlsoap.org/soap/envelope/'><Header/><Body><content xmlns='http://springframework.org/spring-ws'/></Body></Envelope>",
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");
}
}

View File

@@ -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));
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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());
}
}

View File

@@ -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()));
}
}

View File

@@ -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(
"<m:GetLastTradePrice xmlns:m='http://www.springframework.org/spring-ws'>" + "<symbol>DIS</symbol>" +
"</m:GetLastTradePrice>");
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());
}
}

View File

@@ -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());
}
}