SWS-1047 - Remove sandbox project.

sandbox was used in the days for svn work when feature branches were unavailable.
This commit is contained in:
Greg Turnquist
2018-12-10 13:10:01 -06:00
parent e8d89c9eb0
commit cd27d471b6
51 changed files with 0 additions and 4099 deletions

6
sandbox/.gitignore vendored
View File

@@ -1,6 +0,0 @@
target
*.iml
.classpath
.project
.settings

View File

@@ -1,22 +0,0 @@
/*
* Copyright 2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* 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.client.object;
/** @author Arjen Poutsma */
public abstract class MarshallingInvocation extends WebServiceInvocation {
}

View File

@@ -1,40 +0,0 @@
/*
* Copyright 2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* 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.client.object;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.ws.client.core.WebServiceTemplate;
/** @author Arjen Poutsma */
public abstract class WebServiceInvocation {
/** Logger available to subclasses. */
protected final Log logger = LogFactory.getLog(getClass());
/** Lower-level class used to invoke Web service. */
private WebServiceTemplate webServiceTemplate = new WebServiceTemplate();
/** Returns the {@link WebServiceTemplate} used by this object. */
public WebServiceTemplate getWebServiceTemplate() {
return webServiceTemplate;
}
public void setWebServiceTemplate(WebServiceTemplate webServiceTemplate) {
this.webServiceTemplate = webServiceTemplate;
}
}

View File

@@ -1,12 +0,0 @@
<html>
<body>
Contains classes that represent Web service invocations as threadsafe, reusable objects. This approach is similar to
the JDBC Object support in the Spring framework (see the <code>org.springframework.jdbc.object</code> package).
<p>
This higher level of Web service abstraction depends on the lower-level
abstraction in the <code>org.springframework.jdbc.core</code> package.
Exceptions thrown are as in the <code>org.springframework.dao</code> package,
meaning that code using this package does not need to implement JDBC or
RDBMS-specific error handling.
</body>
</html>

View File

@@ -1,81 +0,0 @@
/*
* Copyright 2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* 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.jaxws;
import javax.xml.soap.SOAPMessage;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.ws.Provider;
import javax.xml.ws.Service;
import javax.xml.ws.ServiceMode;
import javax.xml.ws.WebServiceProvider;
import org.springframework.ws.WebServiceMessage;
import org.springframework.ws.context.MessageContext;
import org.springframework.ws.server.EndpointAdapter;
import org.springframework.ws.soap.saaj.SaajSoapMessage;
import org.springframework.xml.transform.TransformerObjectSupport;
/**
* Adapter to use a JAX-WS {@link Provider} as the endpoint for a <code>EndpointInvocationChain</code>. Supports both
* message and payload providers.
*
* @author Arjen Poutsma
*/
public class JaxWsProviderEndpointAdapter extends TransformerObjectSupport implements EndpointAdapter {
public boolean supports(Object endpoint) {
return endpoint.getClass().getAnnotation(WebServiceProvider.class) != null && endpoint instanceof Provider;
}
public void invoke(MessageContext messageContext, Object endpoint) throws Exception {
ServiceMode serviceMode = endpoint.getClass().getAnnotation(ServiceMode.class);
if (serviceMode == null || Service.Mode.PAYLOAD.equals(serviceMode.value())) {
invokeSourceProvider(messageContext, (Provider<Source>) endpoint);
}
else if (Service.Mode.MESSAGE.equals(serviceMode.value())) {
Provider<SOAPMessage> provider = (Provider<SOAPMessage>) endpoint;
invokeMessageProvider(messageContext, provider);
}
}
private void invokeSourceProvider(MessageContext messageContext, Provider<Source> provider)
throws TransformerException {
Source requestSource = messageContext.getRequest().getPayloadSource();
Source responseSource = provider.invoke(requestSource);
if (responseSource != null) {
WebServiceMessage response = messageContext.getResponse();
Transformer transformer = createTransformer();
transformer.transform(responseSource, response.getPayloadResult());
}
}
private void invokeMessageProvider(MessageContext messageContext, Provider<SOAPMessage> provider) {
if (!(messageContext.getRequest() instanceof SaajSoapMessage)) {
throw new IllegalArgumentException("JaxWsProviderEndpointAdapter requires a SaajSoapMessage. " +
"Use a SaajSoapMessageFactory to create the SOAP messages.");
}
SaajSoapMessage request = (SaajSoapMessage) messageContext.getRequest();
SOAPMessage saajRequest = request.getSaajMessage();
SOAPMessage saajResponse = provider.invoke(saajRequest);
if (saajResponse != null) {
SaajSoapMessage response = (SaajSoapMessage) messageContext.getResponse();
response.setSaajMessage(saajResponse);
}
}
}

View File

@@ -1,228 +0,0 @@
/*
* Copyright 2005-2010 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;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.util.StopWatch;
import org.springframework.ws.soap.axiom.AxiomSoapMessageFactory;
import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;
import org.springframework.ws.soap.stroap.StroapMessageFactory;
import org.springframework.ws.stream.StreamingPayload;
import org.springframework.ws.stream.StreamingWebServiceMessage;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class PerformanceTest {
private static final Log logger = LogFactory.getLog(PerformanceTest.class);
private static final int ITERATIONS = 1000;
private static final int ELEMENTS = 500;
private SoapMessageFactory messageFactory;
private Marshaller marshaller;
private StopWatch stopWatch;
private MyRootElement jaxbElement;
private OutputStream os;
private boolean streaming = false;
private static final QName NAME = new QName("http://springframework.org", "root");
private Transformer transformer;
public PerformanceTest(SoapMessageFactory messageFactory, StopWatch stopWatch) throws Exception {
if (messageFactory instanceof InitializingBean) {
((InitializingBean) messageFactory).afterPropertiesSet();
}
this.messageFactory = messageFactory;
JAXBContext jaxbContext = JAXBContext.newInstance(MyRootElement.class);
marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
jaxbElement = new MyRootElement();
for (int i = 0; i < ELEMENTS; i++) {
jaxbElement.getStrings().add(String.valueOf(i));
}
os = new NullOutputSteam();
this.stopWatch = stopWatch;
this.transformer = TransformerFactory.newInstance().newTransformer();
}
public void test(boolean streaming) throws Exception {
String s = messageFactory.toString() + " streaming " + (streaming ? "enabled" : "disabled");
stopWatch.start(s);
logger.info(s);
for (int i = 0; i < ITERATIONS; i++) {
SoapMessage message = (SoapMessage) messageFactory.createWebServiceMessage();
marshal(message, streaming);
transformer.transform(message.getPayloadSource(), new StreamResult(os));
message.writeTo(os);
}
stopWatch.stop();
}
private void marshal(SoapMessage message, boolean streaming) throws JAXBException {
if (streaming && message instanceof StreamingWebServiceMessage) {
StreamingWebServiceMessage streamingMessage = (StreamingWebServiceMessage) message;
StreamingPayload payload = new JaxbStreamingPayload(jaxbElement, NAME, marshaller);
streamingMessage.setStreamingPayload(payload);
}
else {
marshaller.marshal(jaxbElement, message.getPayloadResult());
}
}
public static void main(String[] args) throws Exception {
StopWatch stopWatch = new StopWatch();
try {
saaj(stopWatch);
axiom(stopWatch, false, false);
axiom(stopWatch, true, false);
axiom(stopWatch, false, true);
axiom(stopWatch, true, true);
stroap(stopWatch, false, false);
stroap(stopWatch, true, false);
stroap(stopWatch, false, true);
stroap(stopWatch, true, true);
}
finally {
System.out.println(stopWatch.prettyPrint());
}
}
private static void saaj(StopWatch stopWatch) throws Exception {
SaajSoapMessageFactory ssmf = new SaajSoapMessageFactory();
PerformanceTest performanceTest = new PerformanceTest(ssmf, stopWatch);
performanceTest.test(false);
}
private static void axiom(StopWatch stopWatch, boolean caching, boolean streaming) throws Exception {
AxiomSoapMessageFactory axmf = new AxiomSoapMessageFactory();
axmf.setPayloadCaching(caching);
PerformanceTest performanceTest = new PerformanceTest(axmf, stopWatch);
performanceTest.test(streaming);
}
private static void stroap(StopWatch stopWatch, boolean caching, boolean streaming) throws Exception {
StroapMessageFactory smf = new StroapMessageFactory();
smf.setPayloadCaching(caching);
PerformanceTest performanceTest = new PerformanceTest(smf, stopWatch);
performanceTest.test(streaming);
}
@XmlRootElement(name = "root", namespace = "http://springframework.org")
public static class MyRootElement {
private List<String> strings;
@XmlElement(name = "string", namespace = "http://springframework.org")
public List<String> getStrings() {
if (strings == null) {
strings = new ArrayList<String>();
}
return strings;
}
}
private static class NullOutputSteam extends OutputStream {
@Override
public void write(int b) throws IOException {
}
@Override
public void write(byte[] b) throws IOException {
}
@Override
public void write(byte[] b, int off, int len) throws IOException {
}
@Override
public void flush() throws IOException {
}
@Override
public void close() throws IOException {
}
}
private static class JaxbStreamingPayload implements StreamingPayload {
private final Object jaxbElement;
private final QName name;
private final Marshaller marshaller;
private JaxbStreamingPayload(Object jaxbElement, QName name, Marshaller marshaller) {
this.jaxbElement = jaxbElement;
this.name = name;
this.marshaller = marshaller;
}
public QName getName() {
return name;
}
public void writeTo(XMLStreamWriter streamWriter) throws XMLStreamException {
try {
marshaller.marshal(jaxbElement, streamWriter);
}
catch (JAXBException ex) {
throw new XMLStreamException(ex);
}
}
}
}

View File

@@ -1,67 +0,0 @@
/*
* Copyright 2005-2010 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.stroap;
import java.util.LinkedList;
import java.util.List;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLEventWriter;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.XMLEvent;
import org.springframework.util.Assert;
import org.springframework.xml.stream.ListBasedXMLEventReader;
/**
* @author Arjen Poutsma
*/
class CachingStroapPayload extends StroapPayload {
private final List<XMLEvent> events = new LinkedList<XMLEvent>();
CachingStroapPayload() {
}
CachingStroapPayload(XMLEventReader eventReader) throws XMLStreamException {
Assert.notNull(eventReader, "'eventReader' must not be null");
XMLEventWriter eventWriter = getEventWriter();
eventWriter.add(eventReader);
}
@Override
public QName getName() {
if (!events.isEmpty()) {
XMLEvent event = events.get(0);
if (event.isStartElement()) {
return event.asStartElement().getName();
}
}
return null;
}
@Override
public XMLEventReader getEventReader() {
return new ListBasedXMLEventReader(events);
}
public XMLEventWriter getEventWriter() {
events.clear();
return new CachingXMLEventWriter(events);
}
}

View File

@@ -1,57 +0,0 @@
/*
* Copyright 2005-2010 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.stroap;
import java.util.List;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.XMLEvent;
import org.springframework.util.Assert;
import org.springframework.xml.stream.AbstractXMLEventWriter;
/**
* @author Arjen Poutsma
*/
class CachingXMLEventWriter extends AbstractXMLEventWriter {
private int elementDepth = 0;
boolean startElementSeen = false;
private final List<XMLEvent> events;
CachingXMLEventWriter(List<XMLEvent> events) {
Assert.notNull(events, "'events' must not be null");
this.events = events;
}
public void add(XMLEvent event) throws XMLStreamException {
if (event.isStartElement()) {
startElementSeen = true;
elementDepth++;
}
else if (event.isEndElement()) {
elementDepth--;
}
else if (event.isStartDocument() || event.isEndDocument()) {
return;
}
if (elementDepth >= 0 && startElementSeen) {
events.add(event);
}
}
}

View File

@@ -1,51 +0,0 @@
/*
* Copyright 2005-2010 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.stroap;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventReader;
import org.springframework.util.Assert;
import org.springframework.ws.soap.SoapFault;
/**
* @author Arjen Poutsma
*/
class FaultStroapPayload extends StroapPayload {
private final StroapFault fault;
FaultStroapPayload(StroapFault fault) {
Assert.notNull(fault, "'fault' must not be null");
this.fault = fault;
}
SoapFault getFault() {
return fault;
}
@Override
public QName getName() {
return fault.getName();
}
@Override
public XMLEventReader getEventReader() {
return fault.getEventReader(false);
}
}

View File

@@ -1,91 +0,0 @@
/*
* Copyright 2005-2010 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.stroap;
import java.util.NoSuchElementException;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.XMLEvent;
import org.springframework.util.Assert;
import org.springframework.xml.stream.AbstractXMLEventReader;
/**
* @author Arjen Poutsma
*/
class NonCachingStroapPayload extends StroapPayload {
private final XMLEventReader eventReader;
private int elementDepth = 0;
NonCachingStroapPayload(XMLEventReader eventReader) throws XMLStreamException {
Assert.notNull(eventReader, "'eventReader' must not be null");
this.eventReader = eventReader;
}
@Override
public QName getName() {
try {
XMLEvent event = eventReader.peek();
if (event != null && event.isStartElement()) {
return event.asStartElement().getName();
}
}
catch (XMLStreamException ex) {
// ignore
}
return null;
}
@Override
public XMLEventReader getEventReader() {
return new NonCachingXMLEventReader();
}
private class NonCachingXMLEventReader extends AbstractXMLEventReader {
public boolean hasNext() {
return elementDepth >= 0 && eventReader.hasNext();
}
public XMLEvent nextEvent() throws XMLStreamException {
if (elementDepth < 0) {
throw new NoSuchElementException();
}
XMLEvent event = eventReader.nextEvent();
if (event.isStartElement()) {
elementDepth++;
}
else if (event.isEndElement()) {
elementDepth--;
}
return event;
}
public XMLEvent peek() throws XMLStreamException {
if (elementDepth < 0) {
return null;
}
else {
return eventReader.peek();
}
}
}
}

View File

@@ -1,74 +0,0 @@
/*
* Copyright 2005-2010 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.stroap;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLEventWriter;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import org.springframework.util.Assert;
import org.springframework.util.xml.StaxUtils;
import org.springframework.ws.stream.StreamingPayload;
/**
* @author Arjen Poutsma
*/
class StreamingStroapPayload extends StroapPayload {
private final StreamingPayload payload;
private final StroapMessageFactory messageFactory;
StreamingStroapPayload(StreamingPayload payload, StroapMessageFactory messageFactory) {
Assert.notNull(payload, "'payload' must not be null");
Assert.notNull(messageFactory, "'messageFactory' must not be null");
this.payload = payload;
this.messageFactory = messageFactory;
}
@Override
public QName getName() {
return payload.getName();
}
@Override
public XMLEventReader getEventReader() {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
XMLStreamWriter streamWriter = messageFactory.getOutputFactory().createXMLStreamWriter(bos);
payload.writeTo(streamWriter);
streamWriter.flush();
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
return messageFactory.getInputFactory().createXMLEventReader(bis);
}
catch (XMLStreamException ex) {
throw new StroapBodyException(ex);
}
}
@Override
public void writeTo(XMLEventWriter eventWriter) throws XMLStreamException {
XMLStreamWriter streamWriter = StaxUtils.createEventStreamWriter(eventWriter, messageFactory.getEventFactory());
payload.writeTo(streamWriter);
}
}

View File

@@ -1,96 +0,0 @@
/*
* Copyright 2005-2010 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.stroap;
import java.util.Locale;
import javax.xml.namespace.QName;
import javax.xml.stream.events.StartElement;
import org.springframework.util.Assert;
import org.springframework.ws.soap.SoapFaultException;
import org.springframework.ws.soap.soap11.Soap11Body;
import org.springframework.ws.soap.soap11.Soap11Fault;
/**
* @author Arjen Poutsma
*/
class Stroap11Body extends StroapBody implements Soap11Body {
private static final String ENVELOPE_NAMESPACE_URI = "http://schemas.xmlsoap.org/soap/envelope/";
private QName CLIENT_FAULT_NAME = new QName(ENVELOPE_NAMESPACE_URI, "Client", DEFAULT_PREFIX);
private QName SERVER_FAULT_NAME = new QName(ENVELOPE_NAMESPACE_URI, "Server", DEFAULT_PREFIX);
private QName MUST_UNDERSTAND_FAULT_NAME = new QName(ENVELOPE_NAMESPACE_URI, "MustUnderstand", DEFAULT_PREFIX);
private QName VERSION_MISMATCH_FAULT_NAME = new QName(ENVELOPE_NAMESPACE_URI, "VersionMismatch", DEFAULT_PREFIX);
Stroap11Body(StroapMessageFactory messageFactory) {
super(messageFactory);
}
Stroap11Body(StartElement startElement, StroapPayload payload, StroapMessageFactory messageFactory) {
super(startElement, payload, messageFactory);
}
@Override
public Soap11Fault getFault() {
return (Soap11Fault) super.getFault();
}
public Soap11Fault addMustUnderstandFault(String faultStringOrReason, Locale locale) throws SoapFaultException {
Stroap11Fault fault =
new Stroap11Fault(MUST_UNDERSTAND_FAULT_NAME, "SOAP Must Understand Error", null, getMessageFactory());
setFault(fault);
return fault;
}
public Soap11Fault addClientOrSenderFault(String faultStringOrReason, Locale locale) throws SoapFaultException {
Assert.hasLength(faultStringOrReason, "'faultStringOrReason' must not be empty");
Stroap11Fault fault = new Stroap11Fault(CLIENT_FAULT_NAME, faultStringOrReason, null, getMessageFactory());
setFault(fault);
return fault;
}
public Soap11Fault addServerOrReceiverFault(String faultStringOrReason, Locale locale) throws SoapFaultException {
Assert.hasLength(faultStringOrReason, "'faultStringOrReason' must not be empty");
Stroap11Fault fault = new Stroap11Fault(SERVER_FAULT_NAME, faultStringOrReason, null, getMessageFactory());
setFault(fault);
return fault;
}
public Soap11Fault addVersionMismatchFault(String faultStringOrReason, Locale locale) throws SoapFaultException {
Assert.hasLength(faultStringOrReason, "'faultStringOrReason' must not be empty");
Stroap11Fault fault =
new Stroap11Fault(VERSION_MISMATCH_FAULT_NAME, faultStringOrReason, null, getMessageFactory());
setFault(fault);
return fault;
}
public Soap11Fault addFault(QName faultCode, String faultString, Locale faultStringLocale)
throws SoapFaultException {
Assert.notNull(faultCode, "'faultCode' must not be null");
Assert.hasLength(faultCode.getLocalPart(), "faultCode's localPart cannot be empty");
Assert.hasLength(faultCode.getNamespaceURI(), "faultCode's namespaceUri cannot be empty");
Assert.hasLength(faultString, "'faultString' must not be empty");
Stroap11Fault fault = new Stroap11Fault(faultCode, faultString, faultStringLocale, getMessageFactory());
setFault(fault);
return fault;
}
}

View File

@@ -1,157 +0,0 @@
/*
* Copyright 2005-2010 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.stroap;
import java.util.Locale;
import javax.xml.XMLConstants;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.events.Characters;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.ws.soap.SoapFaultDetail;
import org.springframework.ws.soap.soap11.Soap11Fault;
import org.springframework.xml.stream.CompositeXMLEventReader;
import org.springframework.xml.stream.ListBasedXMLEventReader;
/**
* @author Arjen Poutsma
*/
class Stroap11Fault extends StroapFault implements Soap11Fault {
private static final QName XML_LANG_NAME = new QName(XMLConstants.XML_NS_URI, "lang", XMLConstants.XML_NS_PREFIX);
private final FaultElement faultCode;
private final FaultElement faultString;
private FaultElement faultActor;
Stroap11Fault(QName faultCode, String faultString, Locale faultStringLocale, StroapMessageFactory messageFactory) {
super(messageFactory);
this.faultCode = FaultElement.createFaultCode(faultCode, messageFactory);
this.faultString = FaultElement.createFaultString(faultString, faultStringLocale, messageFactory);
addNamespaceDeclaration(faultCode.getPrefix(), faultCode.getNamespaceURI());
}
public QName getFaultCode() {
return parseFaultCodeString(faultCode.getCharacterData());
}
private QName parseFaultCodeString(String faultCodeString) {
if (faultCodeString == null) {
return null;
}
int idx = faultCodeString.indexOf(':');
if (idx == -1) {
return new QName(faultCodeString);
}
else {
String prefix = faultCodeString.substring(0, idx);
String localPart = faultCodeString.substring(idx + 1, faultCodeString.length());
String namespaceUri = getStartElement().getNamespaceURI(prefix);
return new QName(namespaceUri, localPart, prefix);
}
}
public String getFaultStringOrReason() {
return faultString.getCharacterData();
}
public Locale getFaultStringLocale() {
String xmlLangString = faultString.getAttributeValue(XML_LANG_NAME);
if (xmlLangString != null) {
String localeString = xmlLangString.replace('-', '_');
return StringUtils.parseLocaleString(localeString);
}
return null;
}
public String getFaultActorOrRole() {
return faultActor != null ? faultActor.getCharacterData() : null;
}
public void setFaultActorOrRole(String faultActor) {
this.faultActor = FaultElement.createFaultActor(faultActor, getMessageFactory());
}
public SoapFaultDetail getFaultDetail() {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
public SoapFaultDetail addFaultDetail() {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
@Override
protected XMLEventReader getChildEventReader() {
XMLEventReader[] eventReaders = (faultActor == null) ? new XMLEventReader[2] : new XMLEventReader[3];
eventReaders[0] = faultCode.getEventReader(false);
eventReaders[1] = faultString.getEventReader(false);
if (faultActor != null) {
eventReaders[2] = faultActor.getEventReader(false);
}
return new CompositeXMLEventReader(eventReaders);
}
private static class FaultElement extends StroapElement {
private final Characters characters;
private FaultElement(String localName, String value, StroapMessageFactory messageFactory) {
super(messageFactory.getEventFactory().createStartElement(new QName(localName), null, null),
messageFactory);
this.characters = getEventFactory().createCharacters(value);
}
public static FaultElement createFaultCode(QName faultCode, StroapMessageFactory messageFactory) {
Assert.notNull(faultCode, "'faultCode' must not be null");
Assert.hasLength(faultCode.getLocalPart(), "faultCode's localPart cannot be empty");
Assert.hasLength(faultCode.getNamespaceURI(), "faultCode's namespaceUri cannot be empty");
String value = faultCode.getPrefix() + ":" + faultCode.getLocalPart();
return new FaultElement("faultcode", value, messageFactory);
}
public static FaultElement createFaultString(String faultString,
Locale faultStringLocale,
StroapMessageFactory messageFactory) {
Assert.hasLength(faultString, "'faultString' must not be empty");
FaultElement element = new FaultElement("faultstring", faultString, messageFactory);
if (faultStringLocale != null) {
String xmlLangString = faultStringLocale.toString().replace('_', '-');
element.addAttribute(XML_LANG_NAME, xmlLangString);
}
return element;
}
public static FaultElement createFaultActor(String actor, StroapMessageFactory messageFactory) {
Assert.hasLength(actor, "'actor' must not be empty");
return new FaultElement("faultactor", actor, messageFactory);
}
public String getCharacterData() {
return characters.getData();
}
@Override
protected XMLEventReader getChildEventReader() {
return new ListBasedXMLEventReader(characters);
}
}
}

View File

@@ -1,73 +0,0 @@
/*
* Copyright 2005-2010 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.stroap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import javax.xml.soap.SOAPConstants;
import javax.xml.stream.events.StartElement;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.ws.soap.SoapHeaderElement;
import org.springframework.ws.soap.soap11.Soap11Header;
/**
* @author Arjen Poutsma
*/
class Stroap11Header extends StroapHeader implements Soap11Header {
Stroap11Header(StroapMessageFactory messageFactory) {
super(messageFactory);
}
Stroap11Header(StartElement startElement, StroapMessageFactory messageFactory) {
super(startElement, messageFactory);
}
public Iterator<SoapHeaderElement> examineHeaderElementsToProcess(String[] actors) {
List<SoapHeaderElement> result = new LinkedList<SoapHeaderElement>();
Iterator<SoapHeaderElement> iterator = examineAllHeaderElements();
while (iterator.hasNext()) {
SoapHeaderElement headerElement = iterator.next();
String actor = headerElement.getActorOrRole();
if (shouldProcess(actor, actors)) {
result.add(headerElement);
}
}
return result.iterator();
}
private boolean shouldProcess(String headerActor, String[] actors) {
if (!StringUtils.hasLength(headerActor)) {
return true;
}
if (SOAPConstants.URI_SOAP_ACTOR_NEXT.equals(headerActor)) {
return true;
}
if (!ObjectUtils.isEmpty(actors)) {
for (String actor : actors) {
if (actor.equals(headerActor)) {
return true;
}
}
}
return false;
}
}

View File

@@ -1,127 +0,0 @@
/*
* Copyright 2005-2010 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.stroap;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLEventWriter;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import org.springframework.util.xml.StaxUtils;
import org.springframework.ws.soap.SoapBody;
import org.springframework.ws.soap.SoapFault;
import org.springframework.ws.soap.SoapVersion;
import org.springframework.ws.stream.StreamingPayload;
/**
* @author Arjen Poutsma
*/
abstract class StroapBody extends StroapElement implements SoapBody {
private StroapPayload payload;
protected StroapBody(StroapMessageFactory messageFactory) {
super(messageFactory.getSoapVersion().getBodyName(), messageFactory);
this.payload = new CachingStroapPayload();
}
protected StroapBody(StartElement startElement, StroapPayload payload, StroapMessageFactory messageFactory) {
super(startElement, messageFactory);
this.payload = payload;
}
static StroapBody build(XMLEventReader eventReader, StroapMessageFactory messageFactory) throws XMLStreamException {
XMLEvent event = eventReader.nextTag();
if (!event.isStartElement()) {
throw new StroapMessageCreationException("Unexpected event: " + event + ", expected StartElement");
}
StartElement startElement = event.asStartElement();
SoapVersion soapVersion = messageFactory.getSoapVersion();
if (!soapVersion.getBodyName().equals(startElement.getName())) {
throw new StroapMessageCreationException(
"Unexpected name: " + startElement.getName() + ", expected " + soapVersion.getBodyName());
}
StroapPayload payload;
if (messageFactory.isPayloadCaching()) {
payload = new CachingStroapPayload(eventReader);
}
else {
payload = new NonCachingStroapPayload(eventReader);
}
if (SoapVersion.SOAP_11.equals(soapVersion)) {
return new Stroap11Body(startElement, payload, messageFactory);
}
else {
return null;
}
}
public Source getPayloadSource() {
XMLEventReader eventReader = payload.getEventReader();
return StaxUtils.createCustomStaxSource(eventReader);
}
public Result getPayloadResult() {
CachingStroapPayload cachingPayload;
if (payload instanceof CachingStroapPayload) {
cachingPayload = (CachingStroapPayload) payload;
}
else {
cachingPayload = new CachingStroapPayload();
this.payload = cachingPayload;
}
XMLEventWriter eventWriter = cachingPayload.getEventWriter();
return StaxUtils.createCustomStaxResult(eventWriter);
}
public boolean hasFault() {
return payload instanceof FaultStroapPayload;
}
public SoapFault getFault() {
return payload instanceof FaultStroapPayload ? ((FaultStroapPayload) payload).getFault() : null;
}
protected void setFault(StroapFault fault) {
this.payload = new FaultStroapPayload(fault);
}
@Override
protected final XMLEventReader getChildEventReader() {
return payload.getEventReader();
}
@Override
public void writeTo(XMLEventWriter eventWriter) throws XMLStreamException {
eventWriter.add(getStartElement());
payload.writeTo(eventWriter);
eventWriter.add(getEndElement());
}
public void setStreamingPayload(StreamingPayload payload) {
this.payload = new StreamingStroapPayload(payload, getMessageFactory());
}
public QName getPayloadName() {
return payload.getName();
}
}

View File

@@ -1,37 +0,0 @@
/*
* Copyright 2005-2010 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.stroap;
import org.springframework.ws.soap.SoapBodyException;
/**
* @author Arjen Poutsma
*/
public class StroapBodyException extends SoapBodyException {
public StroapBodyException(String msg) {
super(msg);
}
public StroapBodyException(String msg, Throwable ex) {
super(msg, ex);
}
public StroapBodyException(Throwable ex) {
super(ex);
}
}

View File

@@ -1,260 +0,0 @@
/*
* Copyright 2005-2010 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.stroap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.NoSuchElementException;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventFactory;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLEventWriter;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.Attribute;
import javax.xml.stream.events.EndElement;
import javax.xml.stream.events.Namespace;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
import javax.xml.transform.Source;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.util.xml.StaxUtils;
import org.springframework.ws.soap.SoapElement;
import org.springframework.ws.soap.SoapVersion;
import org.springframework.xml.stream.AbstractXMLEventReader;
/**
* @author Arjen Poutsma
*/
abstract class StroapElement implements SoapElement {
protected static final String DEFAULT_PREFIX = "SOAP-ENV";
private final StroapMessageFactory messageFactory;
private StartElement startElement;
private EndElement endElement;
protected StroapElement(QName name, StroapMessageFactory messageFactory) {
this(createStartElement(name, messageFactory), messageFactory);
}
private static StartElement createStartElement(QName name, StroapMessageFactory messageFactory) {
if (!StringUtils.hasLength(name.getPrefix())) {
name = new QName(name.getNamespaceURI(), name.getLocalPart(), DEFAULT_PREFIX);
}
return messageFactory.getEventFactory().createStartElement(name, null, null);
}
protected StroapElement(StartElement startElement, StroapMessageFactory messageFactory) {
Assert.notNull(startElement, "'startElement' must not be null");
Assert.notNull(messageFactory, "'messageFactory' must not be null");
this.messageFactory = messageFactory;
this.startElement = startElement;
this.endElement = getEventFactory().createEndElement(startElement.getName(), startElement.getNamespaces());
}
public final Source getSource() {
return StaxUtils.createCustomStaxSource(getEventReader(true));
}
protected XMLEventReader getEventReader(boolean documentEvents) {
return new StroapElementEventReader(documentEvents);
}
public void writeTo(XMLEventWriter eventWriter) throws XMLStreamException {
eventWriter.add(getEventReader(false));
}
protected StroapMessageFactory getMessageFactory() {
return messageFactory;
}
protected final XMLEventFactory getEventFactory() {
return getMessageFactory().getEventFactory();
}
protected SoapVersion getSoapVersion() {
return getMessageFactory().getSoapVersion();
}
public final QName getName() {
return getStartElement().getName();
}
protected abstract XMLEventReader getChildEventReader();
public final Iterator<QName> getAllAttributes() {
List<QName> result = new LinkedList<QName>();
for (Iterator iterator = getStartElement().getAttributes(); iterator.hasNext();) {
Attribute attribute = (Attribute) iterator.next();
result.add(attribute.getName());
}
return result.iterator();
}
public final String getAttributeValue(QName name) {
Attribute attribute = getStartElement().getAttributeByName(name);
return attribute != null ? attribute.getValue() : null;
}
public final void removeAttribute(QName name) {
List<Attribute> newAttributes = new LinkedList<Attribute>();
for (Iterator iterator = getStartElement().getAttributes(); iterator.hasNext();) {
Attribute attribute = (Attribute) iterator.next();
if (!name.equals(attribute.getName())) {
newAttributes.add(attribute);
}
}
StartElement oldStartElement = getStartElement();
this.startElement = getEventFactory().createStartElement(oldStartElement.getName(), newAttributes.iterator(),
oldStartElement.getNamespaces());
}
public final void addAttribute(QName name, String value) {
List<Attribute> newAttributes = new LinkedList<Attribute>();
for (Iterator iterator = getStartElement().getAttributes(); iterator.hasNext();) {
Attribute attribute = (Attribute) iterator.next();
newAttributes.add(attribute);
}
Attribute newAttribute = getEventFactory().createAttribute(name, value);
newAttributes.add(newAttribute);
StartElement oldStartElement = getStartElement();
this.startElement = getEventFactory().createStartElement(oldStartElement.getName(), newAttributes.iterator(),
oldStartElement.getNamespaces());
}
public final void addNamespaceDeclaration(String prefix, String namespaceUri) {
List<Namespace> newNamespaces = new LinkedList<Namespace>();
for (Iterator iterator = getStartElement().getNamespaces(); iterator.hasNext();) {
Namespace namespace = (Namespace) iterator.next();
newNamespaces.add(namespace);
}
Namespace newNamespace;
if (StringUtils.hasLength(prefix)) {
newNamespace = getEventFactory().createNamespace(prefix, namespaceUri);
}
else {
newNamespace = getEventFactory().createNamespace(namespaceUri);
}
newNamespaces.add(newNamespace);
StartElement oldStartElement = getStartElement();
this.startElement = getEventFactory()
.createStartElement(oldStartElement.getName(), oldStartElement.getAttributes(),
newNamespaces.iterator());
}
protected final StartElement getStartElement() {
return startElement;
}
protected final EndElement getEndElement() {
return endElement;
}
private enum EVENT_READER_STATE {
START_DOCUMENT,
START_ELEMENT,
CHILDREN,
END_ELEMENT,
END_DOCUMENT,
DONE
}
private class StroapElementEventReader extends AbstractXMLEventReader {
private EVENT_READER_STATE state;
private boolean documentEvents;
private final XMLEventReader childEventReader;
private StroapElementEventReader(boolean documentEvents) {
this.documentEvents = documentEvents;
state = documentEvents ? EVENT_READER_STATE.START_DOCUMENT : EVENT_READER_STATE.START_ELEMENT;
this.childEventReader = getChildEventReader();
}
public boolean hasNext() {
if (documentEvents && state == EVENT_READER_STATE.DONE) {
return false;
}
else if (!documentEvents && state == EVENT_READER_STATE.END_DOCUMENT) {
return false;
}
else {
return true;
}
}
public XMLEvent nextEvent() throws XMLStreamException {
switch (state) {
case START_DOCUMENT:
state = EVENT_READER_STATE.START_ELEMENT;
return getEventFactory().createStartDocument();
case START_ELEMENT:
state = EVENT_READER_STATE.CHILDREN;
return getStartElement();
case CHILDREN:
if (!childEventReader.hasNext()) {
state = EVENT_READER_STATE.END_ELEMENT;
return nextEvent();
}
return childEventReader.nextEvent();
case END_ELEMENT:
state = EVENT_READER_STATE.END_DOCUMENT;
return getEndElement();
case END_DOCUMENT:
state = EVENT_READER_STATE.DONE;
return getEventFactory().createEndDocument();
case DONE:
throw new NoSuchElementException();
default:
throw new IllegalStateException();
}
}
public XMLEvent peek() throws XMLStreamException {
switch (state) {
case START_DOCUMENT:
return getEventFactory().createStartDocument();
case START_ELEMENT:
return getStartElement();
case CHILDREN:
XMLEvent event = childEventReader.peek();
if (event == null) {
state = EVENT_READER_STATE.END_ELEMENT;
event = getEndElement();
}
return event;
case END_ELEMENT:
return getEndElement();
case END_DOCUMENT:
return getEventFactory().createEndDocument();
case DONE:
return null;
default:
throw new IllegalStateException();
}
}
}
}

View File

@@ -1,125 +0,0 @@
/*
* Copyright 2005-2010 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.stroap;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
import org.springframework.ws.soap.SoapBody;
import org.springframework.ws.soap.SoapBodyException;
import org.springframework.ws.soap.SoapEnvelope;
import org.springframework.ws.soap.SoapHeader;
import org.springframework.ws.soap.SoapHeaderException;
import org.springframework.ws.soap.SoapVersion;
import org.springframework.xml.stream.CompositeXMLEventReader;
/**
* @author Arjen Poutsma
*/
class StroapEnvelope extends StroapElement implements SoapEnvelope {
private static final String LOCAL_NAME = "Envelope";
private StroapHeader header;
private StroapBody body;
StroapEnvelope(StroapMessageFactory messageFactory) {
super(messageFactory.getSoapVersion().getEnvelopeName(), messageFactory);
this.header = null;
this.body = new Stroap11Body(messageFactory);
}
private StroapEnvelope(StartElement startElement,
StroapHeader header,
StroapBody body,
StroapMessageFactory messageFactory) {
super(startElement, messageFactory);
this.header = header;
this.body = body;
}
static StroapEnvelope build(XMLEventReader eventReader, StroapMessageFactory messageFactory)
throws XMLStreamException {
XMLEvent event = eventReader.nextTag();
if (!event.isStartElement()) {
throw new StroapMessageCreationException("Unexpected event: " + event + ", expected StartElement");
}
StartElement startElement = event.asStartElement();
SoapVersion soapVersion = messageFactory.getSoapVersion();
if (!soapVersion.getEnvelopeName().equals(startElement.getName())) {
throw new StroapMessageCreationException(
"Unexpected name: " + startElement.getName() + ", expected " + soapVersion.getEnvelopeName());
}
StroapHeader header = null;
StroapBody body = null;
XMLEvent peekedEvent = eventReader.peek();
while (peekedEvent != null) {
if (peekedEvent.isStartElement()) {
QName headerOrBodyName = peekedEvent.asStartElement().getName();
if (soapVersion.getHeaderName().equals(headerOrBodyName)) {
header = StroapHeader.build(eventReader, messageFactory);
}
else if (soapVersion.getBodyName().equals(headerOrBodyName)) {
body = StroapBody.build(eventReader, messageFactory);
break;
}
else {
throw new StroapMessageCreationException(
"Unexpected start element name [" + headerOrBodyName + "]");
}
}
else {
eventReader.nextEvent();
}
peekedEvent = eventReader.peek();
}
if (body == null) {
throw new StroapMessageCreationException("No SOAP body found");
}
return new StroapEnvelope(startElement, header, body, messageFactory);
}
public SoapHeader getHeader() throws SoapHeaderException {
if (header == null) {
header = new Stroap11Header(getMessageFactory());
}
return header;
}
public SoapBody getBody() throws SoapBodyException {
if (body == null) {
body = new Stroap11Body(getMessageFactory());
}
return body;
}
@Override
protected XMLEventReader getChildEventReader() {
if (header != null) {
return new CompositeXMLEventReader(header.getEventReader(false), body.getEventReader(false));
}
else {
return body.getEventReader(false);
}
}
}

View File

@@ -1,29 +0,0 @@
/*
* Copyright 2005-2010 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.stroap;
import org.springframework.ws.soap.SoapFault;
/**
* @author Arjen Poutsma
*/
abstract class StroapFault extends StroapElement implements SoapFault {
protected StroapFault(StroapMessageFactory messageFactory) {
super(messageFactory.getSoapVersion().getFaultName(), messageFactory);
}
}

View File

@@ -1,165 +0,0 @@
/*
* Copyright 2005-2011 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.stroap;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
import javax.xml.transform.Result;
import org.springframework.util.Assert;
import org.springframework.util.xml.StaxUtils;
import org.springframework.ws.soap.SoapHeader;
import org.springframework.ws.soap.SoapHeaderElement;
import org.springframework.ws.soap.SoapHeaderException;
import org.springframework.ws.soap.SoapVersion;
import org.springframework.xml.stream.AbstractXMLEventWriter;
import org.springframework.xml.stream.CompositeXMLEventReader;
/**
* @author Arjen Poutsma
*/
abstract class StroapHeader extends StroapElement implements SoapHeader {
private List<StroapHeaderElement> headerElements = new LinkedList<StroapHeaderElement>();
protected StroapHeader(StroapMessageFactory messageFactory) {
super(messageFactory.getSoapVersion().getHeaderName(), messageFactory);
}
protected StroapHeader(StartElement startElement, StroapMessageFactory messageFactory) {
super(startElement, messageFactory);
}
static StroapHeader build(XMLEventReader eventReader, StroapMessageFactory messageFactory)
throws XMLStreamException {
XMLEvent event = eventReader.nextTag();
if (!event.isStartElement()) {
throw new StroapMessageCreationException("Unexpected event: " + event + ", expected StartElement");
}
StartElement startElement = event.asStartElement();
SoapVersion soapVersion = messageFactory.getSoapVersion();
if (!soapVersion.getHeaderName().equals(startElement.getName())) {
throw new StroapMessageCreationException(
"Unexpected name: " + startElement.getName() + ", expected " + soapVersion.getHeaderName());
}
if (SoapVersion.SOAP_11.equals(soapVersion)) {
return new Stroap11Header(startElement, messageFactory);
}
else {
return null;
}
}
public SoapHeaderElement addHeaderElement(QName name) throws SoapHeaderException {
StroapHeaderElement headerElement = new StroapHeaderElement(name, getMessageFactory());
headerElements.add(headerElement);
return headerElement;
}
public Iterator<SoapHeaderElement> examineAllHeaderElements() throws SoapHeaderException {
List<SoapHeaderElement> headerElements = Collections.<SoapHeaderElement>unmodifiableList(this.headerElements);
return headerElements.iterator();
}
public Iterator<SoapHeaderElement> examineHeaderElements(QName name) throws SoapHeaderException {
List<SoapHeaderElement> result = new LinkedList<SoapHeaderElement>();
for (StroapHeaderElement headerElement : this.headerElements) {
if (headerElement.getName().equals(name)) {
result.add(headerElement);
}
}
return result.iterator();
}
public Iterator<SoapHeaderElement> examineMustUnderstandHeaderElements(String actorOrRole)
throws SoapHeaderException {
List<SoapHeaderElement> result = new LinkedList<SoapHeaderElement>();
for (StroapHeaderElement headerElement : this.headerElements) {
if (headerElement.getMustUnderstand() && headerElement.getActorOrRole().equals(actorOrRole)) {
result.add(headerElement);
}
}
return result.iterator();
}
public void removeHeaderElement(QName name) throws SoapHeaderException {
Assert.notNull(name, "'name' must not be null");
for (Iterator<StroapHeaderElement> iterator = headerElements.iterator(); iterator.hasNext();) {
StroapHeaderElement headerElement = iterator.next();
if (name.equals(headerElement.getName())) {
iterator.remove();
break;
}
}
}
@Override
protected XMLEventReader getChildEventReader() {
XMLEventReader[] eventReaders = new XMLEventReader[headerElements.size()];
for (int i = 0; i < headerElements.size(); i++) {
StroapHeaderElement headerElement = headerElements.get(i);
eventReaders[i] = headerElement.getEventReader(false);
}
return new CompositeXMLEventReader(eventReaders);
}
public Result getResult() {
headerElements.clear();
return StaxUtils.createCustomStaxResult(new StroapHeaderXMLEventWriter());
}
class StroapHeaderXMLEventWriter extends AbstractXMLEventWriter {
private int elementDepth = 0;
boolean startElementSeen = false;
private final List<XMLEvent> events = new LinkedList<XMLEvent>();
public void add(XMLEvent event) throws XMLStreamException {
if (event.isStartElement()) {
startElementSeen = true;
elementDepth++;
}
else if (event.isEndElement()) {
elementDepth--;
}
else if (event.isStartDocument() || event.isEndDocument()) {
return;
}
if (elementDepth >= 0 && startElementSeen) {
events.add(event);
}
if (elementDepth == 0 && (event.isEndElement() || event.isEndDocument())) {
StroapHeaderElement headerElement = StroapHeaderElement.build(events, getMessageFactory());
headerElements.add(headerElement);
events.clear();
}
}
}
}

View File

@@ -1,112 +0,0 @@
/*
* Copyright 2005-2010 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.stroap;
import java.util.LinkedList;
import java.util.List;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
import javax.xml.transform.Result;
import org.springframework.util.Assert;
import org.springframework.util.xml.StaxUtils;
import org.springframework.ws.soap.SoapHeaderElement;
import org.springframework.ws.soap.SoapHeaderException;
import org.springframework.xml.stream.ListBasedXMLEventReader;
/**
* @author Arjen Poutsma
*/
class StroapHeaderElement extends StroapElement implements SoapHeaderElement {
private final List<XMLEvent> events = new LinkedList<XMLEvent>();
StroapHeaderElement(QName name, StroapMessageFactory messageFactory) {
super(name, messageFactory);
}
private StroapHeaderElement(StartElement startElement, List<XMLEvent> events, StroapMessageFactory messageFactory) {
super(startElement, messageFactory);
Assert.notNull(events, "'events' must not be null");
this.events.addAll(events);
}
static StroapHeaderElement build(List<XMLEvent> events, StroapMessageFactory messageFactory)
throws XMLStreamException {
Assert.notNull(events, "'events' must not be null");
Assert.isTrue(events.size() >= 2, "not enough events");
XMLEvent event = events.get(0);
if (!event.isStartElement()) {
throw new StroapHeaderException("Unexpected event: " + event + ", expected StartElement");
}
StartElement startElement = event.asStartElement();
event = events.get(events.size() - 1);
if (!event.isEndElement()) {
throw new StroapHeaderException("Unexpected event: " + event + ", expected EndElement");
}
List<XMLEvent> childEvents = events.subList(1, events.size() - 1);
return new StroapHeaderElement(startElement, childEvents, messageFactory);
}
public final String getActorOrRole() throws SoapHeaderException {
return getAttributeValue(getSoapVersion().getActorOrRoleName());
}
public final void setActorOrRole(String actorOrRole) throws SoapHeaderException {
addAttribute(getSoapVersion().getActorOrRoleName(), actorOrRole);
}
public final boolean getMustUnderstand() throws SoapHeaderException {
String mustUnderstandAttribute = getAttributeValue(getSoapVersion().getMustUnderstandAttributeName());
return "1".equals(mustUnderstandAttribute);
}
public void setMustUnderstand(boolean mustUnderstand) throws SoapHeaderException {
String mustUnderstandAttribute = mustUnderstand ? "1" : "0";
addAttribute(getSoapVersion().getMustUnderstandAttributeName(), mustUnderstandAttribute);
}
public Result getResult() throws SoapHeaderException {
events.clear();
return StaxUtils.createCustomStaxResult(new CachingXMLEventWriter(events));
}
public String getText() {
StringBuilder builder = new StringBuilder();
for (XMLEvent event : events) {
if (event.isCharacters()) {
builder.append(event.asCharacters().getData());
}
}
return builder.toString();
}
public void setText(String content) {
events.clear();
events.add(getEventFactory().createCharacters(content));
}
@Override
protected XMLEventReader getChildEventReader() {
return new ListBasedXMLEventReader(events);
}
}

View File

@@ -1,38 +0,0 @@
/*
* Copyright 2005-2010 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.stroap;
import org.springframework.ws.soap.SoapHeaderException;
/**
* @author Arjen Poutsma
* @since 1.0.0
*/
public class StroapHeaderException extends SoapHeaderException {
public StroapHeaderException(String msg) {
super(msg);
}
public StroapHeaderException(String msg, Throwable ex) {
super(msg, ex);
}
public StroapHeaderException(Throwable ex) {
super(ex);
}
}

View File

@@ -1,297 +0,0 @@
/*
* Copyright 2005-2010 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.stroap;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import javax.activation.DataHandler;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLEventWriter;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.EndDocument;
import javax.xml.stream.events.StartDocument;
import javax.xml.stream.events.XMLEvent;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
import org.springframework.util.Assert;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.util.StringUtils;
import org.springframework.ws.mime.Attachment;
import org.springframework.ws.mime.AttachmentException;
import org.springframework.ws.soap.AbstractSoapMessage;
import org.springframework.ws.soap.SoapEnvelope;
import org.springframework.ws.soap.SoapEnvelopeException;
import org.springframework.ws.soap.SoapVersion;
import org.springframework.ws.soap.support.SoapUtils;
import org.springframework.ws.stream.StreamingPayload;
import org.springframework.ws.stream.StreamingWebServiceMessage;
import org.springframework.ws.transport.TransportConstants;
import org.springframework.ws.transport.TransportInputStream;
import org.springframework.ws.transport.TransportOutputStream;
import org.springframework.xml.stream.AbstractXMLEventWriter;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
import org.w3c.dom.ls.DOMImplementationLS;
import org.w3c.dom.ls.LSOutput;
import org.w3c.dom.ls.LSSerializer;
import org.xml.sax.SAXException;
/**
* @author Arjen Poutsma
*/
public class StroapMessage extends AbstractSoapMessage implements StreamingWebServiceMessage {
private final MultiValueMap<String, String> mimeHeaders = new LinkedMultiValueMap<String, String>();
private StroapEnvelope envelope;
private final StroapMessageFactory messageFactory;
private final StartDocument startDocument;
private final EndDocument endDocument;
public StroapMessage(StroapMessageFactory messageFactory) {
this(null, null, messageFactory);
}
public StroapMessage(MultiValueMap<String, String> mimeHeaders,
StroapEnvelope envelope,
StroapMessageFactory messageFactory) {
Assert.notNull(messageFactory, "'messageFactory' must not be null");
this.messageFactory = messageFactory;
if (mimeHeaders != null) {
this.mimeHeaders.putAll(mimeHeaders);
}
this.envelope = envelope != null ? envelope : new StroapEnvelope(messageFactory);
if (!this.mimeHeaders.containsKey(TransportConstants.HEADER_CONTENT_TYPE)) {
this.mimeHeaders
.set(TransportConstants.HEADER_CONTENT_TYPE, messageFactory.getSoapVersion().getContentType());
}
if (!this.mimeHeaders.containsKey(TransportConstants.HEADER_ACCEPT)) {
this.mimeHeaders.set(TransportConstants.HEADER_ACCEPT, messageFactory.getSoapVersion().getContentType());
}
this.startDocument = messageFactory.getEventFactory().createStartDocument();
this.endDocument = messageFactory.getEventFactory().createEndDocument();
}
static StroapMessage build(InputStream inputStream, StroapMessageFactory messageFactory)
throws XMLStreamException, IOException {
MultiValueMap<String, String> mimeHeaders = parseMimeHeaders(inputStream);
XMLEventReader eventReader = messageFactory.getInputFactory().createXMLEventReader(inputStream);
StroapEnvelope envelope = StroapEnvelope.build(eventReader, messageFactory);
return new StroapMessage(mimeHeaders, envelope, messageFactory);
}
private static MultiValueMap<String, String> parseMimeHeaders(InputStream inputStream) throws IOException {
MultiValueMap<String, String> mimeHeaders = new LinkedMultiValueMap<String, String>();
if (inputStream instanceof TransportInputStream) {
TransportInputStream transportInputStream = (TransportInputStream) inputStream;
for (Iterator<String> headerNames = transportInputStream.getHeaderNames(); headerNames.hasNext();) {
String headerName = headerNames.next();
for (Iterator<String> headerValues = transportInputStream.getHeaders(headerName);
headerValues.hasNext();) {
String headerValue = headerValues.next();
StringTokenizer tokenizer = new StringTokenizer(headerValue, ",");
while (tokenizer.hasMoreTokens()) {
mimeHeaders.add(headerName, tokenizer.nextToken().trim());
}
}
}
}
return mimeHeaders;
}
public SoapEnvelope getEnvelope() throws SoapEnvelopeException {
return envelope;
}
public void setStreamingPayload(StreamingPayload payload) {
StroapBody soapBody = (StroapBody) getSoapBody();
soapBody.setStreamingPayload(payload);
}
public String getSoapAction() {
String soapAction = mimeHeaders.getFirst(TransportConstants.HEADER_SOAP_ACTION);
return StringUtils.hasLength(soapAction) ? soapAction : TransportConstants.EMPTY_SOAP_ACTION;
}
public void setSoapAction(String soapAction) {
soapAction = SoapUtils.escapeAction(soapAction);
mimeHeaders.set(TransportConstants.HEADER_SOAP_ACTION, soapAction);
}
@Override
public SoapVersion getVersion() {
return messageFactory.getSoapVersion();
}
public Document getDocument() {
try {
DocumentBuilder documentBuilder = messageFactory.getDocumentBuilderFactory().newDocumentBuilder();
try {
Document result = documentBuilder.newDocument();
DOMResult domResult = new DOMResult(result);
XMLEventWriter eventWriter = messageFactory.getOutputFactory().createXMLEventWriter(domResult);
eventWriter.add(startDocument);
envelope.writeTo(new NoStartEndDocumentWriter(eventWriter));
eventWriter.add(endDocument);
eventWriter.flush();
return result;
}
catch (XMLStreamException ignored) {
// ignored
}
catch (UnsupportedOperationException ignored) {
// ignored
}
// XMLOutputFactory does not support DOMResults, so let's do it the hard way
ByteArrayOutputStream bos = new ByteArrayOutputStream();
writeTo(bos);
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
return documentBuilder.parse(bis);
}
catch (ParserConfigurationException ex) {
throw new StroapMessageException("Could not create DocumentBuilderFactory", ex);
}
catch (SAXException ex) {
throw new StroapMessageException("Could not save message as Document", ex);
}
catch (IOException ex) {
throw new StroapMessageException("Could not save message as Document", ex);
}
}
public void setDocument(Document document) {
try {
try {
DOMSource domSource = new DOMSource(document);
XMLEventReader eventReader = messageFactory.getInputFactory().createXMLEventReader(domSource);
this.envelope = StroapEnvelope.build(eventReader, messageFactory);
return;
}
catch (XMLStreamException ignored) {
// ignored
}
catch (UnsupportedOperationException ignored) {
// ignored
}
// XMLInputFactory does not support DOMSources, so let's do it the hard way
DOMImplementation implementation = document.getImplementation();
Assert.isInstanceOf(DOMImplementationLS.class, implementation);
DOMImplementationLS loadSaveImplementation = (DOMImplementationLS) implementation;
LSOutput output = loadSaveImplementation.createLSOutput();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
output.setByteStream(bos);
LSSerializer serializer = loadSaveImplementation.createLSSerializer();
serializer.write(document, output);
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
XMLEventReader eventReader = messageFactory.getInputFactory().createXMLEventReader(bis);
this.envelope = StroapEnvelope.build(eventReader, messageFactory);
}
catch (XMLStreamException ex) {
throw new StroapMessageException("Could not read Document", ex);
}
}
public void writeTo(OutputStream outputStream) throws IOException {
if (outputStream instanceof TransportOutputStream) {
TransportOutputStream tos = (TransportOutputStream) outputStream;
for (Map.Entry<String, List<String>> entry : mimeHeaders.entrySet()) {
String name = entry.getKey();
for (String value : entry.getValue()) {
tos.addHeader(name, value);
}
}
}
try {
XMLEventWriter eventWriter = messageFactory.getOutputFactory().createXMLEventWriter(outputStream);
eventWriter.add(startDocument);
envelope.writeTo(new NoStartEndDocumentWriter(eventWriter));
eventWriter.add(endDocument);
eventWriter.flush();
}
catch (XMLStreamException ex) {
throw new StroapMessageException("Could not write message to OutputStream: " + ex.getMessage(), ex);
}
}
public boolean isXopPackage() {
return false;
}
public boolean convertToXopPackage() {
return false;
}
public Attachment getAttachment(String contentId) throws AttachmentException {
throw new UnsupportedOperationException();
}
public Iterator<Attachment> getAttachments() throws AttachmentException {
return Collections.<Attachment>emptyList().iterator();
}
public Attachment addAttachment(String contentId, DataHandler dataHandler) {
throw new UnsupportedOperationException();
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder("StroapMessage");
StroapBody body = (StroapBody) envelope.getBody();
if (body != null) {
builder.append(' ');
builder.append(body.getPayloadName());
}
return builder.toString();
}
private static class NoStartEndDocumentWriter extends AbstractXMLEventWriter {
private final XMLEventWriter delegate;
private NoStartEndDocumentWriter(XMLEventWriter delegate) {
this.delegate = delegate;
}
public void add(XMLEvent event) throws XMLStreamException {
if (!event.isStartDocument() && !event.isEndDocument()) {
delegate.add(event);
}
}
}
}

View File

@@ -1,33 +0,0 @@
/*
* Copyright 2005-2010 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.stroap;
import org.springframework.ws.soap.SoapMessageCreationException;
/**
* @author Arjen Poutsma
*/
public class StroapMessageCreationException extends SoapMessageCreationException {
public StroapMessageCreationException(String msg) {
super(msg);
}
public StroapMessageCreationException(String msg, Throwable ex) {
super(msg, ex);
}
}

View File

@@ -1,35 +0,0 @@
/*
* Copyright 2005-2010 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.stroap;
import org.springframework.ws.soap.SoapMessageException;
/**
* @author Arjen Poutsma
*/
public class StroapMessageException extends SoapMessageException {
public StroapMessageException(String msg) {
super(msg);
}
public StroapMessageException(String msg, Throwable ex) {
super(msg, ex);
}
}

View File

@@ -1,168 +0,0 @@
/*
* Copyright 2005-2010 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.stroap;
import java.io.IOException;
import java.io.InputStream;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.stream.XMLEventFactory;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamException;
import org.springframework.ws.soap.SoapMessageFactory;
import org.springframework.ws.soap.SoapVersion;
/**
* @author Arjen Poutsma
*/
public class StroapMessageFactory implements SoapMessageFactory {
private final XMLInputFactory inputFactory = createXmlInputFactory();
private final XMLOutputFactory outputFactory = createXmlOutputFactory();
private final XMLEventFactory eventFactory = createXmlEventFactory();
private final DocumentBuilderFactory documentBuilderFactory = createDocumentBuilderFactory();
private boolean payloadCaching = true;
public boolean isPayloadCaching() {
return payloadCaching;
}
public void setPayloadCaching(boolean payloadCaching) {
this.payloadCaching = payloadCaching;
}
public SoapVersion getSoapVersion() {
return SoapVersion.SOAP_11;
}
public void setSoapVersion(SoapVersion version) {
if (version != SoapVersion.SOAP_11) {
throw new UnsupportedOperationException();
}
}
public StroapMessage createWebServiceMessage() {
return new StroapMessage(this);
}
public StroapMessage createWebServiceMessage(InputStream inputStream) throws IOException {
try {
return StroapMessage.build(inputStream, this);
}
catch (XMLStreamException ex) {
throw new StroapMessageCreationException("Could not create message from InputStream: " + ex.getMessage(),
ex);
}
}
XMLInputFactory getInputFactory() {
return inputFactory;
}
XMLOutputFactory getOutputFactory() {
return outputFactory;
}
XMLEventFactory getEventFactory() {
return eventFactory;
}
DocumentBuilderFactory getDocumentBuilderFactory() {
return documentBuilderFactory;
}
/**
* Create a {@code XMLInputFactory} that this message factory will use to create {@link
* javax.xml.stream.XMLEventReader} objects.
*
* <p>Can be overridden in subclasses, adding further initialization of the factory. The resulting factory is cached,
* so this method will only be called once.
*
* @return the created factory
*/
protected XMLInputFactory createXmlInputFactory() {
return XMLInputFactory.newInstance();
}
/**
* Create a {@code XMLOutputFactory} that this message factory will use to create {@link
* javax.xml.stream.XMLEventWriter} objects.
*
* <p>Can be overridden in subclasses, adding further initialization of the factory. The resulting factory is cached,
* so this method will only be called once.
*
* @return the created factory
*/
protected XMLOutputFactory createXmlOutputFactory() {
XMLOutputFactory outputFactory = XMLOutputFactory.newFactory();
outputFactory.setProperty("javax.xml.stream.isRepairingNamespaces", true);
return outputFactory;
}
/**
* Create a {@code XMLEventFactory} that this message factory will use to create {@link
* javax.xml.stream.events.XMLEvent} objects.
*
* <p>Can be overridden in subclasses, adding further initialization of the factory. The resulting factory is cached,
* so this method will only be called once.
*
* @return the created factory
*/
protected XMLEventFactory createXmlEventFactory() {
return XMLEventFactory.newFactory();
}
/**
* Create a {@code DocumentBuilderFactory} that this message factory will use to create {@link org.w3c.dom.Document} objects.
*
* <p>Can be overridden in subclasses, adding further initialization of the factory. The resulting factory is cached,
* so this method will only be called once.
*
* @return the created factory
*/
protected DocumentBuilderFactory createDocumentBuilderFactory() {
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
return documentBuilderFactory;
}
public String toString() {
StringBuilder builder = new StringBuilder("StroapMessageFactory[");
if (getSoapVersion() == SoapVersion.SOAP_11) {
builder.append("SOAP 1.1");
}
else if (getSoapVersion() == SoapVersion.SOAP_12) {
builder.append("SOAP 1.2");
}
builder.append(',');
if (payloadCaching) {
builder.append("PayloadCaching enabled");
}
else {
builder.append("PayloadCaching disabled");
}
builder.append(']');
return builder.toString();
}
}

View File

@@ -1,37 +0,0 @@
/*
* Copyright 2005-2010 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.stroap;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLEventWriter;
import javax.xml.stream.XMLStreamException;
/**
* @author Arjen Poutsma
*/
abstract class StroapPayload {
public abstract QName getName();
public abstract XMLEventReader getEventReader();
public void writeTo(XMLEventWriter eventWriter) throws XMLStreamException {
eventWriter.add(getEventReader());
}
}

View File

@@ -1,152 +0,0 @@
/*
* Copyright 2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* 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.transport.tcp;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.UnknownHostException;
import org.springframework.scheduling.SchedulingAwareRunnable;
import org.springframework.ws.transport.WebServiceConnection;
import org.springframework.ws.transport.support.AbstractAsyncStandaloneMessageReceiver;
/** @author Arjen Poutsma */
public class TcpMessageReceiver extends AbstractAsyncStandaloneMessageReceiver {
public static final int DEFAULT_PORT = 8081;
private ServerSocket serverSocket;
private InetAddress bindAddress;
private int backlog = -1;
private int port = DEFAULT_PORT;
/** Sets the port the server will bind to. */
public void setPort(int port) {
this.port = port;
}
/** Sets the server back log. */
public void setBacklog(int backlog) {
this.backlog = backlog;
}
/**
* Sets the local internet address the server will bind to. By default, it will accept connections on any/all local
* addresses.
*
* @throws UnknownHostException when the given address is not known
* @see ServerSocket#ServerSocket(int,int,java.net.InetAddress)
*/
public void setBindAddress(String bindAddress) throws UnknownHostException {
this.bindAddress = InetAddress.getByName(bindAddress);
}
protected void onActivate() throws IOException {
openServerSocket();
}
protected void onStart() {
if (logger.isInfoEnabled()) {
logger.info("Starting tcp receiver [" + serverSocket.getLocalSocketAddress() + "]");
}
execute(new SocketAcceptingRunnable());
}
protected void onStop() {
if (logger.isInfoEnabled()) {
logger.info("Stopping tcp receiver [" + serverSocket.getLocalSocketAddress() + "]");
}
}
protected void onShutdown() {
if (logger.isInfoEnabled()) {
logger.info("Shutting down tcp receiver [" + serverSocket.getLocalSocketAddress() + "]");
}
closeServerSocket();
}
/** Establish a <code>ServerSocket</code> for this receiver. */
protected void openServerSocket() throws IOException {
closeServerSocket();
serverSocket = new ServerSocket(port, backlog, bindAddress);
}
protected void closeServerSocket() {
if (serverSocket == null) {
return;
}
try {
serverSocket.close();
}
catch (IOException ex) {
logger.debug("Could not close ServerSocket", ex);
}
}
private class SocketAcceptingRunnable implements SchedulingAwareRunnable {
public void run() {
while (isRunning()) {
try {
Socket socket = serverSocket.accept();
TcpRequestHandler handler = new TcpRequestHandler(socket);
execute(handler);
}
catch (InterruptedIOException ex) {
logger.warn(ex);
}
catch (IOException ex) {
logger.warn("Could not accept incoming connection: " + ex.getMessage());
}
}
}
public boolean isLongLived() {
return true;
}
}
private class TcpRequestHandler implements SchedulingAwareRunnable {
private final Socket socket;
public TcpRequestHandler(Socket socket) {
this.socket = socket;
}
public void run() {
WebServiceConnection connection = new TcpReceiverConnection(socket);
try {
handleConnection(connection);
}
catch (Exception ex) {
logger.warn("Could not handle request", ex);
}
}
public boolean isLongLived() {
return false;
}
}
}

View File

@@ -1,56 +0,0 @@
/*
* Copyright 2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* 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.transport.tcp;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketAddress;
import java.net.URI;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.ws.transport.WebServiceConnection;
import org.springframework.ws.transport.WebServiceMessageSender;
/** @author Arjen Poutsma */
public class TcpMessageSender implements WebServiceMessageSender {
public static final int DEFAULT_PORT = 8081;
private int timeOut = 1000;
/** Sets the amount of milliseconds before the tcp connection will timeout. */
public void setTimeOut(int timeOut) {
this.timeOut = timeOut;
}
public WebServiceConnection createConnection(URI theUri) throws IOException {
int port = theUri.getPort();
if (port == -1) {
port = DEFAULT_PORT;
}
Socket socket = new Socket();
SocketAddress socketAddress = new InetSocketAddress(theUri.getHost(), port);
socket.connect(socketAddress, timeOut);
return new TcpSenderConnection(socket);
}
public boolean supports(URI uri) {
return uri.getScheme().equals(TcpTransportConstants.TCP_URI_SCHEME);
}
}

View File

@@ -1,96 +0,0 @@
/*
* Copyright 2005-2010 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.transport.tcp;
import java.io.FilterInputStream;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Collections;
import java.util.Iterator;
import org.springframework.util.Assert;
import org.springframework.ws.transport.AbstractReceiverConnection;
import org.springframework.ws.transport.tcp.support.TcpTransportUtils;
/** @author Arjen Poutsma */
public class TcpReceiverConnection extends AbstractReceiverConnection {
private final Socket socket;
protected TcpReceiverConnection(Socket socket) {
Assert.notNull(socket, "socket must not be null");
this.socket = socket;
}
public URI getUri() throws URISyntaxException {
return TcpTransportUtils.toUri(socket);
}
public boolean hasError() throws IOException {
return false;
}
public String getErrorMessage() throws IOException {
return null;
}
public void onClose() throws IOException {
socket.close();
}
protected Iterator getRequestHeaderNames() throws IOException {
return Collections.EMPTY_LIST.iterator();
}
protected Iterator getRequestHeaders(String name) throws IOException {
return Collections.EMPTY_LIST.iterator();
}
protected InputStream getRequestInputStream() throws IOException {
return new FilterInputStream(socket.getInputStream()) {
@Override
public void close() throws IOException {
// don't close the socket
socket.shutdownInput();
}
};
}
protected void addResponseHeader(String name, String value) throws IOException {
}
protected OutputStream getResponseOutputStream() throws IOException {
return new FilterOutputStream(socket.getOutputStream()) {
@Override
public void close() throws IOException {
// don't close the socket
socket.shutdownOutput();
}
};
}
protected void sendResponse(boolean sentFault) throws IOException {
}
}

View File

@@ -1,114 +0,0 @@
/*
* Copyright 2005-2010 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.transport.tcp;
import java.io.FilterInputStream;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Collections;
import java.util.Iterator;
import org.springframework.util.Assert;
import org.springframework.ws.transport.AbstractSenderConnection;
import org.springframework.ws.transport.WebServiceConnection;
import org.springframework.ws.transport.tcp.support.TcpTransportUtils;
/**
* Implementation of {@link WebServiceConnection} that is used for client-side TCP/IP access. Exposes a {@link Socket}.
*
* @author Arjen Poutsma
*/
public class TcpSenderConnection extends AbstractSenderConnection {
private final Socket socket;
/** Constructs a new TCP/IP connection with the given socket. */
protected TcpSenderConnection(Socket socket) {
Assert.notNull(socket, "socket must not be null");
this.socket = socket;
}
/** Returns the socket for this connection. */
public Socket getSocket() {
return socket;
}
public URI getUri() throws URISyntaxException {
return TcpTransportUtils.toUri(socket);
}
public void onClose() throws IOException {
socket.close();
}
/*
* Errors
*/
public boolean hasError() throws IOException {
return false;
}
public String getErrorMessage() throws IOException {
return null;
}
protected void addRequestHeader(String name, String value) throws IOException {
}
protected OutputStream getRequestOutputStream() throws IOException {
return new FilterOutputStream(socket.getOutputStream()) {
@Override
public void close() throws IOException {
// don't close the socket
socket.shutdownOutput();
}
};
}
protected void sendRequest() throws IOException {
}
protected boolean hasResponse() throws IOException {
return true;
}
protected Iterator getResponseHeaderNames() throws IOException {
return Collections.EMPTY_LIST.iterator();
}
protected Iterator getResponseHeaders(String name) throws IOException {
return Collections.EMPTY_LIST.iterator();
}
protected InputStream getResponseInputStream() throws IOException {
return new FilterInputStream(socket.getInputStream()) {
@Override
public void close() throws IOException {
// don't close the socket
socket.shutdownInput();
}
};
}
}

View File

@@ -1,29 +0,0 @@
/*
* Copyright 2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* 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.transport.tcp;
/**
* Declares TCP/IP-specific transport constants.
*
* @author Arjen Poutsma
*/
public interface TcpTransportConstants {
/** The "tcp" URI scheme. */
String TCP_URI_SCHEME = "tcp";
}

View File

@@ -1,37 +0,0 @@
/*
* Copyright 2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* 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.transport.tcp;
import java.io.IOException;
import org.springframework.ws.transport.TransportException;
/** @author Arjen Poutsma */
public class TcpTransportException extends TransportException {
public TcpTransportException(String msg) {
super(msg);
}
public TcpTransportException(String msg, IOException ex) {
super(msg + ": " + ex.getMessage());
}
public TcpTransportException(IOException ex) {
super(ex.getMessage());
}
}

View File

@@ -1,44 +0,0 @@
/*
* Copyright 2008 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.transport.tcp.support;
import java.net.Socket;
import java.net.URI;
import java.net.URISyntaxException;
import org.springframework.ws.transport.tcp.TcpTransportConstants;
/**
* Collection of utility methods to work with TCP/IP transports.
*
* @author Arjen Poutsma
*/
public abstract class TcpTransportUtils {
/**
* Converts the given Socket into a <code>tcp</code> URI.
*
* @param socket the socket
* @return a tcp URI
*/
public static URI toUri(Socket socket) throws URISyntaxException {
String host = socket.getInetAddress().getHostName();
return new URI(TcpTransportConstants.TCP_URI_SCHEME, null, host, socket.getPort(), null, null, null);
}
}

View File

@@ -1,139 +0,0 @@
/*
* Copyright 2005-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.xml.stream;
import java.util.NoSuchElementException;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.Characters;
import javax.xml.stream.events.XMLEvent;
import org.springframework.util.ClassUtils;
/**
* Abstract base class for <code>XMLEventReader</code>s.
*
* @author Arjen Poutsma
*/
public abstract class AbstractXMLEventReader implements XMLEventReader {
private boolean closed;
public Object next() {
try {
return nextEvent();
}
catch (XMLStreamException ex) {
throw new NoSuchElementException();
}
}
/**
* Throws an <code>UnsupportedOperationException</code> when called.
*
* @throws UnsupportedOperationException when called
*/
public void remove() {
throw new UnsupportedOperationException("remove not supported on " + ClassUtils.getShortName(getClass()));
}
public String getElementText() throws XMLStreamException {
checkIfClosed();
if (!peek().isStartElement()) {
throw new XMLStreamException("Not at START_ELEMENT");
}
StringBuilder builder = new StringBuilder();
while (true) {
XMLEvent event = nextEvent();
if (event.isEndElement()) {
break;
}
else if (!event.isCharacters()) {
throw new XMLStreamException("Unexpected event [" + event + "] in getElementText()");
}
Characters characters = event.asCharacters();
if (!characters.isIgnorableWhiteSpace()) {
builder.append(event.asCharacters().getData());
}
}
return builder.toString();
}
public XMLEvent nextTag() throws XMLStreamException {
checkIfClosed();
while (true) {
XMLEvent event = nextEvent();
switch (event.getEventType()) {
case XMLStreamConstants.START_ELEMENT:
case XMLStreamConstants.END_ELEMENT:
return event;
case XMLStreamConstants.END_DOCUMENT:
return null;
case XMLStreamConstants.SPACE:
case XMLStreamConstants.COMMENT:
case XMLStreamConstants.PROCESSING_INSTRUCTION:
continue;
case XMLStreamConstants.CDATA:
case XMLStreamConstants.CHARACTERS:
if (!event.asCharacters().isWhiteSpace()) {
throw new XMLStreamException("Non-ignorable whitespace CDATA or CHARACTERS event in nextTag()");
}
break;
default:
throw new XMLStreamException(
"Received event [" + event + "], instead of START_ELEMENT or END_ELEMENT.");
}
}
}
/**
* Throws an <code>IllegalArgumentException</code> when called.
*
* @throws IllegalArgumentException when called.
*/
public Object getProperty(String name) throws IllegalArgumentException {
throw new IllegalArgumentException("Property not supported: [" + name + "]");
}
/**
* Returns <code>true</code> if closed; <code>false</code> otherwise.
*
* @see #close()
*/
protected boolean isClosed() {
return closed;
}
/**
* Checks if the reader is closed, and throws a <code>XMLStreamException</code> if so.
*
* @throws XMLStreamException if the reader is closed
* @see #close()
* @see #isClosed()
*/
protected void checkIfClosed() throws XMLStreamException {
if (closed) {
throw new XMLStreamException("XMLEventReader has been closed");
}
}
public void close() {
closed = true;
}
}

View File

@@ -1,96 +0,0 @@
/*
* Copyright 2005-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.xml.stream;
import javax.xml.namespace.NamespaceContext;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLEventWriter;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.XMLEvent;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.xml.namespace.SimpleNamespaceContext;
/**
* @author Arjen Poutsma
*/
public abstract class AbstractXMLEventWriter implements XMLEventWriter {
private boolean closed;
private SimpleNamespaceContext namespaceContext = new SimpleNamespaceContext();
public void flush() throws XMLStreamException {
}
public void add(XMLEventReader eventReader) throws XMLStreamException {
checkIfClosed();
while (eventReader.hasNext()) {
XMLEvent event = eventReader.nextEvent();
add(event);
}
}
public String getPrefix(String uri) throws XMLStreamException {
return namespaceContext.getPrefix(uri);
}
public void setPrefix(String prefix, String uri) throws XMLStreamException {
namespaceContext.bindNamespaceUri(prefix, uri);
}
public void setDefaultNamespace(String uri) throws XMLStreamException {
namespaceContext.bindDefaultNamespaceUri(uri);
}
public void setNamespaceContext(NamespaceContext namespaceContext) throws XMLStreamException {
Assert.notNull(namespaceContext, "'namespaceContext' must not be null");
this.namespaceContext = (SimpleNamespaceContext) namespaceContext;
}
public NamespaceContext getNamespaceContext() {
return namespaceContext;
}
/**
* Returns <code>true</code> if closed; <code>false</code> otherwise.
*
* @see #close()
*/
protected boolean isClosed() {
return closed;
}
/**
* Checks if the reader is closed, and throws a <code>XMLStreamException</code> if so.
*
* @throws XMLStreamException if the reader is closed
* @see #close()
* @see #isClosed()
*/
protected void checkIfClosed() throws XMLStreamException {
if (closed) {
throw new XMLStreamException(ClassUtils.getShortName(getClass()) + " has been closed");
}
}
public void close() {
closed = true;
}
}

View File

@@ -1,101 +0,0 @@
/*
* Copyright 2005-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.xml.stream;
import java.util.List;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.XMLEvent;
import org.springframework.util.Assert;
/**
* Implementation of {@link XMLEventReader} that combines multiple other {@code XMLEventReader}s.
*
* @author Arjen Poutsma
*/
public class CompositeXMLEventReader extends AbstractXMLEventReader {
private final XMLEventReader[] eventReaders;
private int cursor = 0;
public CompositeXMLEventReader(XMLEventReader eventReader) {
Assert.notNull(eventReader, "'eventReader' must not be null");
this.eventReaders = new XMLEventReader[]{eventReader};
}
public CompositeXMLEventReader(XMLEventReader... eventReaders) {
Assert.notNull(eventReaders, "'eventReaders' must not be null");
this.eventReaders = eventReaders;
}
public CompositeXMLEventReader(List<XMLEventReader> eventReaders) {
Assert.notNull(eventReaders, "'eventReaders' must not be null");
this.eventReaders = eventReaders.toArray(new XMLEventReader[eventReaders.size()]);
}
public boolean hasNext() {
while (cursor < eventReaders.length) {
if (!atLastEventReader()) {
if (!currentEventReader().hasNext()) {
cursor++;
continue;
}
}
return currentEventReader().hasNext();
}
return false;
}
public XMLEvent nextEvent() throws XMLStreamException {
XMLEvent event = null;
while (cursor < eventReaders.length) {
event = currentEventReader().nextEvent();
if (!atLastEventReader() && event.isEndDocument()) {
cursor++;
}
else {
break;
}
}
return event;
}
public XMLEvent peek() throws XMLStreamException {
XMLEvent event = null;
while (cursor < eventReaders.length) {
event = currentEventReader().peek();
if (!atLastEventReader() && (event == null || event.isEndDocument())) {
cursor++;
}
else {
break;
}
}
return event;
}
private XMLEventReader currentEventReader() {
return eventReaders[cursor];
}
private boolean atLastEventReader() {
return cursor == eventReaders.length - 1;
}
}

View File

@@ -1,79 +0,0 @@
/*
* Copyright 2005-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.xml.stream;
import java.util.List;
import java.util.NoSuchElementException;
import javax.xml.stream.events.XMLEvent;
import org.springframework.util.Assert;
/**
* @author Arjen Poutsma
*/
public class ListBasedXMLEventReader extends AbstractXMLEventReader {
private final XMLEvent[] events;
private int cursor = 0;
public ListBasedXMLEventReader() {
this.events = new XMLEvent[0];
}
public ListBasedXMLEventReader(XMLEvent event) {
if (event != null) {
this.events = new XMLEvent[]{event};
}
else {
this.events = new XMLEvent[0];
}
}
public ListBasedXMLEventReader(XMLEvent... events) {
Assert.notNull(events, "'events' must not be null");
this.events = events;
}
public ListBasedXMLEventReader(List<XMLEvent> events) {
Assert.notNull(events, "'events' must not be null");
this.events = events.toArray(new XMLEvent[events.size()]);
}
public boolean hasNext() {
Assert.notNull(events, "'events' must not be null");
return cursor != events.length;
}
public XMLEvent nextEvent() {
if (cursor < events.length) {
return events[cursor++];
}
else {
throw new NoSuchElementException();
}
}
public XMLEvent peek() {
if (cursor < events.length) {
return events[cursor];
}
else {
return null;
}
}
}

View File

@@ -1,7 +0,0 @@
log4j.rootCategory=WARN, stdout
log4j.logger.org.springframework.ws=DEBUG
log4j.logger.org.springframework.jms=DEBUG
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n

View File

@@ -1,107 +0,0 @@
/*
* Copyright 2005-2010 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.jaxws;
import javax.xml.namespace.QName;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPMessage;
import javax.xml.transform.Source;
import javax.xml.ws.Provider;
import javax.xml.ws.Service;
import javax.xml.ws.ServiceMode;
import javax.xml.ws.WebServiceProvider;
import junit.framework.TestCase;
import org.springframework.ws.context.DefaultMessageContext;
import org.springframework.ws.context.MessageContext;
import org.springframework.ws.soap.saaj.SaajSoapMessage;
import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;
public class JaxWsProviderEndpointAdapterTest extends TestCase {
private JaxWsProviderEndpointAdapter adapter;
private MessageContext messageContext;
@Override
protected void setUp() throws Exception {
adapter = new JaxWsProviderEndpointAdapter();
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage request = messageFactory.createMessage();
request.getSOAPBody().addBodyElement(new QName("http://springframework.org/spring-ws", "content"));
messageContext =
new DefaultMessageContext(new SaajSoapMessage(request), new SaajSoapMessageFactory(messageFactory));
}
public void testSupports() throws Exception {
MyMessageProvider messageProvider = new MyMessageProvider();
assertTrue("Does not support message provider", adapter.supports(messageProvider));
MySourceProvider sourceProvider = new MySourceProvider();
assertTrue("Does not support source provider", adapter.supports(sourceProvider));
MyDefaultProvider defaultProvider = new MyDefaultProvider();
assertTrue("Does not support source provider", adapter.supports(defaultProvider));
}
public void testInvokeMessageProvider() throws Exception {
MyMessageProvider provider = new MyMessageProvider();
adapter.invoke(messageContext, provider);
assertTrue("No response", messageContext.hasResponse());
SaajSoapMessage request = (SaajSoapMessage) messageContext.getRequest();
SaajSoapMessage response = (SaajSoapMessage) messageContext.getResponse();
assertEquals("Invalid response", request.getSaajMessage(), response.getSaajMessage());
}
public void testInvokeSourceProvider() throws Exception {
MySourceProvider provider = new MySourceProvider();
adapter.invoke(messageContext, provider);
assertTrue("No response", messageContext.hasResponse());
}
public void testInvokeDefaultProvider() throws Exception {
MyDefaultProvider provider = new MyDefaultProvider();
adapter.invoke(messageContext, provider);
assertTrue("No response", messageContext.hasResponse());
}
@WebServiceProvider
@ServiceMode(Service.Mode.MESSAGE)
private static class MyMessageProvider implements Provider<SOAPMessage> {
public SOAPMessage invoke(SOAPMessage request) {
return request;
}
}
@WebServiceProvider
@ServiceMode(value = Service.Mode.PAYLOAD)
private static class MySourceProvider implements Provider<Source> {
public Source invoke(Source request) {
return request;
}
}
@WebServiceProvider
private static class MyDefaultProvider implements Provider<Source> {
public Source invoke(Source request) {
return request;
}
}
}

View File

@@ -1,37 +0,0 @@
/*
* Copyright 2005-2010 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.stroap;
import org.springframework.ws.soap.SoapBody;
import org.springframework.ws.soap.soap11.AbstractSoap11BodyTestCase;
public class Stroap11BodyTest extends AbstractSoap11BodyTestCase {
@Override
protected SoapBody createSoapBody() throws Exception {
StroapMessageFactory messageFactory = new StroapMessageFactory();
return new Stroap11Body(messageFactory);
}
@Override
public void testAddFaultWithDetail() throws Exception {
}
@Override
public void testAddFaultWithDetailResult() throws Exception {
}
}

View File

@@ -1,31 +0,0 @@
/*
* Copyright 2005-2010 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.stroap;
import org.springframework.ws.soap.SoapEnvelope;
import org.springframework.ws.soap.soap11.AbstractSoap11EnvelopeTestCase;
public class Stroap11EnvelopeTest extends AbstractSoap11EnvelopeTestCase {
@Override
protected SoapEnvelope createSoapEnvelope() throws Exception {
StroapMessageFactory messageFactory = new StroapMessageFactory();
StroapEnvelope envelope = new StroapEnvelope(messageFactory);
envelope.getHeader();
return envelope;
}
}

View File

@@ -1,29 +0,0 @@
/*
* Copyright 2005-2010 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.stroap;
import org.springframework.ws.soap.SoapHeader;
import org.springframework.ws.soap.soap11.AbstractSoap11HeaderTestCase;
public class Stroap11HeaderTest extends AbstractSoap11HeaderTestCase {
@Override
protected SoapHeader createSoapHeader() throws Exception {
StroapMessageFactory messageFactory = new StroapMessageFactory();
return new Stroap11Header(messageFactory);
}
}

View File

@@ -1,40 +0,0 @@
/*
* Copyright 2005-2010 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.stroap;
import org.springframework.ws.WebServiceMessageFactory;
import org.springframework.ws.soap.soap11.AbstractSoap11MessageFactoryTestCase;
public class Stroap11MessageFactoryTest extends AbstractSoap11MessageFactoryTestCase {
@Override
protected WebServiceMessageFactory createMessageFactory() throws Exception {
return new StroapMessageFactory();
}
@Override
public void testCreateSoapMessageMtom() throws Exception {
}
@Override
public void testCreateSoapMessageSwA() throws Exception {
}
@Override
public void testCreateSoapMessageMtomWeirdStartInfo() throws Exception {
}
}

View File

@@ -1,46 +0,0 @@
/*
* Copyright 2005-2010 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.stroap;
import org.springframework.ws.soap.SoapMessage;
import org.springframework.ws.soap.soap11.AbstractSoap11MessageTestCase;
public class Stroap11MessageTest extends AbstractSoap11MessageTestCase {
@Override
protected final SoapMessage createSoapMessage() throws Exception {
StroapMessageFactory messageFactory = new StroapMessageFactory();
return new StroapMessage(messageFactory);
}
@Override
public void testWriteToTransportResponseAttachment() throws Exception {
}
@Override
public void testAddAttachment() throws Exception {
}
@Override
public void testGetAttachment() throws Exception {
}
@Override
public void testGetAttachments() throws Exception {
}
}

View File

@@ -1,33 +0,0 @@
/*
* Copyright 2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* 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.transport.tcp;
import java.io.IOException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/** @author Arjen Poutsma */
public class Driver {
public static void main(String[] args) throws IOException {
new ClassPathXmlApplicationContext("applicationContext.xml", Driver.class);
System.out.println("Started....");
System.in.read();
}
}

View File

@@ -1,47 +0,0 @@
/*
* Copyright 2005-2010 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.transport.tcp;
import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
import org.springframework.ws.client.core.WebServiceTemplate;
import org.springframework.xml.transform.StringResult;
import org.springframework.xml.transform.StringSource;
import org.custommonkey.xmlunit.XMLAssert;
import org.junit.Ignore;
@Ignore
public class TcpIntegrationTest extends AbstractDependencyInjectionSpringContextTests {
private WebServiceTemplate webServiceTemplate;
protected String[] getConfigLocations() {
return new String[]{"classpath:org/springframework/ws/transport/tcp/tcp-applicationContext.xml"};
}
public void setWebServiceTemplate(WebServiceTemplate webServiceTemplate) {
this.webServiceTemplate = webServiceTemplate;
}
public void testJmsTransport() throws Exception {
String content = "<root xmlns='http://springframework.org/spring-ws'><child/></root>";
StringResult result = new StringResult();
webServiceTemplate.sendSourceAndReceiveToResult(new StringSource(content), result);
XMLAssert.assertXMLEqual("Invalid content received", content, result.toString());
applicationContext.close();
}
}

View File

@@ -1,90 +0,0 @@
/*
* Copyright 2005-2010 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.transport.tcp;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.net.Socket;
import javax.xml.transform.stream.StreamResult;
import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
import org.springframework.ws.WebServiceMessageFactory;
import org.springframework.ws.client.core.WebServiceTemplate;
import org.springframework.ws.transport.WebServiceMessageSender;
import org.springframework.xml.transform.StringSource;
import org.junit.Ignore;
@Ignore
public class TcpMessageReceiverIntegrationTest extends AbstractDependencyInjectionSpringContextTests {
private WebServiceMessageFactory messageFactory;
private WebServiceMessageSender messageSender;
public void setMessageFactory(WebServiceMessageFactory messageFactory) {
this.messageFactory = messageFactory;
}
public void setMessageSender(WebServiceMessageSender messageSender) {
this.messageSender = messageSender;
}
public static final String REQUEST =
"<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'\n" +
" SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>\n" +
" <SOAP-ENV:Body>\n" +
" <m:GetLastTradePrice xmlns:m='http://www.springframework.org/spring-ws'>\n" +
" <symbol>DIS</symbol>\n" + " </m:GetLastTradePrice>\n" +
" </SOAP-ENV:Body>\n" + "</SOAP-ENV:Envelope>";
public void testServer() throws IOException, InterruptedException {
Socket socket = new Socket("localhost", TcpMessageReceiver.DEFAULT_PORT);
Writer writer;
BufferedReader reader;
try {
writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream(), "UTF-8"));
writer.write(REQUEST);
writer.flush();
socket.shutdownOutput();
reader = new BufferedReader(new InputStreamReader(socket.getInputStream(), "UTF-8"));
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
}
finally {
socket.close();
}
}
public void testTemplate() throws Exception {
WebServiceTemplate template = new WebServiceTemplate(messageFactory);
template.setMessageSender(messageSender);
template.sendSourceAndReceiveToResult("tcp://localhost", new StringSource(REQUEST),
new StreamResult(System.out));
}
protected String[] getConfigLocations() {
return new String[]{"classpath:/org/springframework/ws/transport/tcp/applicationContext.xml"};
}
}

View File

@@ -1,95 +0,0 @@
/*
* Copyright 2005-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.xml.stream;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.NoSuchElementException;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.XMLEvent;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* @author Arjen Poutsma
*/
public class CompositeXMLEventReaderTest {
private CompositeXMLEventReader chain;
private XMLInputFactory inputFactory;
private List<XMLEvent> expectedEvents = new ArrayList<XMLEvent>();
@Before
public void createChainUp() throws Exception {
inputFactory = XMLInputFactory.newFactory();
List<XMLEvent> events = getEvents("<event1-1><event1-2>text1</event1-2></event1-1>");
expectedEvents.addAll(events);
XMLEventReader reader1 = new ListBasedXMLEventReader(events);
XMLEventReader reader2 = new ListBasedXMLEventReader();
events = getEvents("<event2-1></event2-1>");
expectedEvents.addAll(events);
XMLEventReader reader3 = new ListBasedXMLEventReader(events);
XMLEventReader reader4 = new ListBasedXMLEventReader();
chain = new CompositeXMLEventReader(reader1, reader2, reader3, reader4);
}
private List<XMLEvent> getEvents(String xml) throws XMLStreamException {
XMLEventReader eventReader = inputFactory.createXMLEventReader(new StringReader(xml));
List<XMLEvent> events = new LinkedList<XMLEvent>();
while (eventReader.hasNext()) {
XMLEvent event = eventReader.nextEvent();
if (!(event.isStartDocument() || event.isEndDocument())) {
events.add(event);
}
}
return events;
}
@Test
public void testChain() throws Exception {
for (XMLEvent expectedEvent : expectedEvents) {
testEvent(expectedEvent);
}
assertFalse("hasNext returns true", chain.hasNext());
assertNull("peek returns element", chain.peek());
try {
chain.nextEvent();
fail("NoSuchElementElementException expected");
}
catch (NoSuchElementException e) {
// expected
}
}
private void testEvent(XMLEvent expected) throws XMLStreamException {
assertEquals("1st peek returns invalid result", expected, chain.peek());
assertEquals("2nd peek returns invalid result", expected, chain.peek());
assertTrue("hasNext returns false", chain.hasNext());
assertEquals("nextEvent returns invalid result", expected, chain.nextEvent());
}
}

View File

@@ -1,38 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="messagingReceiver" class="org.springframework.ws.transport.tcp.TcpMessageReceiver">
<property name="messageFactory" ref="messageFactory"/>
<property name="messageReceiver">
<bean class="org.springframework.ws.transport.SimpleTestingMessageReceiver"/>
</property>
</bean>
<bean id="tcpSender" class="org.springframework.ws.transport.tcp.TcpMessageSender" />
<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory"/>
<!-- define an MBeanExporter -->
<bean id="mbeanExporter" class="org.springframework.jmx.export.MBeanExporter">
<!-- the beans to be exported to JMX -->
<property name="beans">
<map>
<entry key="spring-ws:service=messagingContainer">
<ref local="messagingReceiver"/>
</entry>
</map>
</property>
<property name="assembler">
<bean class="org.springframework.jmx.export.assembler.InterfaceBasedMBeanInfoAssembler">
<property name="interfaceMappings">
<props>
<prop key="spring-ws:service=messagingContainer">org.springframework.context.Lifecycle</prop>
</props>
</property>
</bean>
</property>
</bean>
</beans>

View File

@@ -1,38 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd">
<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory">
<property name="soapVersion">
<util:constant static-field="org.springframework.ws.soap.SoapVersion.SOAP_12"/>
</property>
</bean>
<bean id="messagingReceiver" class="org.springframework.ws.transport.tcp.TcpMessageReceiver">
<property name="messageFactory" ref="messageFactory"/>
<property name="messageReceiver" ref="messageDispatcher"/>
<property name="bindAddress" value="localhost"/>
</bean>
<bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate">
<constructor-arg ref="messageFactory"/>
<property name="messageSender">
<bean class="org.springframework.ws.transport.tcp.TcpMessageSender"/>
</property>
<property name="defaultUri" value="tcp://localhost"/>
</bean>
<bean id="messageDispatcher" class="org.springframework.ws.soap.server.SoapMessageDispatcher">
<property name="endpointMappings">
<bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping">
<property name="defaultEndpoint">
<bean class="org.springframework.ws.transport.support.EchoPayloadEndpoint"/>
</property>
</bean>
</property>
</bean>
</beans>