Converted spaces to tabs
This commit changes leading spaces in all Java source files to tabs, to be consistent with other Spring projects.
This commit is contained in:
@@ -23,18 +23,18 @@ 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());
|
||||
/** Logger available to subclasses. */
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
/** Lower-level class used to invoke Web service. */
|
||||
private WebServiceTemplate webServiceTemplate = new WebServiceTemplate();
|
||||
/** 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;
|
||||
}
|
||||
/** Returns the {@link WebServiceTemplate} used by this object. */
|
||||
public WebServiceTemplate getWebServiceTemplate() {
|
||||
return webServiceTemplate;
|
||||
}
|
||||
|
||||
public void setWebServiceTemplate(WebServiceTemplate webServiceTemplate) {
|
||||
this.webServiceTemplate = webServiceTemplate;
|
||||
}
|
||||
public void setWebServiceTemplate(WebServiceTemplate webServiceTemplate) {
|
||||
this.webServiceTemplate = webServiceTemplate;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,43 +39,43 @@ import org.springframework.xml.transform.TransformerObjectSupport;
|
||||
*/
|
||||
public class JaxWsProviderEndpointAdapter extends TransformerObjectSupport implements EndpointAdapter {
|
||||
|
||||
public boolean supports(Object endpoint) {
|
||||
return endpoint.getClass().getAnnotation(WebServiceProvider.class) != null && endpoint instanceof Provider;
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
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 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);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,184 +45,184 @@ import org.apache.commons.logging.LogFactory;
|
||||
|
||||
public class PerformanceTest {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(PerformanceTest.class);
|
||||
private static final Log logger = LogFactory.getLog(PerformanceTest.class);
|
||||
|
||||
private static final int ITERATIONS = 1000;
|
||||
private static final int ITERATIONS = 1000;
|
||||
|
||||
private static final int ELEMENTS = 500;
|
||||
private static final int ELEMENTS = 500;
|
||||
|
||||
private SoapMessageFactory messageFactory;
|
||||
private SoapMessageFactory messageFactory;
|
||||
|
||||
private Marshaller marshaller;
|
||||
private Marshaller marshaller;
|
||||
|
||||
private StopWatch stopWatch;
|
||||
private StopWatch stopWatch;
|
||||
|
||||
private MyRootElement jaxbElement;
|
||||
private MyRootElement jaxbElement;
|
||||
|
||||
private OutputStream os;
|
||||
private OutputStream os;
|
||||
|
||||
private boolean streaming = false;
|
||||
private boolean streaming = false;
|
||||
|
||||
private static final QName NAME = new QName("http://springframework.org", "root");
|
||||
private static final QName NAME = new QName("http://springframework.org", "root");
|
||||
|
||||
private Transformer transformer;
|
||||
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);
|
||||
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));
|
||||
}
|
||||
jaxbElement = new MyRootElement();
|
||||
for (int i = 0; i < ELEMENTS; i++) {
|
||||
jaxbElement.getStrings().add(String.valueOf(i));
|
||||
}
|
||||
|
||||
os = new NullOutputSteam();
|
||||
os = new NullOutputSteam();
|
||||
|
||||
this.stopWatch = stopWatch;
|
||||
this.stopWatch = stopWatch;
|
||||
|
||||
this.transformer = TransformerFactory.newInstance().newTransformer();
|
||||
}
|
||||
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();
|
||||
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);
|
||||
marshal(message, streaming);
|
||||
|
||||
transformer.transform(message.getPayloadSource(), new StreamResult(os));
|
||||
transformer.transform(message.getPayloadSource(), new StreamResult(os));
|
||||
|
||||
message.writeTo(os);
|
||||
message.writeTo(os);
|
||||
|
||||
|
||||
}
|
||||
stopWatch.stop();
|
||||
}
|
||||
}
|
||||
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);
|
||||
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());
|
||||
}
|
||||
}
|
||||
streamingMessage.setStreamingPayload(payload);
|
||||
}
|
||||
else {
|
||||
marshaller.marshal(jaxbElement, message.getPayloadResult());
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
StopWatch stopWatch = new StopWatch();
|
||||
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);
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
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 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 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);
|
||||
}
|
||||
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 {
|
||||
@XmlRootElement(name = "root", namespace = "http://springframework.org")
|
||||
public static class MyRootElement {
|
||||
|
||||
private List<String> strings;
|
||||
private List<String> strings;
|
||||
|
||||
@XmlElement(name = "string", namespace = "http://springframework.org")
|
||||
public List<String> getStrings() {
|
||||
if (strings == null) {
|
||||
strings = new ArrayList<String>();
|
||||
}
|
||||
return 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 {
|
||||
private static class NullOutputSteam extends OutputStream {
|
||||
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
}
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] 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 write(byte[] b, int off, int len) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() throws IOException {
|
||||
}
|
||||
@Override
|
||||
public void flush() throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
}
|
||||
}
|
||||
|
||||
private static class JaxbStreamingPayload implements StreamingPayload {
|
||||
private static class JaxbStreamingPayload implements StreamingPayload {
|
||||
|
||||
private final Object jaxbElement;
|
||||
private final Object jaxbElement;
|
||||
|
||||
private final QName name;
|
||||
private final QName name;
|
||||
|
||||
private final Marshaller marshaller;
|
||||
private final Marshaller marshaller;
|
||||
|
||||
private JaxbStreamingPayload(Object jaxbElement, QName name, Marshaller marshaller) {
|
||||
this.jaxbElement = jaxbElement;
|
||||
this.name = name;
|
||||
this.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 QName getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void writeTo(XMLStreamWriter streamWriter) throws XMLStreamException {
|
||||
try {
|
||||
marshaller.marshal(jaxbElement, streamWriter);
|
||||
}
|
||||
catch (JAXBException ex) {
|
||||
throw new XMLStreamException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void writeTo(XMLStreamWriter streamWriter) throws XMLStreamException {
|
||||
try {
|
||||
marshaller.marshal(jaxbElement, streamWriter);
|
||||
}
|
||||
catch (JAXBException ex) {
|
||||
throw new XMLStreamException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -32,36 +32,36 @@ import org.springframework.xml.stream.ListBasedXMLEventReader;
|
||||
*/
|
||||
class CachingStroapPayload extends StroapPayload {
|
||||
|
||||
private final List<XMLEvent> events = new LinkedList<XMLEvent>();
|
||||
private final List<XMLEvent> events = new LinkedList<XMLEvent>();
|
||||
|
||||
CachingStroapPayload() {
|
||||
}
|
||||
CachingStroapPayload() {
|
||||
}
|
||||
|
||||
CachingStroapPayload(XMLEventReader eventReader) throws XMLStreamException {
|
||||
Assert.notNull(eventReader, "'eventReader' must not be null");
|
||||
XMLEventWriter eventWriter = getEventWriter();
|
||||
eventWriter.add(eventReader);
|
||||
}
|
||||
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 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);
|
||||
}
|
||||
@Override
|
||||
public XMLEventReader getEventReader() {
|
||||
return new ListBasedXMLEventReader(events);
|
||||
}
|
||||
|
||||
public XMLEventWriter getEventWriter() {
|
||||
events.clear();
|
||||
return new CachingXMLEventWriter(events);
|
||||
}
|
||||
public XMLEventWriter getEventWriter() {
|
||||
events.clear();
|
||||
return new CachingXMLEventWriter(events);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,30 +28,30 @@ import org.springframework.xml.stream.AbstractXMLEventWriter;
|
||||
*/
|
||||
class CachingXMLEventWriter extends AbstractXMLEventWriter {
|
||||
|
||||
private int elementDepth = 0;
|
||||
private int elementDepth = 0;
|
||||
|
||||
boolean startElementSeen = false;
|
||||
boolean startElementSeen = false;
|
||||
|
||||
private final List<XMLEvent> events;
|
||||
private final List<XMLEvent> events;
|
||||
|
||||
CachingXMLEventWriter(List<XMLEvent> events) {
|
||||
Assert.notNull(events, "'events' must not be null");
|
||||
this.events = 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);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,25 +27,25 @@ import org.springframework.ws.soap.SoapFault;
|
||||
*/
|
||||
class FaultStroapPayload extends StroapPayload {
|
||||
|
||||
private final StroapFault fault;
|
||||
private final StroapFault fault;
|
||||
|
||||
FaultStroapPayload(StroapFault fault) {
|
||||
Assert.notNull(fault, "'fault' must not be null");
|
||||
this.fault = fault;
|
||||
}
|
||||
FaultStroapPayload(StroapFault fault) {
|
||||
Assert.notNull(fault, "'fault' must not be null");
|
||||
this.fault = fault;
|
||||
}
|
||||
|
||||
SoapFault getFault() {
|
||||
return fault;
|
||||
}
|
||||
SoapFault getFault() {
|
||||
return fault;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QName getName() {
|
||||
return fault.getName();
|
||||
}
|
||||
@Override
|
||||
public QName getName() {
|
||||
return fault.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public XMLEventReader getEventReader() {
|
||||
return fault.getEventReader(false);
|
||||
}
|
||||
@Override
|
||||
public XMLEventReader getEventReader() {
|
||||
return fault.getEventReader(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,62 +30,62 @@ import org.springframework.xml.stream.AbstractXMLEventReader;
|
||||
*/
|
||||
class NonCachingStroapPayload extends StroapPayload {
|
||||
|
||||
private final XMLEventReader eventReader;
|
||||
private final XMLEventReader eventReader;
|
||||
|
||||
private int elementDepth = 0;
|
||||
private int elementDepth = 0;
|
||||
|
||||
NonCachingStroapPayload(XMLEventReader eventReader) throws XMLStreamException {
|
||||
Assert.notNull(eventReader, "'eventReader' must not be null");
|
||||
this.eventReader = eventReader;
|
||||
}
|
||||
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();
|
||||
}
|
||||
@Override
|
||||
public QName getName() {
|
||||
try {
|
||||
XMLEvent event = eventReader.peek();
|
||||
if (event != null && event.isStartElement()) {
|
||||
return event.asStartElement().getName();
|
||||
}
|
||||
|
||||
}
|
||||
catch (XMLStreamException ex) {
|
||||
// ignore
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
catch (XMLStreamException ex) {
|
||||
// ignore
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XMLEventReader getEventReader() {
|
||||
return new NonCachingXMLEventReader();
|
||||
}
|
||||
@Override
|
||||
public XMLEventReader getEventReader() {
|
||||
return new NonCachingXMLEventReader();
|
||||
}
|
||||
|
||||
private class NonCachingXMLEventReader extends AbstractXMLEventReader {
|
||||
private class NonCachingXMLEventReader extends AbstractXMLEventReader {
|
||||
|
||||
public boolean hasNext() {
|
||||
return elementDepth >= 0 && eventReader.hasNext();
|
||||
}
|
||||
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 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
public XMLEvent peek() throws XMLStreamException {
|
||||
if (elementDepth < 0) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
return eventReader.peek();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,42 +33,42 @@ import org.springframework.ws.stream.StreamingPayload;
|
||||
*/
|
||||
class StreamingStroapPayload extends StroapPayload {
|
||||
|
||||
private final StreamingPayload payload;
|
||||
private final StreamingPayload payload;
|
||||
|
||||
private final StroapMessageFactory messageFactory;
|
||||
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");
|
||||
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;
|
||||
}
|
||||
this.payload = payload;
|
||||
this.messageFactory = messageFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QName getName() {
|
||||
return payload.getName();
|
||||
}
|
||||
@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 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);
|
||||
}
|
||||
@Override
|
||||
public void writeTo(XMLEventWriter eventWriter) throws XMLStreamException {
|
||||
XMLStreamWriter streamWriter = StaxUtils.createEventStreamWriter(eventWriter, messageFactory.getEventFactory());
|
||||
payload.writeTo(streamWriter);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,67 +30,67 @@ import org.springframework.ws.soap.soap11.Soap11Fault;
|
||||
*/
|
||||
class Stroap11Body extends StroapBody implements Soap11Body {
|
||||
|
||||
private static final String ENVELOPE_NAMESPACE_URI = "http://schemas.xmlsoap.org/soap/envelope/";
|
||||
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 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 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 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);
|
||||
private QName VERSION_MISMATCH_FAULT_NAME = new QName(ENVELOPE_NAMESPACE_URI, "VersionMismatch", DEFAULT_PREFIX);
|
||||
|
||||
Stroap11Body(StroapMessageFactory messageFactory) {
|
||||
super(messageFactory);
|
||||
}
|
||||
Stroap11Body(StroapMessageFactory messageFactory) {
|
||||
super(messageFactory);
|
||||
}
|
||||
|
||||
Stroap11Body(StartElement startElement, StroapPayload payload, StroapMessageFactory messageFactory) {
|
||||
super(startElement, payload, messageFactory);
|
||||
}
|
||||
Stroap11Body(StartElement startElement, StroapPayload payload, StroapMessageFactory messageFactory) {
|
||||
super(startElement, payload, messageFactory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Soap11Fault getFault() {
|
||||
return (Soap11Fault) super.getFault();
|
||||
}
|
||||
@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 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 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 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 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");
|
||||
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;
|
||||
}
|
||||
Stroap11Fault fault = new Stroap11Fault(faultCode, faultString, faultStringLocale, getMessageFactory());
|
||||
setFault(fault);
|
||||
return fault;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,124 +34,124 @@ import org.springframework.xml.stream.ListBasedXMLEventReader;
|
||||
*/
|
||||
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 static final QName XML_LANG_NAME = new QName(XMLConstants.XML_NS_URI, "lang", XMLConstants.XML_NS_PREFIX);
|
||||
|
||||
private final FaultElement faultCode;
|
||||
private final FaultElement faultCode;
|
||||
|
||||
private final FaultElement faultString;
|
||||
private final FaultElement faultString;
|
||||
|
||||
private FaultElement faultActor;
|
||||
private FaultElement faultActor;
|
||||
|
||||
Stroap11Fault(QName faultCode, String faultString, Locale faultStringLocale, StroapMessageFactory messageFactory) {
|
||||
super(messageFactory);
|
||||
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());
|
||||
}
|
||||
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());
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
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 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 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 String getFaultActorOrRole() {
|
||||
return faultActor != null ? faultActor.getCharacterData() : null;
|
||||
}
|
||||
|
||||
public void setFaultActorOrRole(String faultActor) {
|
||||
this.faultActor = FaultElement.createFaultActor(faultActor, getMessageFactory());
|
||||
}
|
||||
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 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.
|
||||
}
|
||||
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);
|
||||
}
|
||||
@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 static class FaultElement extends StroapElement {
|
||||
|
||||
private final Characters characters;
|
||||
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);
|
||||
}
|
||||
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 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 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 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();
|
||||
}
|
||||
public String getCharacterData() {
|
||||
return characters.getData();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected XMLEventReader getChildEventReader() {
|
||||
return new ListBasedXMLEventReader(characters);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected XMLEventReader getChildEventReader() {
|
||||
return new ListBasedXMLEventReader(characters);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,42 +32,42 @@ import org.springframework.ws.soap.soap11.Soap11Header;
|
||||
*/
|
||||
class Stroap11Header extends StroapHeader implements Soap11Header {
|
||||
|
||||
Stroap11Header(StroapMessageFactory messageFactory) {
|
||||
super(messageFactory);
|
||||
}
|
||||
Stroap11Header(StroapMessageFactory messageFactory) {
|
||||
super(messageFactory);
|
||||
}
|
||||
|
||||
Stroap11Header(StartElement startElement, StroapMessageFactory messageFactory) {
|
||||
super(startElement, 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();
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,92 +36,92 @@ import org.springframework.ws.stream.StreamingPayload;
|
||||
*/
|
||||
abstract class StroapBody extends StroapElement implements SoapBody {
|
||||
|
||||
private StroapPayload payload;
|
||||
private StroapPayload payload;
|
||||
|
||||
protected StroapBody(StroapMessageFactory messageFactory) {
|
||||
super(messageFactory.getSoapVersion().getBodyName(), messageFactory);
|
||||
this.payload = new CachingStroapPayload();
|
||||
}
|
||||
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;
|
||||
}
|
||||
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);
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
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 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 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 boolean hasFault() {
|
||||
return payload instanceof FaultStroapPayload;
|
||||
}
|
||||
|
||||
public SoapFault getFault() {
|
||||
return payload instanceof FaultStroapPayload ? ((FaultStroapPayload) payload).getFault() : null;
|
||||
}
|
||||
public SoapFault getFault() {
|
||||
return payload instanceof FaultStroapPayload ? ((FaultStroapPayload) payload).getFault() : null;
|
||||
}
|
||||
|
||||
protected void setFault(StroapFault fault) {
|
||||
this.payload = new FaultStroapPayload(fault);
|
||||
}
|
||||
protected void setFault(StroapFault fault) {
|
||||
this.payload = new FaultStroapPayload(fault);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final XMLEventReader getChildEventReader() {
|
||||
return payload.getEventReader();
|
||||
}
|
||||
@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());
|
||||
}
|
||||
@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 void setStreamingPayload(StreamingPayload payload) {
|
||||
this.payload = new StreamingStroapPayload(payload, getMessageFactory());
|
||||
}
|
||||
|
||||
public QName getPayloadName() {
|
||||
return payload.getName();
|
||||
}
|
||||
public QName getPayloadName() {
|
||||
return payload.getName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,15 +23,15 @@ import org.springframework.ws.soap.SoapBodyException;
|
||||
*/
|
||||
public class StroapBodyException extends SoapBodyException {
|
||||
|
||||
public StroapBodyException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
public StroapBodyException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public StroapBodyException(String msg, Throwable ex) {
|
||||
super(msg, ex);
|
||||
}
|
||||
public StroapBodyException(String msg, Throwable ex) {
|
||||
super(msg, ex);
|
||||
}
|
||||
|
||||
public StroapBodyException(Throwable ex) {
|
||||
super(ex);
|
||||
}
|
||||
public StroapBodyException(Throwable ex) {
|
||||
super(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,217 +44,217 @@ import org.springframework.xml.stream.AbstractXMLEventReader;
|
||||
*/
|
||||
abstract class StroapElement implements SoapElement {
|
||||
|
||||
protected static final String DEFAULT_PREFIX = "SOAP-ENV";
|
||||
protected static final String DEFAULT_PREFIX = "SOAP-ENV";
|
||||
|
||||
private final StroapMessageFactory messageFactory;
|
||||
private final StroapMessageFactory messageFactory;
|
||||
|
||||
private StartElement startElement;
|
||||
private StartElement startElement;
|
||||
|
||||
private EndElement endElement;
|
||||
private EndElement endElement;
|
||||
|
||||
protected StroapElement(QName name, StroapMessageFactory messageFactory) {
|
||||
this(createStartElement(name, messageFactory), messageFactory);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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());
|
||||
}
|
||||
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));
|
||||
}
|
||||
public final Source getSource() {
|
||||
return StaxUtils.createCustomStaxSource(getEventReader(true));
|
||||
}
|
||||
|
||||
protected XMLEventReader getEventReader(boolean documentEvents) {
|
||||
return new StroapElementEventReader(documentEvents);
|
||||
}
|
||||
protected XMLEventReader getEventReader(boolean documentEvents) {
|
||||
return new StroapElementEventReader(documentEvents);
|
||||
}
|
||||
|
||||
public void writeTo(XMLEventWriter eventWriter) throws XMLStreamException {
|
||||
eventWriter.add(getEventReader(false));
|
||||
}
|
||||
public void writeTo(XMLEventWriter eventWriter) throws XMLStreamException {
|
||||
eventWriter.add(getEventReader(false));
|
||||
}
|
||||
|
||||
protected StroapMessageFactory getMessageFactory() {
|
||||
return messageFactory;
|
||||
}
|
||||
protected StroapMessageFactory getMessageFactory() {
|
||||
return messageFactory;
|
||||
}
|
||||
|
||||
protected final XMLEventFactory getEventFactory() {
|
||||
return getMessageFactory().getEventFactory();
|
||||
}
|
||||
protected final XMLEventFactory getEventFactory() {
|
||||
return getMessageFactory().getEventFactory();
|
||||
}
|
||||
|
||||
protected SoapVersion getSoapVersion() {
|
||||
return getMessageFactory().getSoapVersion();
|
||||
}
|
||||
protected SoapVersion getSoapVersion() {
|
||||
return getMessageFactory().getSoapVersion();
|
||||
}
|
||||
|
||||
public final QName getName() {
|
||||
return getStartElement().getName();
|
||||
}
|
||||
public final QName getName() {
|
||||
return getStartElement().getName();
|
||||
}
|
||||
|
||||
protected abstract XMLEventReader getChildEventReader();
|
||||
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 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 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 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 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());
|
||||
}
|
||||
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 StartElement getStartElement() {
|
||||
return startElement;
|
||||
}
|
||||
|
||||
protected final EndElement getEndElement() {
|
||||
return endElement;
|
||||
}
|
||||
protected final EndElement getEndElement() {
|
||||
return endElement;
|
||||
}
|
||||
|
||||
private enum EVENT_READER_STATE {
|
||||
private enum EVENT_READER_STATE {
|
||||
|
||||
START_DOCUMENT,
|
||||
START_ELEMENT,
|
||||
CHILDREN,
|
||||
END_ELEMENT,
|
||||
END_DOCUMENT,
|
||||
DONE
|
||||
}
|
||||
START_DOCUMENT,
|
||||
START_ELEMENT,
|
||||
CHILDREN,
|
||||
END_ELEMENT,
|
||||
END_DOCUMENT,
|
||||
DONE
|
||||
}
|
||||
|
||||
private class StroapElementEventReader extends AbstractXMLEventReader {
|
||||
private class StroapElementEventReader extends AbstractXMLEventReader {
|
||||
|
||||
private EVENT_READER_STATE state;
|
||||
private EVENT_READER_STATE state;
|
||||
|
||||
private boolean documentEvents;
|
||||
private boolean documentEvents;
|
||||
|
||||
private final XMLEventReader childEventReader;
|
||||
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();
|
||||
}
|
||||
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 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 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();
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,91 +35,91 @@ import org.springframework.xml.stream.CompositeXMLEventReader;
|
||||
*/
|
||||
class StroapEnvelope extends StroapElement implements SoapEnvelope {
|
||||
|
||||
private static final String LOCAL_NAME = "Envelope";
|
||||
private static final String LOCAL_NAME = "Envelope";
|
||||
|
||||
private StroapHeader header;
|
||||
private StroapHeader header;
|
||||
|
||||
private StroapBody body;
|
||||
private StroapBody body;
|
||||
|
||||
StroapEnvelope(StroapMessageFactory messageFactory) {
|
||||
super(messageFactory.getSoapVersion().getEnvelopeName(), messageFactory);
|
||||
this.header = null;
|
||||
this.body = new Stroap11Body(messageFactory);
|
||||
}
|
||||
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;
|
||||
}
|
||||
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");
|
||||
}
|
||||
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);
|
||||
}
|
||||
return new StroapEnvelope(startElement, header, body, messageFactory);
|
||||
}
|
||||
|
||||
public SoapHeader getHeader() throws SoapHeaderException {
|
||||
if (header == null) {
|
||||
header = new Stroap11Header(getMessageFactory());
|
||||
}
|
||||
return header;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected XMLEventReader getChildEventReader() {
|
||||
if (header != null) {
|
||||
return new CompositeXMLEventReader(header.getEventReader(false), body.getEventReader(false));
|
||||
}
|
||||
else {
|
||||
return body.getEventReader(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.springframework.ws.soap.SoapFault;
|
||||
*/
|
||||
abstract class StroapFault extends StroapElement implements SoapFault {
|
||||
|
||||
protected StroapFault(StroapMessageFactory messageFactory) {
|
||||
super(messageFactory.getSoapVersion().getFaultName(), messageFactory);
|
||||
}
|
||||
protected StroapFault(StroapMessageFactory messageFactory) {
|
||||
super(messageFactory.getSoapVersion().getFaultName(), messageFactory);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -41,125 +41,125 @@ import org.springframework.xml.stream.CompositeXMLEventReader;
|
||||
*/
|
||||
abstract class StroapHeader extends StroapElement implements SoapHeader {
|
||||
|
||||
private List<StroapHeaderElement> headerElements = new LinkedList<StroapHeaderElement>();
|
||||
private List<StroapHeaderElement> headerElements = new LinkedList<StroapHeaderElement>();
|
||||
|
||||
protected StroapHeader(StroapMessageFactory messageFactory) {
|
||||
super(messageFactory.getSoapVersion().getHeaderName(), messageFactory);
|
||||
}
|
||||
protected StroapHeader(StroapMessageFactory messageFactory) {
|
||||
super(messageFactory.getSoapVersion().getHeaderName(), messageFactory);
|
||||
}
|
||||
|
||||
protected StroapHeader(StartElement startElement, StroapMessageFactory messageFactory) {
|
||||
super(startElement, 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());
|
||||
}
|
||||
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;
|
||||
}
|
||||
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 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> 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> 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 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");
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
@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());
|
||||
}
|
||||
public Result getResult() {
|
||||
headerElements.clear();
|
||||
return StaxUtils.createCustomStaxResult(new StroapHeaderXMLEventWriter());
|
||||
}
|
||||
|
||||
class StroapHeaderXMLEventWriter extends AbstractXMLEventWriter {
|
||||
class StroapHeaderXMLEventWriter extends AbstractXMLEventWriter {
|
||||
|
||||
private int elementDepth = 0;
|
||||
private int elementDepth = 0;
|
||||
|
||||
boolean startElementSeen = false;
|
||||
boolean startElementSeen = false;
|
||||
|
||||
private final List<XMLEvent> events = new LinkedList<XMLEvent>();
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,77 +36,77 @@ import org.springframework.xml.stream.ListBasedXMLEventReader;
|
||||
*/
|
||||
class StroapHeaderElement extends StroapElement implements SoapHeaderElement {
|
||||
|
||||
private final List<XMLEvent> events = new LinkedList<XMLEvent>();
|
||||
private final List<XMLEvent> events = new LinkedList<XMLEvent>();
|
||||
|
||||
StroapHeaderElement(QName name, StroapMessageFactory messageFactory) {
|
||||
super(name, messageFactory);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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 String getActorOrRole() throws SoapHeaderException {
|
||||
return getAttributeValue(getSoapVersion().getActorOrRoleName());
|
||||
}
|
||||
|
||||
public final void setActorOrRole(String actorOrRole) throws SoapHeaderException {
|
||||
addAttribute(getSoapVersion().getActorOrRoleName(), actorOrRole);
|
||||
}
|
||||
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 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 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 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 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));
|
||||
}
|
||||
public void setText(String content) {
|
||||
events.clear();
|
||||
events.add(getEventFactory().createCharacters(content));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected XMLEventReader getChildEventReader() {
|
||||
return new ListBasedXMLEventReader(events);
|
||||
}
|
||||
@Override
|
||||
protected XMLEventReader getChildEventReader() {
|
||||
return new ListBasedXMLEventReader(events);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -24,15 +24,15 @@ import org.springframework.ws.soap.SoapHeaderException;
|
||||
*/
|
||||
public class StroapHeaderException extends SoapHeaderException {
|
||||
|
||||
public StroapHeaderException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
public StroapHeaderException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public StroapHeaderException(String msg, Throwable ex) {
|
||||
super(msg, ex);
|
||||
}
|
||||
public StroapHeaderException(String msg, Throwable ex) {
|
||||
super(msg, ex);
|
||||
}
|
||||
|
||||
public StroapHeaderException(Throwable ex) {
|
||||
super(ex);
|
||||
}
|
||||
public StroapHeaderException(Throwable ex) {
|
||||
super(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,230 +68,230 @@ import org.xml.sax.SAXException;
|
||||
*/
|
||||
public class StroapMessage extends AbstractSoapMessage implements StreamingWebServiceMessage {
|
||||
|
||||
private final MultiValueMap<String, String> mimeHeaders = new LinkedMultiValueMap<String, String>();
|
||||
private final MultiValueMap<String, String> mimeHeaders = new LinkedMultiValueMap<String, String>();
|
||||
|
||||
private StroapEnvelope envelope;
|
||||
private StroapEnvelope envelope;
|
||||
|
||||
private final StroapMessageFactory messageFactory;
|
||||
private final StroapMessageFactory messageFactory;
|
||||
|
||||
private final StartDocument startDocument;
|
||||
private final StartDocument startDocument;
|
||||
|
||||
private final EndDocument endDocument;
|
||||
private final EndDocument endDocument;
|
||||
|
||||
public StroapMessage(StroapMessageFactory messageFactory) {
|
||||
this(null, null, messageFactory);
|
||||
}
|
||||
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();
|
||||
}
|
||||
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);
|
||||
}
|
||||
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;
|
||||
}
|
||||
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 SoapEnvelope getEnvelope() throws SoapEnvelopeException {
|
||||
return envelope;
|
||||
}
|
||||
|
||||
public void setStreamingPayload(StreamingPayload payload) {
|
||||
StroapBody soapBody = (StroapBody) getSoapBody();
|
||||
soapBody.setStreamingPayload(payload);
|
||||
}
|
||||
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 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);
|
||||
}
|
||||
public void setSoapAction(String soapAction) {
|
||||
soapAction = SoapUtils.escapeAction(soapAction);
|
||||
mimeHeaders.set(TransportConstants.HEADER_SOAP_ACTION, soapAction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SoapVersion getVersion() {
|
||||
return messageFactory.getSoapVersion();
|
||||
}
|
||||
@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
|
||||
}
|
||||
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);
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
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);
|
||||
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);
|
||||
DOMImplementationLS loadSaveImplementation = (DOMImplementationLS) implementation;
|
||||
LSOutput output = loadSaveImplementation.createLSOutput();
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
output.setByteStream(bos);
|
||||
|
||||
LSSerializer serializer = loadSaveImplementation.createLSSerializer();
|
||||
serializer.write(document, output);
|
||||
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);
|
||||
}
|
||||
}
|
||||
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 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 isXopPackage() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean convertToXopPackage() {
|
||||
return false;
|
||||
}
|
||||
public boolean convertToXopPackage() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Attachment getAttachment(String contentId) throws AttachmentException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
public Attachment getAttachment(String contentId) throws AttachmentException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Iterator<Attachment> getAttachments() throws AttachmentException {
|
||||
return Collections.<Attachment>emptyList().iterator();
|
||||
}
|
||||
public Iterator<Attachment> getAttachments() throws AttachmentException {
|
||||
return Collections.<Attachment>emptyList().iterator();
|
||||
}
|
||||
|
||||
public Attachment addAttachment(String contentId, DataHandler dataHandler) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
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();
|
||||
}
|
||||
@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 static class NoStartEndDocumentWriter extends AbstractXMLEventWriter {
|
||||
|
||||
private final XMLEventWriter delegate;
|
||||
private final XMLEventWriter delegate;
|
||||
|
||||
private NoStartEndDocumentWriter(XMLEventWriter delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
private NoStartEndDocumentWriter(XMLEventWriter delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
public void add(XMLEvent event) throws XMLStreamException {
|
||||
if (!event.isStartDocument() && !event.isEndDocument()) {
|
||||
delegate.add(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void add(XMLEvent event) throws XMLStreamException {
|
||||
if (!event.isStartDocument() && !event.isEndDocument()) {
|
||||
delegate.add(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,11 +23,11 @@ import org.springframework.ws.soap.SoapMessageCreationException;
|
||||
*/
|
||||
public class StroapMessageCreationException extends SoapMessageCreationException {
|
||||
|
||||
public StroapMessageCreationException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
public StroapMessageCreationException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public StroapMessageCreationException(String msg, Throwable ex) {
|
||||
super(msg, ex);
|
||||
}
|
||||
public StroapMessageCreationException(String msg, Throwable ex) {
|
||||
super(msg, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,13 +23,13 @@ import org.springframework.ws.soap.SoapMessageException;
|
||||
*/
|
||||
public class StroapMessageException extends SoapMessageException {
|
||||
|
||||
public StroapMessageException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
public StroapMessageException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public StroapMessageException(String msg, Throwable ex) {
|
||||
super(msg, ex);
|
||||
}
|
||||
public StroapMessageException(String msg, Throwable ex) {
|
||||
super(msg, ex);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -32,137 +32,137 @@ import org.springframework.ws.soap.SoapVersion;
|
||||
*/
|
||||
public class StroapMessageFactory implements SoapMessageFactory {
|
||||
|
||||
private final XMLInputFactory inputFactory = createXmlInputFactory();
|
||||
private final XMLInputFactory inputFactory = createXmlInputFactory();
|
||||
|
||||
private final XMLOutputFactory outputFactory = createXmlOutputFactory();
|
||||
private final XMLOutputFactory outputFactory = createXmlOutputFactory();
|
||||
|
||||
private final XMLEventFactory eventFactory = createXmlEventFactory();
|
||||
private final XMLEventFactory eventFactory = createXmlEventFactory();
|
||||
|
||||
private final DocumentBuilderFactory documentBuilderFactory = createDocumentBuilderFactory();
|
||||
private final DocumentBuilderFactory documentBuilderFactory = createDocumentBuilderFactory();
|
||||
|
||||
private boolean payloadCaching = true;
|
||||
private boolean payloadCaching = true;
|
||||
|
||||
public boolean isPayloadCaching() {
|
||||
return payloadCaching;
|
||||
}
|
||||
public boolean isPayloadCaching() {
|
||||
return payloadCaching;
|
||||
}
|
||||
|
||||
public void setPayloadCaching(boolean payloadCaching) {
|
||||
this.payloadCaching = payloadCaching;
|
||||
}
|
||||
public void setPayloadCaching(boolean payloadCaching) {
|
||||
this.payloadCaching = payloadCaching;
|
||||
}
|
||||
|
||||
public SoapVersion getSoapVersion() {
|
||||
return SoapVersion.SOAP_11;
|
||||
}
|
||||
public SoapVersion getSoapVersion() {
|
||||
return SoapVersion.SOAP_11;
|
||||
}
|
||||
|
||||
public void setSoapVersion(SoapVersion version) {
|
||||
if (version != SoapVersion.SOAP_11) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
public void setSoapVersion(SoapVersion version) {
|
||||
if (version != SoapVersion.SOAP_11) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
public StroapMessage createWebServiceMessage() {
|
||||
return new StroapMessage(this);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
XMLInputFactory getInputFactory() {
|
||||
return inputFactory;
|
||||
}
|
||||
|
||||
XMLOutputFactory getOutputFactory() {
|
||||
return outputFactory;
|
||||
}
|
||||
XMLOutputFactory getOutputFactory() {
|
||||
return outputFactory;
|
||||
}
|
||||
|
||||
XMLEventFactory getEventFactory() {
|
||||
return eventFactory;
|
||||
}
|
||||
XMLEventFactory getEventFactory() {
|
||||
return eventFactory;
|
||||
}
|
||||
|
||||
DocumentBuilderFactory getDocumentBuilderFactory() {
|
||||
return documentBuilderFactory;
|
||||
}
|
||||
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 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 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 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;
|
||||
}
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -26,12 +26,12 @@ import javax.xml.stream.XMLStreamException;
|
||||
*/
|
||||
abstract class StroapPayload {
|
||||
|
||||
public abstract QName getName();
|
||||
public abstract QName getName();
|
||||
|
||||
public abstract XMLEventReader getEventReader();
|
||||
public abstract XMLEventReader getEventReader();
|
||||
|
||||
public void writeTo(XMLEventWriter eventWriter) throws XMLStreamException {
|
||||
eventWriter.add(getEventReader());
|
||||
}
|
||||
public void writeTo(XMLEventWriter eventWriter) throws XMLStreamException {
|
||||
eventWriter.add(getEventReader());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,123 +30,123 @@ import org.springframework.ws.transport.support.AbstractAsyncStandaloneMessageRe
|
||||
/** @author Arjen Poutsma */
|
||||
public class TcpMessageReceiver extends AbstractAsyncStandaloneMessageReceiver {
|
||||
|
||||
public static final int DEFAULT_PORT = 8081;
|
||||
public static final int DEFAULT_PORT = 8081;
|
||||
|
||||
private ServerSocket serverSocket;
|
||||
private ServerSocket serverSocket;
|
||||
|
||||
private InetAddress bindAddress;
|
||||
private InetAddress bindAddress;
|
||||
|
||||
private int backlog = -1;
|
||||
private int backlog = -1;
|
||||
|
||||
private int port = DEFAULT_PORT;
|
||||
private int port = DEFAULT_PORT;
|
||||
|
||||
/** Sets the port the server will bind to. */
|
||||
public void setPort(int port) {
|
||||
this.port = 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 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);
|
||||
}
|
||||
/**
|
||||
* 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 onActivate() throws IOException {
|
||||
openServerSocket();
|
||||
}
|
||||
|
||||
protected void onStart() {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Starting tcp receiver [" + serverSocket.getLocalSocketAddress() + "]");
|
||||
}
|
||||
execute(new SocketAcceptingRunnable());
|
||||
}
|
||||
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 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();
|
||||
}
|
||||
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);
|
||||
}
|
||||
/** 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);
|
||||
}
|
||||
}
|
||||
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 {
|
||||
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 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;
|
||||
}
|
||||
}
|
||||
public boolean isLongLived() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private class TcpRequestHandler implements SchedulingAwareRunnable {
|
||||
private class TcpRequestHandler implements SchedulingAwareRunnable {
|
||||
|
||||
private final Socket socket;
|
||||
private final Socket socket;
|
||||
|
||||
public TcpRequestHandler(Socket socket) {
|
||||
this.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 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;
|
||||
}
|
||||
}
|
||||
public boolean isLongLived() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,27 +30,27 @@ import org.springframework.ws.transport.WebServiceMessageSender;
|
||||
/** @author Arjen Poutsma */
|
||||
public class TcpMessageSender implements WebServiceMessageSender {
|
||||
|
||||
public static final int DEFAULT_PORT = 8081;
|
||||
public static final int DEFAULT_PORT = 8081;
|
||||
|
||||
private int timeOut = 1000;
|
||||
private int timeOut = 1000;
|
||||
|
||||
/** Sets the amount of milliseconds before the tcp connection will timeout. */
|
||||
public void setTimeOut(int timeOut) {
|
||||
this.timeOut = timeOut;
|
||||
}
|
||||
/** 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 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);
|
||||
}
|
||||
public boolean supports(URI uri) {
|
||||
return uri.getScheme().equals(TcpTransportConstants.TCP_URI_SCHEME);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,63 +34,63 @@ import org.springframework.ws.transport.tcp.support.TcpTransportUtils;
|
||||
/** @author Arjen Poutsma */
|
||||
public class TcpReceiverConnection extends AbstractReceiverConnection {
|
||||
|
||||
private final Socket socket;
|
||||
private final Socket socket;
|
||||
|
||||
protected TcpReceiverConnection(Socket socket) {
|
||||
Assert.notNull(socket, "socket must not be null");
|
||||
this.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 URI getUri() throws URISyntaxException {
|
||||
return TcpTransportUtils.toUri(socket);
|
||||
}
|
||||
|
||||
public boolean hasError() throws IOException {
|
||||
return false;
|
||||
}
|
||||
public boolean hasError() throws IOException {
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getErrorMessage() throws IOException {
|
||||
return null;
|
||||
}
|
||||
public String getErrorMessage() throws IOException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void onClose() throws IOException {
|
||||
socket.close();
|
||||
}
|
||||
public void onClose() throws IOException {
|
||||
socket.close();
|
||||
}
|
||||
|
||||
protected Iterator getRequestHeaderNames() throws IOException {
|
||||
return Collections.EMPTY_LIST.iterator();
|
||||
}
|
||||
protected Iterator getRequestHeaderNames() throws IOException {
|
||||
return Collections.EMPTY_LIST.iterator();
|
||||
}
|
||||
|
||||
protected Iterator getRequestHeaders(String name) 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()) {
|
||||
protected InputStream getRequestInputStream() throws IOException {
|
||||
return new FilterInputStream(socket.getInputStream()) {
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
// don't close the socket
|
||||
socket.shutdownInput();
|
||||
}
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
// don't close the socket
|
||||
socket.shutdownInput();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected void addResponseHeader(String name, String value) throws IOException {
|
||||
}
|
||||
protected void addResponseHeader(String name, String value) throws IOException {
|
||||
}
|
||||
|
||||
protected OutputStream getResponseOutputStream() throws IOException {
|
||||
return new FilterOutputStream(socket.getOutputStream()) {
|
||||
protected OutputStream getResponseOutputStream() throws IOException {
|
||||
return new FilterOutputStream(socket.getOutputStream()) {
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
// don't close the socket
|
||||
socket.shutdownOutput();
|
||||
}
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
// don't close the socket
|
||||
socket.shutdownOutput();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected void sendResponse(boolean sentFault) throws IOException {
|
||||
}
|
||||
protected void sendResponse(boolean sentFault) throws IOException {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,76 +39,76 @@ import org.springframework.ws.transport.tcp.support.TcpTransportUtils;
|
||||
*/
|
||||
public class TcpSenderConnection extends AbstractSenderConnection {
|
||||
|
||||
private final Socket socket;
|
||||
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;
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
/** Returns the socket for this connection. */
|
||||
public Socket getSocket() {
|
||||
return socket;
|
||||
}
|
||||
|
||||
public URI getUri() throws URISyntaxException {
|
||||
return TcpTransportUtils.toUri(socket);
|
||||
}
|
||||
public URI getUri() throws URISyntaxException {
|
||||
return TcpTransportUtils.toUri(socket);
|
||||
}
|
||||
|
||||
public void onClose() throws IOException {
|
||||
socket.close();
|
||||
}
|
||||
public void onClose() throws IOException {
|
||||
socket.close();
|
||||
}
|
||||
|
||||
/*
|
||||
* Errors
|
||||
*/
|
||||
/*
|
||||
* Errors
|
||||
*/
|
||||
|
||||
public boolean hasError() throws IOException {
|
||||
return false;
|
||||
}
|
||||
public boolean hasError() throws IOException {
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getErrorMessage() throws IOException {
|
||||
return null;
|
||||
}
|
||||
public String getErrorMessage() throws IOException {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void addRequestHeader(String name, String value) throws IOException {
|
||||
}
|
||||
protected void addRequestHeader(String name, String value) throws IOException {
|
||||
}
|
||||
|
||||
protected OutputStream getRequestOutputStream() throws IOException {
|
||||
return new FilterOutputStream(socket.getOutputStream()) {
|
||||
protected OutputStream getRequestOutputStream() throws IOException {
|
||||
return new FilterOutputStream(socket.getOutputStream()) {
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
// don't close the socket
|
||||
socket.shutdownOutput();
|
||||
}
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
// don't close the socket
|
||||
socket.shutdownOutput();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected void sendRequest() throws IOException {
|
||||
}
|
||||
protected void sendRequest() throws IOException {
|
||||
}
|
||||
|
||||
protected boolean hasResponse() throws IOException {
|
||||
return true;
|
||||
}
|
||||
protected boolean hasResponse() throws IOException {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected Iterator getResponseHeaderNames() throws IOException {
|
||||
return Collections.EMPTY_LIST.iterator();
|
||||
}
|
||||
protected Iterator getResponseHeaderNames() throws IOException {
|
||||
return Collections.EMPTY_LIST.iterator();
|
||||
}
|
||||
|
||||
protected Iterator getResponseHeaders(String name) 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()) {
|
||||
protected InputStream getResponseInputStream() throws IOException {
|
||||
return new FilterInputStream(socket.getInputStream()) {
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
// don't close the socket
|
||||
socket.shutdownInput();
|
||||
}
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
// don't close the socket
|
||||
socket.shutdownInput();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ package org.springframework.ws.transport.tcp;
|
||||
*/
|
||||
public interface TcpTransportConstants {
|
||||
|
||||
/** The "tcp" URI scheme. */
|
||||
String TCP_URI_SCHEME = "tcp";
|
||||
/** The "tcp" URI scheme. */
|
||||
String TCP_URI_SCHEME = "tcp";
|
||||
|
||||
}
|
||||
|
||||
@@ -23,15 +23,15 @@ import org.springframework.ws.transport.TransportException;
|
||||
/** @author Arjen Poutsma */
|
||||
public class TcpTransportException extends TransportException {
|
||||
|
||||
public TcpTransportException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
public TcpTransportException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public TcpTransportException(String msg, IOException ex) {
|
||||
super(msg + ": " + ex.getMessage());
|
||||
}
|
||||
public TcpTransportException(String msg, IOException ex) {
|
||||
super(msg + ": " + ex.getMessage());
|
||||
}
|
||||
|
||||
public TcpTransportException(IOException ex) {
|
||||
super(ex.getMessage());
|
||||
}
|
||||
public TcpTransportException(IOException ex) {
|
||||
super(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,16 +29,16 @@ import org.springframework.ws.transport.tcp.TcpTransportConstants;
|
||||
*/
|
||||
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);
|
||||
/**
|
||||
* 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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,108 +32,108 @@ import org.springframework.util.ClassUtils;
|
||||
*/
|
||||
public abstract class AbstractXMLEventReader implements XMLEventReader {
|
||||
|
||||
private boolean closed;
|
||||
private boolean closed;
|
||||
|
||||
public Object next() {
|
||||
try {
|
||||
return nextEvent();
|
||||
}
|
||||
catch (XMLStreamException ex) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
}
|
||||
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()));
|
||||
}
|
||||
/**
|
||||
* 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");
|
||||
}
|
||||
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();
|
||||
}
|
||||
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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
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 + "]");
|
||||
}
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
/**
|
||||
* 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");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
public void close() {
|
||||
closed = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,66 +31,66 @@ import org.springframework.xml.namespace.SimpleNamespaceContext;
|
||||
*/
|
||||
public abstract class AbstractXMLEventWriter implements XMLEventWriter {
|
||||
|
||||
private boolean closed;
|
||||
private boolean closed;
|
||||
|
||||
private SimpleNamespaceContext namespaceContext = new SimpleNamespaceContext();
|
||||
private SimpleNamespaceContext namespaceContext = new SimpleNamespaceContext();
|
||||
|
||||
public void flush() throws XMLStreamException {
|
||||
}
|
||||
public void flush() throws XMLStreamException {
|
||||
}
|
||||
|
||||
public void add(XMLEventReader eventReader) throws XMLStreamException {
|
||||
checkIfClosed();
|
||||
while (eventReader.hasNext()) {
|
||||
XMLEvent event = eventReader.nextEvent();
|
||||
add(event);
|
||||
}
|
||||
}
|
||||
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 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 setPrefix(String prefix, String uri) throws XMLStreamException {
|
||||
namespaceContext.bindNamespaceUri(prefix, uri);
|
||||
}
|
||||
|
||||
public void setDefaultNamespace(String uri) throws XMLStreamException {
|
||||
namespaceContext.bindDefaultNamespaceUri(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 void setNamespaceContext(NamespaceContext namespaceContext) throws XMLStreamException {
|
||||
Assert.notNull(namespaceContext, "'namespaceContext' must not be null");
|
||||
this.namespaceContext = (SimpleNamespaceContext) namespaceContext;
|
||||
}
|
||||
|
||||
public NamespaceContext getNamespaceContext() {
|
||||
return namespaceContext;
|
||||
}
|
||||
public NamespaceContext getNamespaceContext() {
|
||||
return namespaceContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if closed; <code>false</code> otherwise.
|
||||
*
|
||||
* @see #close()
|
||||
*/
|
||||
protected boolean isClosed() {
|
||||
return closed;
|
||||
}
|
||||
/**
|
||||
* 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");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
public void close() {
|
||||
closed = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,72 +30,72 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class CompositeXMLEventReader extends AbstractXMLEventReader {
|
||||
|
||||
private final XMLEventReader[] eventReaders;
|
||||
private final XMLEventReader[] eventReaders;
|
||||
|
||||
private int cursor = 0;
|
||||
private int cursor = 0;
|
||||
|
||||
public CompositeXMLEventReader(XMLEventReader eventReader) {
|
||||
Assert.notNull(eventReader, "'eventReader' must not be null");
|
||||
this.eventReaders = new XMLEventReader[]{eventReader};
|
||||
}
|
||||
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(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 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 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 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;
|
||||
}
|
||||
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 XMLEventReader currentEventReader() {
|
||||
return eventReaders[cursor];
|
||||
}
|
||||
|
||||
private boolean atLastEventReader() {
|
||||
return cursor == eventReaders.length - 1;
|
||||
}
|
||||
private boolean atLastEventReader() {
|
||||
return cursor == eventReaders.length - 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,53 +27,53 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class ListBasedXMLEventReader extends AbstractXMLEventReader {
|
||||
|
||||
private final XMLEvent[] events;
|
||||
private final XMLEvent[] events;
|
||||
|
||||
private int cursor = 0;
|
||||
private int cursor = 0;
|
||||
|
||||
public ListBasedXMLEventReader() {
|
||||
this.events = new XMLEvent[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 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(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 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 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 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;
|
||||
}
|
||||
}
|
||||
public XMLEvent peek() {
|
||||
if (cursor < events.length) {
|
||||
return events[cursor];
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,75 +33,75 @@ import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;
|
||||
|
||||
public class JaxWsProviderEndpointAdapterTest extends TestCase {
|
||||
|
||||
private JaxWsProviderEndpointAdapter adapter;
|
||||
private JaxWsProviderEndpointAdapter adapter;
|
||||
|
||||
private MessageContext messageContext;
|
||||
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));
|
||||
}
|
||||
@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 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 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 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());
|
||||
}
|
||||
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> {
|
||||
@WebServiceProvider
|
||||
@ServiceMode(Service.Mode.MESSAGE)
|
||||
private static class MyMessageProvider implements Provider<SOAPMessage> {
|
||||
|
||||
public SOAPMessage invoke(SOAPMessage request) {
|
||||
return request;
|
||||
}
|
||||
}
|
||||
public SOAPMessage invoke(SOAPMessage request) {
|
||||
return request;
|
||||
}
|
||||
}
|
||||
|
||||
@WebServiceProvider
|
||||
@ServiceMode(value = Service.Mode.PAYLOAD)
|
||||
private static class MySourceProvider implements Provider<Source> {
|
||||
@WebServiceProvider
|
||||
@ServiceMode(value = Service.Mode.PAYLOAD)
|
||||
private static class MySourceProvider implements Provider<Source> {
|
||||
|
||||
public Source invoke(Source request) {
|
||||
return request;
|
||||
}
|
||||
}
|
||||
public Source invoke(Source request) {
|
||||
return request;
|
||||
}
|
||||
}
|
||||
|
||||
@WebServiceProvider
|
||||
private static class MyDefaultProvider implements Provider<Source> {
|
||||
@WebServiceProvider
|
||||
private static class MyDefaultProvider implements Provider<Source> {
|
||||
|
||||
public Source invoke(Source request) {
|
||||
return request;
|
||||
}
|
||||
}
|
||||
public Source invoke(Source request) {
|
||||
return request;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -21,17 +21,17 @@ 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
|
||||
protected SoapBody createSoapBody() throws Exception {
|
||||
StroapMessageFactory messageFactory = new StroapMessageFactory();
|
||||
return new Stroap11Body(messageFactory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testAddFaultWithDetail() throws Exception {
|
||||
}
|
||||
@Override
|
||||
public void testAddFaultWithDetail() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testAddFaultWithDetailResult() throws Exception {
|
||||
}
|
||||
@Override
|
||||
public void testAddFaultWithDetailResult() throws Exception {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,11 +21,11 @@ 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;
|
||||
}
|
||||
@Override
|
||||
protected SoapEnvelope createSoapEnvelope() throws Exception {
|
||||
StroapMessageFactory messageFactory = new StroapMessageFactory();
|
||||
StroapEnvelope envelope = new StroapEnvelope(messageFactory);
|
||||
envelope.getHeader();
|
||||
return envelope;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ 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);
|
||||
}
|
||||
@Override
|
||||
protected SoapHeader createSoapHeader() throws Exception {
|
||||
StroapMessageFactory messageFactory = new StroapMessageFactory();
|
||||
return new Stroap11Header(messageFactory);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,20 +21,20 @@ import org.springframework.ws.soap.soap11.AbstractSoap11MessageFactoryTestCase;
|
||||
|
||||
public class Stroap11MessageFactoryTest extends AbstractSoap11MessageFactoryTestCase {
|
||||
|
||||
@Override
|
||||
protected WebServiceMessageFactory createMessageFactory() throws Exception {
|
||||
return new StroapMessageFactory();
|
||||
}
|
||||
@Override
|
||||
protected WebServiceMessageFactory createMessageFactory() throws Exception {
|
||||
return new StroapMessageFactory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testCreateSoapMessageMtom() throws Exception {
|
||||
}
|
||||
@Override
|
||||
public void testCreateSoapMessageMtom() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testCreateSoapMessageSwA() throws Exception {
|
||||
}
|
||||
@Override
|
||||
public void testCreateSoapMessageSwA() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testCreateSoapMessageMtomWeirdStartInfo() throws Exception {
|
||||
}
|
||||
@Override
|
||||
public void testCreateSoapMessageMtomWeirdStartInfo() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -21,26 +21,26 @@ 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
|
||||
protected final SoapMessage createSoapMessage() throws Exception {
|
||||
StroapMessageFactory messageFactory = new StroapMessageFactory();
|
||||
return new StroapMessage(messageFactory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testWriteToTransportResponseAttachment() throws Exception {
|
||||
}
|
||||
@Override
|
||||
public void testWriteToTransportResponseAttachment() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testAddAttachment() throws Exception {
|
||||
}
|
||||
@Override
|
||||
public void testAddAttachment() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testGetAttachment() throws Exception {
|
||||
}
|
||||
@Override
|
||||
public void testGetAttachment() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testGetAttachments() throws Exception {
|
||||
}
|
||||
@Override
|
||||
public void testGetAttachments() throws Exception {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,10 +24,10 @@ 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();
|
||||
}
|
||||
public static void main(String[] args) throws IOException {
|
||||
new ClassPathXmlApplicationContext("applicationContext.xml", Driver.class);
|
||||
System.out.println("Started....");
|
||||
System.in.read();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,21 +27,21 @@ import org.junit.Ignore;
|
||||
@Ignore
|
||||
public class TcpIntegrationTest extends AbstractDependencyInjectionSpringContextTests {
|
||||
|
||||
private WebServiceTemplate webServiceTemplate;
|
||||
private WebServiceTemplate webServiceTemplate;
|
||||
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[]{"classpath:org/springframework/ws/transport/tcp/tcp-applicationContext.xml"};
|
||||
}
|
||||
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 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();
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -36,55 +36,55 @@ import org.junit.Ignore;
|
||||
@Ignore
|
||||
public class TcpMessageReceiverIntegrationTest extends AbstractDependencyInjectionSpringContextTests {
|
||||
|
||||
private WebServiceMessageFactory messageFactory;
|
||||
private WebServiceMessageFactory messageFactory;
|
||||
|
||||
private WebServiceMessageSender messageSender;
|
||||
private WebServiceMessageSender messageSender;
|
||||
|
||||
public void setMessageFactory(WebServiceMessageFactory messageFactory) {
|
||||
this.messageFactory = messageFactory;
|
||||
}
|
||||
public void setMessageFactory(WebServiceMessageFactory messageFactory) {
|
||||
this.messageFactory = messageFactory;
|
||||
}
|
||||
|
||||
public void setMessageSender(WebServiceMessageSender messageSender) {
|
||||
this.messageSender = messageSender;
|
||||
}
|
||||
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 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 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));
|
||||
}
|
||||
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"};
|
||||
}
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[]{"classpath:/org/springframework/ws/transport/tcp/applicationContext.xml"};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -36,60 +36,60 @@ import static org.junit.Assert.*;
|
||||
*/
|
||||
public class CompositeXMLEventReaderTest {
|
||||
|
||||
private CompositeXMLEventReader chain;
|
||||
private CompositeXMLEventReader chain;
|
||||
|
||||
private XMLInputFactory inputFactory;
|
||||
private XMLInputFactory inputFactory;
|
||||
|
||||
private List<XMLEvent> expectedEvents = new ArrayList<XMLEvent>();
|
||||
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);
|
||||
}
|
||||
@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);
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
@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());
|
||||
}
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,13 +28,13 @@ import javax.xml.namespace.QName;
|
||||
*/
|
||||
public interface FaultAwareWebServiceMessage extends WebServiceMessage {
|
||||
|
||||
/**
|
||||
* Does this message have a fault?
|
||||
*
|
||||
* @return {@code true} if the message has a fault.
|
||||
* @see #getFaultReason()
|
||||
*/
|
||||
boolean hasFault();
|
||||
/**
|
||||
* Does this message have a fault?
|
||||
*
|
||||
* @return {@code true} if the message has a fault.
|
||||
* @see #getFaultReason()
|
||||
*/
|
||||
boolean hasFault();
|
||||
|
||||
/**
|
||||
* Returns the fault code, if any.
|
||||
@@ -42,11 +42,11 @@ public interface FaultAwareWebServiceMessage extends WebServiceMessage {
|
||||
QName getFaultCode();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the fault reason message.
|
||||
*
|
||||
* @return the fault reason message, if any; returns {@code null} when no fault is present.
|
||||
* @see #hasFault()
|
||||
*/
|
||||
String getFaultReason();
|
||||
/**
|
||||
* Returns the fault reason message.
|
||||
*
|
||||
* @return the fault reason message, if any; returns {@code null} when no fault is present.
|
||||
* @see #hasFault()
|
||||
*/
|
||||
String getFaultReason();
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ package org.springframework.ws;
|
||||
@SuppressWarnings("serial")
|
||||
public final class InvalidXmlException extends WebServiceException {
|
||||
|
||||
public InvalidXmlException(String msg, Throwable ex) {
|
||||
super(msg, ex);
|
||||
}
|
||||
public InvalidXmlException(String msg, Throwable ex) {
|
||||
super(msg, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ package org.springframework.ws;
|
||||
@SuppressWarnings("serial")
|
||||
public final class NoEndpointFoundException extends WebServiceException {
|
||||
|
||||
public NoEndpointFoundException(WebServiceMessage request) {
|
||||
super("No endpoint can be found for request [" + request + "]");
|
||||
}
|
||||
public NoEndpointFoundException(WebServiceMessage request) {
|
||||
super("No endpoint can be found for request [" + request + "]");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,23 +27,23 @@ import org.springframework.core.NestedRuntimeException;
|
||||
@SuppressWarnings("serial")
|
||||
public abstract class WebServiceException extends NestedRuntimeException {
|
||||
|
||||
/**
|
||||
* Create a new instance of the {@code WebServiceException} class.
|
||||
*
|
||||
* @param msg the detail message
|
||||
*/
|
||||
public WebServiceException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
/**
|
||||
* Create a new instance of the {@code WebServiceException} class.
|
||||
*
|
||||
* @param msg the detail message
|
||||
*/
|
||||
public WebServiceException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance of the {@code WebServiceException} class.
|
||||
*
|
||||
* @param msg the detail message
|
||||
* @param ex the root {@link Throwable exception}
|
||||
*/
|
||||
public WebServiceException(String msg, Throwable ex) {
|
||||
super(msg, ex);
|
||||
}
|
||||
/**
|
||||
* Create a new instance of the {@code WebServiceException} class.
|
||||
*
|
||||
* @param msg the detail message
|
||||
* @param ex the root {@link Throwable exception}
|
||||
*/
|
||||
public WebServiceException(String msg, Throwable ex) {
|
||||
super(msg, ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,35 +33,35 @@ import javax.xml.transform.Source;
|
||||
*/
|
||||
public interface WebServiceMessage {
|
||||
|
||||
/**
|
||||
* Returns the contents of the message as a {@link Source}.
|
||||
*
|
||||
* <p>Depending on the implementation, this can be retrieved multiple times, or just
|
||||
* a single time.
|
||||
*
|
||||
* @return the message contents
|
||||
*/
|
||||
Source getPayloadSource();
|
||||
/**
|
||||
* Returns the contents of the message as a {@link Source}.
|
||||
*
|
||||
* <p>Depending on the implementation, this can be retrieved multiple times, or just
|
||||
* a single time.
|
||||
*
|
||||
* @return the message contents
|
||||
*/
|
||||
Source getPayloadSource();
|
||||
|
||||
/**
|
||||
* Returns the contents of the message as a {@link Result}.
|
||||
*
|
||||
* <p>Calling this method removes the current payload.
|
||||
*
|
||||
* <p>Implementations that are read-only will throw an {@link UnsupportedOperationException}.
|
||||
*
|
||||
* @return the message contents
|
||||
* @throws UnsupportedOperationException if the message is read-only
|
||||
*/
|
||||
Result getPayloadResult();
|
||||
/**
|
||||
* Returns the contents of the message as a {@link Result}.
|
||||
*
|
||||
* <p>Calling this method removes the current payload.
|
||||
*
|
||||
* <p>Implementations that are read-only will throw an {@link UnsupportedOperationException}.
|
||||
*
|
||||
* @return the message contents
|
||||
* @throws UnsupportedOperationException if the message is read-only
|
||||
*/
|
||||
Result getPayloadResult();
|
||||
|
||||
/**
|
||||
* Writes the entire message to the given output stream. <p>If the given stream is an instance of {@link
|
||||
* org.springframework.ws.transport.TransportOutputStream}, the corresponding headers will be written as well.
|
||||
*
|
||||
* @param outputStream the stream to write to
|
||||
* @throws IOException if an I/O exception occurs
|
||||
*/
|
||||
void writeTo(OutputStream outputStream) throws IOException;
|
||||
/**
|
||||
* Writes the entire message to the given output stream. <p>If the given stream is an instance of {@link
|
||||
* org.springframework.ws.transport.TransportOutputStream}, the corresponding headers will be written as well.
|
||||
*
|
||||
* @param outputStream the stream to write to
|
||||
* @throws IOException if an I/O exception occurs
|
||||
*/
|
||||
void writeTo(OutputStream outputStream) throws IOException;
|
||||
|
||||
}
|
||||
|
||||
@@ -25,13 +25,13 @@ package org.springframework.ws;
|
||||
@SuppressWarnings("serial")
|
||||
public abstract class WebServiceMessageException extends WebServiceException {
|
||||
|
||||
/** Constructor for {@code WebServiceMessageException}. */
|
||||
public WebServiceMessageException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
/** Constructor for {@code WebServiceMessageException}. */
|
||||
public WebServiceMessageException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
/** Constructor for {@code WebServiceMessageException}. */
|
||||
public WebServiceMessageException(String msg, Throwable ex) {
|
||||
super(msg, ex);
|
||||
}
|
||||
/** Constructor for {@code WebServiceMessageException}. */
|
||||
public WebServiceMessageException(String msg, Throwable ex) {
|
||||
super(msg, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -31,24 +31,24 @@ import java.io.InputStream;
|
||||
*/
|
||||
public interface WebServiceMessageFactory {
|
||||
|
||||
/**
|
||||
* Creates a new, empty {@code WebServiceMessage}.
|
||||
*
|
||||
* @return the empty message
|
||||
*/
|
||||
WebServiceMessage createWebServiceMessage();
|
||||
/**
|
||||
* Creates a new, empty {@code WebServiceMessage}.
|
||||
*
|
||||
* @return the empty message
|
||||
*/
|
||||
WebServiceMessage createWebServiceMessage();
|
||||
|
||||
/**
|
||||
* Reads a {@link WebServiceMessage} from the given input stream.
|
||||
*
|
||||
* <p>If the given stream is an instance of {@link org.springframework.ws.transport.TransportInputStream
|
||||
* TransportInputStream}, the headers will be read from the request.
|
||||
*
|
||||
* @param inputStream the input stream to read the message from
|
||||
* @return the created message
|
||||
* @throws InvalidXmlException if the XML read from the input stream is invalid
|
||||
* @throws IOException if an I/O exception occurs
|
||||
*/
|
||||
WebServiceMessage createWebServiceMessage(InputStream inputStream) throws InvalidXmlException, IOException;
|
||||
/**
|
||||
* Reads a {@link WebServiceMessage} from the given input stream.
|
||||
*
|
||||
* <p>If the given stream is an instance of {@link org.springframework.ws.transport.TransportInputStream
|
||||
* TransportInputStream}, the headers will be read from the request.
|
||||
*
|
||||
* @param inputStream the input stream to read the message from
|
||||
* @return the created message
|
||||
* @throws InvalidXmlException if the XML read from the input stream is invalid
|
||||
* @throws IOException if an I/O exception occurs
|
||||
*/
|
||||
WebServiceMessage createWebServiceMessage(InputStream inputStream) throws InvalidXmlException, IOException;
|
||||
|
||||
}
|
||||
|
||||
@@ -27,23 +27,23 @@ import org.springframework.ws.WebServiceException;
|
||||
@SuppressWarnings("serial")
|
||||
public abstract class WebServiceClientException extends WebServiceException {
|
||||
|
||||
/**
|
||||
* Create a new instance of the {@code WebServiceClientException} class.
|
||||
*
|
||||
* @param msg the detail message
|
||||
*/
|
||||
public WebServiceClientException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
/**
|
||||
* Create a new instance of the {@code WebServiceClientException} class.
|
||||
*
|
||||
* @param msg the detail message
|
||||
*/
|
||||
public WebServiceClientException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance of the {@code WebServiceClientException} class.
|
||||
*
|
||||
* @param msg the detail message
|
||||
* @param ex the root {@link Throwable exception}
|
||||
*/
|
||||
public WebServiceClientException(String msg, Throwable ex) {
|
||||
super(msg, ex);
|
||||
}
|
||||
/**
|
||||
* Create a new instance of the {@code WebServiceClientException} class.
|
||||
*
|
||||
* @param msg the detail message
|
||||
* @param ex the root {@link Throwable exception}
|
||||
*/
|
||||
public WebServiceClientException(String msg, Throwable ex) {
|
||||
super(msg, ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,26 +27,26 @@ import org.springframework.ws.FaultAwareWebServiceMessage;
|
||||
@SuppressWarnings("serial")
|
||||
public class WebServiceFaultException extends WebServiceClientException {
|
||||
|
||||
private final FaultAwareWebServiceMessage faultMessage;
|
||||
private final FaultAwareWebServiceMessage faultMessage;
|
||||
|
||||
/** Create a new instance of the {@code WebServiceFaultException} class. */
|
||||
public WebServiceFaultException(String msg) {
|
||||
super(msg);
|
||||
faultMessage = null;
|
||||
}
|
||||
/** Create a new instance of the {@code WebServiceFaultException} class. */
|
||||
public WebServiceFaultException(String msg) {
|
||||
super(msg);
|
||||
faultMessage = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance of the {@code WebServiceFaultException} class.
|
||||
*
|
||||
* @param faultMessage the fault message
|
||||
*/
|
||||
public WebServiceFaultException(FaultAwareWebServiceMessage faultMessage) {
|
||||
super(faultMessage.getFaultReason());
|
||||
this.faultMessage = faultMessage;
|
||||
}
|
||||
/**
|
||||
* Create a new instance of the {@code WebServiceFaultException} class.
|
||||
*
|
||||
* @param faultMessage the fault message
|
||||
*/
|
||||
public WebServiceFaultException(FaultAwareWebServiceMessage faultMessage) {
|
||||
super(faultMessage.getFaultReason());
|
||||
this.faultMessage = faultMessage;
|
||||
}
|
||||
|
||||
/** Returns the fault message. */
|
||||
public FaultAwareWebServiceMessage getWebServiceMessage() {
|
||||
return faultMessage;
|
||||
}
|
||||
/** Returns the fault message. */
|
||||
public FaultAwareWebServiceMessage getWebServiceMessage() {
|
||||
return faultMessage;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,23 +27,23 @@ import java.io.IOException;
|
||||
@SuppressWarnings("serial")
|
||||
public class WebServiceIOException extends WebServiceClientException {
|
||||
|
||||
/**
|
||||
* Create a new instance of the {@code WebServiceIOException} class.
|
||||
*
|
||||
* @param msg the detail message
|
||||
*/
|
||||
public WebServiceIOException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
/**
|
||||
* Create a new instance of the {@code WebServiceIOException} class.
|
||||
*
|
||||
* @param msg the detail message
|
||||
*/
|
||||
public WebServiceIOException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance of the {@code WebServiceIOException} class.
|
||||
*
|
||||
* @param msg the detail message
|
||||
* @param ex the root {@link IOException}
|
||||
*/
|
||||
public WebServiceIOException(String msg, IOException ex) {
|
||||
super(msg, ex);
|
||||
}
|
||||
/**
|
||||
* Create a new instance of the {@code WebServiceIOException} class.
|
||||
*
|
||||
* @param msg the detail message
|
||||
* @param ex the root {@link IOException}
|
||||
*/
|
||||
public WebServiceIOException(String msg, IOException ex) {
|
||||
super(msg, ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,23 +27,23 @@ import javax.xml.transform.TransformerException;
|
||||
@SuppressWarnings("serial")
|
||||
public class WebServiceTransformerException extends WebServiceClientException {
|
||||
|
||||
/**
|
||||
* Create a new instance of the {@code WebServiceTransformerException} class.
|
||||
*
|
||||
* @param msg the detail message
|
||||
*/
|
||||
public WebServiceTransformerException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
/**
|
||||
* Create a new instance of the {@code WebServiceTransformerException} class.
|
||||
*
|
||||
* @param msg the detail message
|
||||
*/
|
||||
public WebServiceTransformerException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance of the {@code WebServiceTransformerException} class.
|
||||
*
|
||||
* @param msg the detail message
|
||||
* @param ex the root {@link Throwable exception}
|
||||
*/
|
||||
public WebServiceTransformerException(String msg, TransformerException ex) {
|
||||
super(msg, ex);
|
||||
}
|
||||
/**
|
||||
* Create a new instance of the {@code WebServiceTransformerException} class.
|
||||
*
|
||||
* @param msg the detail message
|
||||
* @param ex the root {@link Throwable exception}
|
||||
*/
|
||||
public WebServiceTransformerException(String msg, TransformerException ex) {
|
||||
super(msg, ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,23 +27,23 @@ import org.springframework.ws.transport.TransportException;
|
||||
@SuppressWarnings("serial")
|
||||
public class WebServiceTransportException extends WebServiceIOException {
|
||||
|
||||
/**
|
||||
* Create a new instance of the {@code WebServiceTransportException} class.
|
||||
*
|
||||
* @param msg the detail message
|
||||
*/
|
||||
public WebServiceTransportException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
/**
|
||||
* Create a new instance of the {@code WebServiceTransportException} class.
|
||||
*
|
||||
* @param msg the detail message
|
||||
*/
|
||||
public WebServiceTransportException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance of the {@code WebServiceTransportException} class.
|
||||
*
|
||||
* @param msg the detail message
|
||||
* @param ex the root {@link TransportException}
|
||||
*/
|
||||
public WebServiceTransportException(String msg, TransportException ex) {
|
||||
super(msg, ex);
|
||||
}
|
||||
/**
|
||||
* Create a new instance of the {@code WebServiceTransportException} class.
|
||||
*
|
||||
* @param msg the detail message
|
||||
* @param ex the root {@link TransportException}
|
||||
*/
|
||||
public WebServiceTransportException(String msg, TransportException ex) {
|
||||
super(msg, ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,11 +28,11 @@ import org.springframework.ws.WebServiceMessage;
|
||||
*/
|
||||
public interface FaultMessageResolver {
|
||||
|
||||
/**
|
||||
* Try to resolve the given fault message that got received.
|
||||
*
|
||||
* @param message the fault message
|
||||
*/
|
||||
void resolveFault(WebServiceMessage message) throws IOException;
|
||||
/**
|
||||
* Try to resolve the given fault message that got received.
|
||||
*
|
||||
* @param message the fault message
|
||||
*/
|
||||
void resolveFault(WebServiceMessage message) throws IOException;
|
||||
|
||||
}
|
||||
|
||||
@@ -29,14 +29,14 @@ import org.springframework.ws.client.WebServiceFaultException;
|
||||
*/
|
||||
public class SimpleFaultMessageResolver implements FaultMessageResolver {
|
||||
|
||||
/** Throws a new {@code WebServiceFaultException}. */
|
||||
@Override
|
||||
public void resolveFault(WebServiceMessage message) {
|
||||
if (message instanceof FaultAwareWebServiceMessage) {
|
||||
throw new WebServiceFaultException((FaultAwareWebServiceMessage) message);
|
||||
}
|
||||
else {
|
||||
throw new WebServiceFaultException("Message has unknown fault: " + message);
|
||||
}
|
||||
}
|
||||
/** Throws a new {@code WebServiceFaultException}. */
|
||||
@Override
|
||||
public void resolveFault(WebServiceMessage message) {
|
||||
if (message instanceof FaultAwareWebServiceMessage) {
|
||||
throw new WebServiceFaultException((FaultAwareWebServiceMessage) message);
|
||||
}
|
||||
else {
|
||||
throw new WebServiceFaultException("Message has unknown fault: " + message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,14 +37,14 @@ import javax.xml.transform.TransformerException;
|
||||
*/
|
||||
public interface SourceExtractor<T> {
|
||||
|
||||
/**
|
||||
* Process the data in the given {@code Source}, creating a corresponding result object.
|
||||
*
|
||||
* @param source the message payload to extract data from
|
||||
* @return an arbitrary result object, or {@code null} if none (the extractor will typically be stateful in the
|
||||
* latter case)
|
||||
* @throws IOException in case of I/O errors
|
||||
*/
|
||||
T extractData(Source source) throws IOException, TransformerException;
|
||||
/**
|
||||
* Process the data in the given {@code Source}, creating a corresponding result object.
|
||||
*
|
||||
* @param source the message payload to extract data from
|
||||
* @return an arbitrary result object, or {@code null} if none (the extractor will typically be stateful in the
|
||||
* latter case)
|
||||
* @throws IOException in case of I/O errors
|
||||
*/
|
||||
T extractData(Source source) throws IOException, TransformerException;
|
||||
|
||||
}
|
||||
|
||||
@@ -32,13 +32,13 @@ import org.springframework.ws.WebServiceMessage;
|
||||
*/
|
||||
public interface WebServiceMessageCallback {
|
||||
|
||||
/**
|
||||
* Execute any number of operations on the supplied {@code message}.
|
||||
*
|
||||
* @param message the message
|
||||
* @throws IOException in case of I/O errors
|
||||
* @throws TransformerException in case of transformation errors
|
||||
*/
|
||||
void doWithMessage(WebServiceMessage message) throws IOException, TransformerException;
|
||||
/**
|
||||
* Execute any number of operations on the supplied {@code message}.
|
||||
*
|
||||
* @param message the message
|
||||
* @throws IOException in case of I/O errors
|
||||
* @throws TransformerException in case of transformation errors
|
||||
*/
|
||||
void doWithMessage(WebServiceMessage message) throws IOException, TransformerException;
|
||||
|
||||
}
|
||||
|
||||
@@ -37,15 +37,15 @@ import org.springframework.ws.WebServiceMessage;
|
||||
*/
|
||||
public interface WebServiceMessageExtractor<T> {
|
||||
|
||||
/**
|
||||
* Process the data in the given {@code WebServiceMessage}, creating a corresponding result object.
|
||||
*
|
||||
* @param message the message to extract data from (possibly a {@code SoapMessage})
|
||||
* @return an arbitrary result object, or {@code null} if none (the extractor will typically be stateful in the
|
||||
* latter case)
|
||||
* @throws IOException in case of I/O errors
|
||||
* @throws TransformerException in case of transformation errors
|
||||
*/
|
||||
T extractData(WebServiceMessage message) throws IOException, TransformerException;
|
||||
/**
|
||||
* Process the data in the given {@code WebServiceMessage}, creating a corresponding result object.
|
||||
*
|
||||
* @param message the message to extract data from (possibly a {@code SoapMessage})
|
||||
* @return an arbitrary result object, or {@code null} if none (the extractor will typically be stateful in the
|
||||
* latter case)
|
||||
* @throws IOException in case of I/O errors
|
||||
* @throws TransformerException in case of transformation errors
|
||||
*/
|
||||
T extractData(WebServiceMessage message) throws IOException, TransformerException;
|
||||
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -32,262 +32,262 @@ import org.springframework.ws.client.WebServiceClientException;
|
||||
*/
|
||||
public interface WebServiceOperations {
|
||||
|
||||
/**
|
||||
* Sends a web service message that can be manipulated with the given callback, reading the result with a
|
||||
* {@code WebServiceMessageExtractor}.
|
||||
*
|
||||
* <p>This will only work with a default uri specified!
|
||||
*
|
||||
* @param requestCallback the requestCallback to be used for manipulating the request message
|
||||
* @param responseExtractor object that will extract results
|
||||
* @return an arbitrary result object, as returned by the {@code WebServiceMessageExtractor}
|
||||
* @throws WebServiceClientException if there is a problem sending or receiving the message
|
||||
*/
|
||||
<T> T sendAndReceive(WebServiceMessageCallback requestCallback, WebServiceMessageExtractor<T> responseExtractor)
|
||||
throws WebServiceClientException;
|
||||
/**
|
||||
* Sends a web service message that can be manipulated with the given callback, reading the result with a
|
||||
* {@code WebServiceMessageExtractor}.
|
||||
*
|
||||
* <p>This will only work with a default uri specified!
|
||||
*
|
||||
* @param requestCallback the requestCallback to be used for manipulating the request message
|
||||
* @param responseExtractor object that will extract results
|
||||
* @return an arbitrary result object, as returned by the {@code WebServiceMessageExtractor}
|
||||
* @throws WebServiceClientException if there is a problem sending or receiving the message
|
||||
*/
|
||||
<T> T sendAndReceive(WebServiceMessageCallback requestCallback, WebServiceMessageExtractor<T> responseExtractor)
|
||||
throws WebServiceClientException;
|
||||
|
||||
/**
|
||||
* Sends a web service message that can be manipulated with the given callback, reading the result with a
|
||||
* {@code WebServiceMessageExtractor}.
|
||||
*
|
||||
* @param uri the URI to send the message to
|
||||
* @param requestCallback the requestCallback to be used for manipulating the request message
|
||||
* @param responseExtractor object that will extract results
|
||||
* @return an arbitrary result object, as returned by the {@code WebServiceMessageExtractor}
|
||||
* @throws WebServiceClientException if there is a problem sending or receiving the message
|
||||
*/
|
||||
<T> T sendAndReceive(String uri,
|
||||
WebServiceMessageCallback requestCallback,
|
||||
WebServiceMessageExtractor<T> responseExtractor) throws WebServiceClientException;
|
||||
/**
|
||||
* Sends a web service message that can be manipulated with the given callback, reading the result with a
|
||||
* {@code WebServiceMessageExtractor}.
|
||||
*
|
||||
* @param uri the URI to send the message to
|
||||
* @param requestCallback the requestCallback to be used for manipulating the request message
|
||||
* @param responseExtractor object that will extract results
|
||||
* @return an arbitrary result object, as returned by the {@code WebServiceMessageExtractor}
|
||||
* @throws WebServiceClientException if there is a problem sending or receiving the message
|
||||
*/
|
||||
<T> T sendAndReceive(String uri,
|
||||
WebServiceMessageCallback requestCallback,
|
||||
WebServiceMessageExtractor<T> responseExtractor) throws WebServiceClientException;
|
||||
|
||||
/**
|
||||
* Sends a web service message that can be manipulated with the given request callback, handling the response with a
|
||||
* response callback.
|
||||
*
|
||||
* <p>This will only work with a default uri specified!
|
||||
*
|
||||
* @param requestCallback the callback to be used for manipulating the request message
|
||||
* @param responseCallback the callback to be used for manipulating the response message
|
||||
* @return {@code true} if a response was received; {@code false} otherwise
|
||||
* @throws WebServiceClientException if there is a problem sending or receiving the message
|
||||
*/
|
||||
boolean sendAndReceive(WebServiceMessageCallback requestCallback, WebServiceMessageCallback responseCallback)
|
||||
throws WebServiceClientException;
|
||||
/**
|
||||
* Sends a web service message that can be manipulated with the given request callback, handling the response with a
|
||||
* response callback.
|
||||
*
|
||||
* <p>This will only work with a default uri specified!
|
||||
*
|
||||
* @param requestCallback the callback to be used for manipulating the request message
|
||||
* @param responseCallback the callback to be used for manipulating the response message
|
||||
* @return {@code true} if a response was received; {@code false} otherwise
|
||||
* @throws WebServiceClientException if there is a problem sending or receiving the message
|
||||
*/
|
||||
boolean sendAndReceive(WebServiceMessageCallback requestCallback, WebServiceMessageCallback responseCallback)
|
||||
throws WebServiceClientException;
|
||||
|
||||
/**
|
||||
* Sends a web service message that can be manipulated with the given request callback, handling the response with a
|
||||
* response callback.
|
||||
*
|
||||
* @param uri the URI to send the message to
|
||||
* @param requestCallback the callback to be used for manipulating the request message
|
||||
* @param responseCallback the callback to be used for manipulating the response message
|
||||
* @return {@code true} if a response was received; {@code false} otherwise
|
||||
* @throws WebServiceClientException if there is a problem sending or receiving the message
|
||||
*/
|
||||
boolean sendAndReceive(String uri,
|
||||
WebServiceMessageCallback requestCallback,
|
||||
WebServiceMessageCallback responseCallback) throws WebServiceClientException;
|
||||
/**
|
||||
* Sends a web service message that can be manipulated with the given request callback, handling the response with a
|
||||
* response callback.
|
||||
*
|
||||
* @param uri the URI to send the message to
|
||||
* @param requestCallback the callback to be used for manipulating the request message
|
||||
* @param responseCallback the callback to be used for manipulating the response message
|
||||
* @return {@code true} if a response was received; {@code false} otherwise
|
||||
* @throws WebServiceClientException if there is a problem sending or receiving the message
|
||||
*/
|
||||
boolean sendAndReceive(String uri,
|
||||
WebServiceMessageCallback requestCallback,
|
||||
WebServiceMessageCallback responseCallback) throws WebServiceClientException;
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------------
|
||||
// Convenience methods for sending and receiving marshalled messages
|
||||
//-----------------------------------------------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------------------------------------------
|
||||
// Convenience methods for sending and receiving marshalled messages
|
||||
//-----------------------------------------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Sends a web service message that contains the given payload, marshalled by the configured
|
||||
* {@code Marshaller}. Returns the unmarshalled payload of the response message, if any.
|
||||
*
|
||||
* <p>This will only work with a default uri specified!
|
||||
*
|
||||
* @param requestPayload the object to marshal into the request message payload
|
||||
* @return the unmarshalled payload of the response message, or {@code null} if no response is given
|
||||
* @throws XmlMappingException if there is a problem marshalling or unmarshalling
|
||||
* @throws WebServiceClientException if there is a problem sending or receiving the message
|
||||
* @see WebServiceTemplate#setMarshaller(org.springframework.oxm.Marshaller)
|
||||
* @see WebServiceTemplate#setUnmarshaller(org.springframework.oxm.Unmarshaller)
|
||||
*/
|
||||
Object marshalSendAndReceive(Object requestPayload) throws XmlMappingException, WebServiceClientException;
|
||||
/**
|
||||
* Sends a web service message that contains the given payload, marshalled by the configured
|
||||
* {@code Marshaller}. Returns the unmarshalled payload of the response message, if any.
|
||||
*
|
||||
* <p>This will only work with a default uri specified!
|
||||
*
|
||||
* @param requestPayload the object to marshal into the request message payload
|
||||
* @return the unmarshalled payload of the response message, or {@code null} if no response is given
|
||||
* @throws XmlMappingException if there is a problem marshalling or unmarshalling
|
||||
* @throws WebServiceClientException if there is a problem sending or receiving the message
|
||||
* @see WebServiceTemplate#setMarshaller(org.springframework.oxm.Marshaller)
|
||||
* @see WebServiceTemplate#setUnmarshaller(org.springframework.oxm.Unmarshaller)
|
||||
*/
|
||||
Object marshalSendAndReceive(Object requestPayload) throws XmlMappingException, WebServiceClientException;
|
||||
|
||||
/**
|
||||
* Sends a web service message that contains the given payload, marshalled by the configured
|
||||
* {@code Marshaller}. Returns the unmarshalled payload of the response message, if any.
|
||||
*
|
||||
* @param uri the URI to send the message to
|
||||
* @param requestPayload the object to marshal into the request message payload
|
||||
* @return the unmarshalled payload of the response message, or {@code null} if no response is given
|
||||
* @throws XmlMappingException if there is a problem marshalling or unmarshalling
|
||||
* @throws WebServiceClientException if there is a problem sending or receiving the message
|
||||
* @see WebServiceTemplate#setMarshaller(org.springframework.oxm.Marshaller)
|
||||
* @see WebServiceTemplate#setUnmarshaller(org.springframework.oxm.Unmarshaller)
|
||||
*/
|
||||
Object marshalSendAndReceive(String uri, Object requestPayload)
|
||||
throws XmlMappingException, WebServiceClientException;
|
||||
/**
|
||||
* Sends a web service message that contains the given payload, marshalled by the configured
|
||||
* {@code Marshaller}. Returns the unmarshalled payload of the response message, if any.
|
||||
*
|
||||
* @param uri the URI to send the message to
|
||||
* @param requestPayload the object to marshal into the request message payload
|
||||
* @return the unmarshalled payload of the response message, or {@code null} if no response is given
|
||||
* @throws XmlMappingException if there is a problem marshalling or unmarshalling
|
||||
* @throws WebServiceClientException if there is a problem sending or receiving the message
|
||||
* @see WebServiceTemplate#setMarshaller(org.springframework.oxm.Marshaller)
|
||||
* @see WebServiceTemplate#setUnmarshaller(org.springframework.oxm.Unmarshaller)
|
||||
*/
|
||||
Object marshalSendAndReceive(String uri, Object requestPayload)
|
||||
throws XmlMappingException, WebServiceClientException;
|
||||
|
||||
/**
|
||||
* Sends a web service message that contains the given payload, marshalled by the configured
|
||||
* {@code Marshaller}. Returns the unmarshalled payload of the response message, if any. The given callback
|
||||
* allows changing of the request message after the payload has been marshalled to it.
|
||||
*
|
||||
* <p>This will only work with a default uri specified!
|
||||
*
|
||||
* @param requestPayload the object to marshal into the request message payload
|
||||
* @param requestCallback callback to change message, can be {@code null}
|
||||
* @return the unmarshalled payload of the response message, or {@code null} if no response is given
|
||||
* @throws XmlMappingException if there is a problem marshalling or unmarshalling
|
||||
* @throws WebServiceClientException if there is a problem sending or receiving the message
|
||||
* @see WebServiceTemplate#setMarshaller(org.springframework.oxm.Marshaller)
|
||||
* @see WebServiceTemplate#setUnmarshaller(org.springframework.oxm.Unmarshaller)
|
||||
*/
|
||||
Object marshalSendAndReceive(Object requestPayload, WebServiceMessageCallback requestCallback)
|
||||
throws XmlMappingException, WebServiceClientException;
|
||||
/**
|
||||
* Sends a web service message that contains the given payload, marshalled by the configured
|
||||
* {@code Marshaller}. Returns the unmarshalled payload of the response message, if any. The given callback
|
||||
* allows changing of the request message after the payload has been marshalled to it.
|
||||
*
|
||||
* <p>This will only work with a default uri specified!
|
||||
*
|
||||
* @param requestPayload the object to marshal into the request message payload
|
||||
* @param requestCallback callback to change message, can be {@code null}
|
||||
* @return the unmarshalled payload of the response message, or {@code null} if no response is given
|
||||
* @throws XmlMappingException if there is a problem marshalling or unmarshalling
|
||||
* @throws WebServiceClientException if there is a problem sending or receiving the message
|
||||
* @see WebServiceTemplate#setMarshaller(org.springframework.oxm.Marshaller)
|
||||
* @see WebServiceTemplate#setUnmarshaller(org.springframework.oxm.Unmarshaller)
|
||||
*/
|
||||
Object marshalSendAndReceive(Object requestPayload, WebServiceMessageCallback requestCallback)
|
||||
throws XmlMappingException, WebServiceClientException;
|
||||
|
||||
/**
|
||||
* Sends a web service message that contains the given payload, marshalled by the configured
|
||||
* {@code Marshaller}. Returns the unmarshalled payload of the response message, if any. The given callback
|
||||
* allows changing of the request message after the payload has been marshalled to it.
|
||||
*
|
||||
* @param uri the URI to send the message to
|
||||
* @param requestPayload the object to marshal into the request message payload
|
||||
* @param requestCallback callback to change message, can be {@code null}
|
||||
* @return the unmarshalled payload of the response message, or {@code null} if no response is given
|
||||
* @throws XmlMappingException if there is a problem marshalling or unmarshalling
|
||||
* @throws WebServiceClientException if there is a problem sending or receiving the message
|
||||
* @see WebServiceTemplate#setMarshaller(org.springframework.oxm.Marshaller)
|
||||
* @see WebServiceTemplate#setUnmarshaller(org.springframework.oxm.Unmarshaller)
|
||||
*/
|
||||
Object marshalSendAndReceive(String uri, Object requestPayload, WebServiceMessageCallback requestCallback)
|
||||
throws XmlMappingException, WebServiceClientException;
|
||||
/**
|
||||
* Sends a web service message that contains the given payload, marshalled by the configured
|
||||
* {@code Marshaller}. Returns the unmarshalled payload of the response message, if any. The given callback
|
||||
* allows changing of the request message after the payload has been marshalled to it.
|
||||
*
|
||||
* @param uri the URI to send the message to
|
||||
* @param requestPayload the object to marshal into the request message payload
|
||||
* @param requestCallback callback to change message, can be {@code null}
|
||||
* @return the unmarshalled payload of the response message, or {@code null} if no response is given
|
||||
* @throws XmlMappingException if there is a problem marshalling or unmarshalling
|
||||
* @throws WebServiceClientException if there is a problem sending or receiving the message
|
||||
* @see WebServiceTemplate#setMarshaller(org.springframework.oxm.Marshaller)
|
||||
* @see WebServiceTemplate#setUnmarshaller(org.springframework.oxm.Unmarshaller)
|
||||
*/
|
||||
Object marshalSendAndReceive(String uri, Object requestPayload, WebServiceMessageCallback requestCallback)
|
||||
throws XmlMappingException, WebServiceClientException;
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------------
|
||||
// Convenience methods for sending Sources
|
||||
//-----------------------------------------------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------------------------------------------
|
||||
// Convenience methods for sending Sources
|
||||
//-----------------------------------------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Sends a web service message that contains the given payload, reading the result with a
|
||||
* {@code SourceExtractor}.
|
||||
*
|
||||
* <p>This will only work with a default uri specified!
|
||||
*
|
||||
* @param requestPayload the payload of the request message
|
||||
* @param responseExtractor object that will extract results
|
||||
* @return an arbitrary result object, as returned by the {@code SourceExtractor}
|
||||
* @throws WebServiceClientException if there is a problem sending or receiving the message
|
||||
*/
|
||||
<T> T sendSourceAndReceive(Source requestPayload, SourceExtractor<T> responseExtractor)
|
||||
throws WebServiceClientException;
|
||||
/**
|
||||
* Sends a web service message that contains the given payload, reading the result with a
|
||||
* {@code SourceExtractor}.
|
||||
*
|
||||
* <p>This will only work with a default uri specified!
|
||||
*
|
||||
* @param requestPayload the payload of the request message
|
||||
* @param responseExtractor object that will extract results
|
||||
* @return an arbitrary result object, as returned by the {@code SourceExtractor}
|
||||
* @throws WebServiceClientException if there is a problem sending or receiving the message
|
||||
*/
|
||||
<T> T sendSourceAndReceive(Source requestPayload, SourceExtractor<T> responseExtractor)
|
||||
throws WebServiceClientException;
|
||||
|
||||
/**
|
||||
* Sends a web service message that contains the given payload, reading the result with a
|
||||
* {@code SourceExtractor}.
|
||||
*
|
||||
* @param uri the URI to send the message to
|
||||
* @param requestPayload the payload of the request message
|
||||
* @param responseExtractor object that will extract results
|
||||
* @return an arbitrary result object, as returned by the {@code SourceExtractor}
|
||||
* @throws WebServiceClientException if there is a problem sending or receiving the message
|
||||
*/
|
||||
<T> T sendSourceAndReceive(String uri, Source requestPayload, SourceExtractor<T> responseExtractor)
|
||||
throws WebServiceClientException;
|
||||
/**
|
||||
* Sends a web service message that contains the given payload, reading the result with a
|
||||
* {@code SourceExtractor}.
|
||||
*
|
||||
* @param uri the URI to send the message to
|
||||
* @param requestPayload the payload of the request message
|
||||
* @param responseExtractor object that will extract results
|
||||
* @return an arbitrary result object, as returned by the {@code SourceExtractor}
|
||||
* @throws WebServiceClientException if there is a problem sending or receiving the message
|
||||
*/
|
||||
<T> T sendSourceAndReceive(String uri, Source requestPayload, SourceExtractor<T> responseExtractor)
|
||||
throws WebServiceClientException;
|
||||
|
||||
/**
|
||||
* Sends a web service message that contains the given payload, reading the result with a
|
||||
* {@code SourceExtractor}.
|
||||
*
|
||||
* <p>The given callback allows changing of the request message after the payload has been written to it.
|
||||
*
|
||||
* <p>This will only work with a default uri specified!
|
||||
*
|
||||
* @param requestPayload the payload of the request message
|
||||
* @param requestCallback callback to change message, can be {@code null}
|
||||
* @param responseExtractor object that will extract results
|
||||
* @return an arbitrary result object, as returned by the {@code SourceExtractor}
|
||||
* @throws WebServiceClientException if there is a problem sending or receiving the message
|
||||
*/
|
||||
<T> T sendSourceAndReceive(Source requestPayload,
|
||||
WebServiceMessageCallback requestCallback,
|
||||
SourceExtractor<T> responseExtractor) throws WebServiceClientException;
|
||||
/**
|
||||
* Sends a web service message that contains the given payload, reading the result with a
|
||||
* {@code SourceExtractor}.
|
||||
*
|
||||
* <p>The given callback allows changing of the request message after the payload has been written to it.
|
||||
*
|
||||
* <p>This will only work with a default uri specified!
|
||||
*
|
||||
* @param requestPayload the payload of the request message
|
||||
* @param requestCallback callback to change message, can be {@code null}
|
||||
* @param responseExtractor object that will extract results
|
||||
* @return an arbitrary result object, as returned by the {@code SourceExtractor}
|
||||
* @throws WebServiceClientException if there is a problem sending or receiving the message
|
||||
*/
|
||||
<T> T sendSourceAndReceive(Source requestPayload,
|
||||
WebServiceMessageCallback requestCallback,
|
||||
SourceExtractor<T> responseExtractor) throws WebServiceClientException;
|
||||
|
||||
/**
|
||||
* Sends a web service message that contains the given payload, reading the result with a
|
||||
* {@code SourceExtractor}.
|
||||
*
|
||||
* <p>The given callback allows changing of the request message after the payload has been written to it.
|
||||
*
|
||||
* @param uri the URI to send the message to
|
||||
* @param requestPayload the payload of the request message
|
||||
* @param requestCallback callback to change message, can be {@code null}
|
||||
* @param responseExtractor object that will extract results
|
||||
* @return an arbitrary result object, as returned by the {@code SourceExtractor}
|
||||
* @throws WebServiceClientException if there is a problem sending or receiving the message
|
||||
*/
|
||||
<T> T sendSourceAndReceive(String uri,
|
||||
Source requestPayload,
|
||||
WebServiceMessageCallback requestCallback,
|
||||
SourceExtractor<T> responseExtractor) throws WebServiceClientException;
|
||||
/**
|
||||
* Sends a web service message that contains the given payload, reading the result with a
|
||||
* {@code SourceExtractor}.
|
||||
*
|
||||
* <p>The given callback allows changing of the request message after the payload has been written to it.
|
||||
*
|
||||
* @param uri the URI to send the message to
|
||||
* @param requestPayload the payload of the request message
|
||||
* @param requestCallback callback to change message, can be {@code null}
|
||||
* @param responseExtractor object that will extract results
|
||||
* @return an arbitrary result object, as returned by the {@code SourceExtractor}
|
||||
* @throws WebServiceClientException if there is a problem sending or receiving the message
|
||||
*/
|
||||
<T> T sendSourceAndReceive(String uri,
|
||||
Source requestPayload,
|
||||
WebServiceMessageCallback requestCallback,
|
||||
SourceExtractor<T> responseExtractor) throws WebServiceClientException;
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------------
|
||||
// Convenience methods for sending Sources and receiving to Results
|
||||
//-----------------------------------------------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------------------------------------------
|
||||
// Convenience methods for sending Sources and receiving to Results
|
||||
//-----------------------------------------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Sends a web service message that contains the given payload. Writes the response, if any, to the given
|
||||
* {@code Result}.
|
||||
*
|
||||
* <p>This will only work with a default uri specified!
|
||||
*
|
||||
* @param requestPayload the payload of the request message
|
||||
* @param responseResult the result to write the response payload to
|
||||
* @return {@code true} if a response was received; {@code false} otherwise
|
||||
* @throws WebServiceClientException if there is a problem sending or receiving the message
|
||||
*/
|
||||
boolean sendSourceAndReceiveToResult(Source requestPayload, Result responseResult) throws WebServiceClientException;
|
||||
/**
|
||||
* Sends a web service message that contains the given payload. Writes the response, if any, to the given
|
||||
* {@code Result}.
|
||||
*
|
||||
* <p>This will only work with a default uri specified!
|
||||
*
|
||||
* @param requestPayload the payload of the request message
|
||||
* @param responseResult the result to write the response payload to
|
||||
* @return {@code true} if a response was received; {@code false} otherwise
|
||||
* @throws WebServiceClientException if there is a problem sending or receiving the message
|
||||
*/
|
||||
boolean sendSourceAndReceiveToResult(Source requestPayload, Result responseResult) throws WebServiceClientException;
|
||||
|
||||
/**
|
||||
* Sends a web service message that contains the given payload. Writes the response, if any, to the given
|
||||
* {@code Result}.
|
||||
*
|
||||
* @param uri the URI to send the message to
|
||||
* @param requestPayload the payload of the request message
|
||||
* @param responseResult the result to write the response payload to
|
||||
* @return {@code true} if a response was received; {@code false} otherwise
|
||||
* @throws WebServiceClientException if there is a problem sending or receiving the message
|
||||
*/
|
||||
boolean sendSourceAndReceiveToResult(String uri, Source requestPayload, Result responseResult)
|
||||
throws WebServiceClientException;
|
||||
/**
|
||||
* Sends a web service message that contains the given payload. Writes the response, if any, to the given
|
||||
* {@code Result}.
|
||||
*
|
||||
* @param uri the URI to send the message to
|
||||
* @param requestPayload the payload of the request message
|
||||
* @param responseResult the result to write the response payload to
|
||||
* @return {@code true} if a response was received; {@code false} otherwise
|
||||
* @throws WebServiceClientException if there is a problem sending or receiving the message
|
||||
*/
|
||||
boolean sendSourceAndReceiveToResult(String uri, Source requestPayload, Result responseResult)
|
||||
throws WebServiceClientException;
|
||||
|
||||
/**
|
||||
* Sends a web service message that contains the given payload. Writes the response, if any, to the given
|
||||
* {@code Result}.
|
||||
*
|
||||
* <p>The given callback allows changing of the request message after the payload has been written to it.
|
||||
*
|
||||
* <p>This will only work with a default uri specified!
|
||||
*
|
||||
* @param requestPayload the payload of the request message
|
||||
* @param requestCallback callback to change message, can be {@code null}
|
||||
* @param responseResult the result to write the response payload to
|
||||
* @return {@code true} if a response was received; {@code false} otherwise
|
||||
* @throws WebServiceClientException if there is a problem sending or receiving the message
|
||||
*/
|
||||
boolean sendSourceAndReceiveToResult(Source requestPayload,
|
||||
WebServiceMessageCallback requestCallback,
|
||||
Result responseResult) throws WebServiceClientException;
|
||||
/**
|
||||
* Sends a web service message that contains the given payload. Writes the response, if any, to the given
|
||||
* {@code Result}.
|
||||
*
|
||||
* <p>The given callback allows changing of the request message after the payload has been written to it.
|
||||
*
|
||||
* <p>This will only work with a default uri specified!
|
||||
*
|
||||
* @param requestPayload the payload of the request message
|
||||
* @param requestCallback callback to change message, can be {@code null}
|
||||
* @param responseResult the result to write the response payload to
|
||||
* @return {@code true} if a response was received; {@code false} otherwise
|
||||
* @throws WebServiceClientException if there is a problem sending or receiving the message
|
||||
*/
|
||||
boolean sendSourceAndReceiveToResult(Source requestPayload,
|
||||
WebServiceMessageCallback requestCallback,
|
||||
Result responseResult) throws WebServiceClientException;
|
||||
|
||||
/**
|
||||
* Sends a web service message that contains the given payload. Writes the response, if any, to the given
|
||||
* {@code Result}.
|
||||
*
|
||||
* <p>The given callback allows changing of the request message after the payload has been written to it.
|
||||
*
|
||||
* @param uri the URI to send the message to
|
||||
* @param requestPayload the payload of the request message
|
||||
* @param requestCallback callback to change message, can be {@code null}
|
||||
* @param responseResult the result to write the response payload to
|
||||
* @return {@code true} if a response was received; {@code false} otherwise
|
||||
* @throws WebServiceClientException if there is a problem sending or receiving the message
|
||||
*/
|
||||
boolean sendSourceAndReceiveToResult(String uri,
|
||||
Source requestPayload,
|
||||
WebServiceMessageCallback requestCallback,
|
||||
Result responseResult) throws WebServiceClientException;
|
||||
/**
|
||||
* Sends a web service message that contains the given payload. Writes the response, if any, to the given
|
||||
* {@code Result}.
|
||||
*
|
||||
* <p>The given callback allows changing of the request message after the payload has been written to it.
|
||||
*
|
||||
* @param uri the URI to send the message to
|
||||
* @param requestPayload the payload of the request message
|
||||
* @param requestCallback callback to change message, can be {@code null}
|
||||
* @param responseResult the result to write the response payload to
|
||||
* @return {@code true} if a response was received; {@code false} otherwise
|
||||
* @throws WebServiceClientException if there is a problem sending or receiving the message
|
||||
*/
|
||||
boolean sendSourceAndReceiveToResult(String uri,
|
||||
Source requestPayload,
|
||||
WebServiceMessageCallback requestCallback,
|
||||
Result responseResult) throws WebServiceClientException;
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -52,144 +52,144 @@ import org.springframework.ws.transport.WebServiceMessageSender;
|
||||
*/
|
||||
public abstract class WebServiceGatewaySupport implements InitializingBean {
|
||||
|
||||
/** Logger available to subclasses. */
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
/** Logger available to subclasses. */
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
private WebServiceTemplate webServiceTemplate;
|
||||
private WebServiceTemplate webServiceTemplate;
|
||||
|
||||
/**
|
||||
* Creates a new instance of the {@code WebServiceGatewaySupport} class, with a default
|
||||
* {@code WebServiceTemplate}.
|
||||
*/
|
||||
protected WebServiceGatewaySupport() {
|
||||
webServiceTemplate = new WebServiceTemplate();
|
||||
}
|
||||
/**
|
||||
* Creates a new instance of the {@code WebServiceGatewaySupport} class, with a default
|
||||
* {@code WebServiceTemplate}.
|
||||
*/
|
||||
protected WebServiceGatewaySupport() {
|
||||
webServiceTemplate = new WebServiceTemplate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@code WebServiceGatewaySupport} instance based on the given message factory.
|
||||
*
|
||||
* @param messageFactory the message factory to use
|
||||
*/
|
||||
protected WebServiceGatewaySupport(WebServiceMessageFactory messageFactory) {
|
||||
webServiceTemplate = new WebServiceTemplate(messageFactory);
|
||||
}
|
||||
/**
|
||||
* Creates a new {@code WebServiceGatewaySupport} instance based on the given message factory.
|
||||
*
|
||||
* @param messageFactory the message factory to use
|
||||
*/
|
||||
protected WebServiceGatewaySupport(WebServiceMessageFactory messageFactory) {
|
||||
webServiceTemplate = new WebServiceTemplate(messageFactory);
|
||||
}
|
||||
|
||||
/** Returns the {@code WebServiceMessageFactory} used by the gateway. */
|
||||
public final WebServiceMessageFactory getMessageFactory() {
|
||||
return webServiceTemplate.getMessageFactory();
|
||||
}
|
||||
/** Returns the {@code WebServiceMessageFactory} used by the gateway. */
|
||||
public final WebServiceMessageFactory getMessageFactory() {
|
||||
return webServiceTemplate.getMessageFactory();
|
||||
}
|
||||
|
||||
/** Set the {@code WebServiceMessageFactory} to be used by the gateway. */
|
||||
public final void setMessageFactory(WebServiceMessageFactory messageFactory) {
|
||||
webServiceTemplate.setMessageFactory(messageFactory);
|
||||
}
|
||||
/** Set the {@code WebServiceMessageFactory} to be used by the gateway. */
|
||||
public final void setMessageFactory(WebServiceMessageFactory messageFactory) {
|
||||
webServiceTemplate.setMessageFactory(messageFactory);
|
||||
}
|
||||
|
||||
/** Returns the default URI used by the gateway. */
|
||||
public final String getDefaultUri() {
|
||||
return webServiceTemplate.getDefaultUri();
|
||||
}
|
||||
/** Returns the default URI used by the gateway. */
|
||||
public final String getDefaultUri() {
|
||||
return webServiceTemplate.getDefaultUri();
|
||||
}
|
||||
|
||||
/** Sets the default URI used by the gateway. */
|
||||
public final void setDefaultUri(String uri) {
|
||||
webServiceTemplate.setDefaultUri(uri);
|
||||
}
|
||||
/** Sets the default URI used by the gateway. */
|
||||
public final void setDefaultUri(String uri) {
|
||||
webServiceTemplate.setDefaultUri(uri);
|
||||
}
|
||||
|
||||
/** Returns the destination provider used by the gateway. */
|
||||
public final DestinationProvider getDestinationProvider() {
|
||||
return webServiceTemplate.getDestinationProvider();
|
||||
}
|
||||
/** Returns the destination provider used by the gateway. */
|
||||
public final DestinationProvider getDestinationProvider() {
|
||||
return webServiceTemplate.getDestinationProvider();
|
||||
}
|
||||
|
||||
/** Set the destination provider URI used by the gateway. */
|
||||
public final void setDestinationProvider(DestinationProvider destinationProvider) {
|
||||
webServiceTemplate.setDestinationProvider(destinationProvider);
|
||||
}
|
||||
/** Set the destination provider URI used by the gateway. */
|
||||
public final void setDestinationProvider(DestinationProvider destinationProvider) {
|
||||
webServiceTemplate.setDestinationProvider(destinationProvider);
|
||||
}
|
||||
|
||||
/** Sets a single {@code WebServiceMessageSender} to be used by the gateway. */
|
||||
public final void setMessageSender(WebServiceMessageSender messageSender) {
|
||||
webServiceTemplate.setMessageSender(messageSender);
|
||||
}
|
||||
/** Sets a single {@code WebServiceMessageSender} to be used by the gateway. */
|
||||
public final void setMessageSender(WebServiceMessageSender messageSender) {
|
||||
webServiceTemplate.setMessageSender(messageSender);
|
||||
}
|
||||
|
||||
/** Returns the {@code WebServiceMessageSender}s used by the gateway. */
|
||||
public final WebServiceMessageSender[] getMessageSenders() {
|
||||
return webServiceTemplate.getMessageSenders();
|
||||
}
|
||||
/** Returns the {@code WebServiceMessageSender}s used by the gateway. */
|
||||
public final WebServiceMessageSender[] getMessageSenders() {
|
||||
return webServiceTemplate.getMessageSenders();
|
||||
}
|
||||
|
||||
/** Sets multiple {@code WebServiceMessageSender} to be used by the gateway. */
|
||||
public final void setMessageSenders(WebServiceMessageSender[] messageSenders) {
|
||||
webServiceTemplate.setMessageSenders(messageSenders);
|
||||
}
|
||||
/** Sets multiple {@code WebServiceMessageSender} to be used by the gateway. */
|
||||
public final void setMessageSenders(WebServiceMessageSender[] messageSenders) {
|
||||
webServiceTemplate.setMessageSenders(messageSenders);
|
||||
}
|
||||
|
||||
/** Returns the {@code WebServiceTemplate} for the gateway. */
|
||||
public final WebServiceTemplate getWebServiceTemplate() {
|
||||
return webServiceTemplate;
|
||||
}
|
||||
/** Returns the {@code WebServiceTemplate} for the gateway. */
|
||||
public final WebServiceTemplate getWebServiceTemplate() {
|
||||
return webServiceTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@code WebServiceTemplate} to be used by the gateway.
|
||||
*
|
||||
* <p>When using this property, the convenience setters ({@link #setMarshaller(Marshaller)}, {@link
|
||||
* #setUnmarshaller(Unmarshaller)}, {@link #setMessageSender(WebServiceMessageSender)}, {@link
|
||||
* #setMessageSenders(WebServiceMessageSender[])}, and {@link #setDefaultUri(String)}) should not be set on this
|
||||
* class, but on the template directly.
|
||||
*/
|
||||
public final void setWebServiceTemplate(WebServiceTemplate webServiceTemplate) {
|
||||
Assert.notNull(webServiceTemplate, "'webServiceTemplate' must not be null");
|
||||
this.webServiceTemplate = webServiceTemplate;
|
||||
}
|
||||
/**
|
||||
* Sets the {@code WebServiceTemplate} to be used by the gateway.
|
||||
*
|
||||
* <p>When using this property, the convenience setters ({@link #setMarshaller(Marshaller)}, {@link
|
||||
* #setUnmarshaller(Unmarshaller)}, {@link #setMessageSender(WebServiceMessageSender)}, {@link
|
||||
* #setMessageSenders(WebServiceMessageSender[])}, and {@link #setDefaultUri(String)}) should not be set on this
|
||||
* class, but on the template directly.
|
||||
*/
|
||||
public final void setWebServiceTemplate(WebServiceTemplate webServiceTemplate) {
|
||||
Assert.notNull(webServiceTemplate, "'webServiceTemplate' must not be null");
|
||||
this.webServiceTemplate = webServiceTemplate;
|
||||
}
|
||||
|
||||
/** Returns the {@code Marshaller} used by the gateway. */
|
||||
public final Marshaller getMarshaller() {
|
||||
return webServiceTemplate.getMarshaller();
|
||||
}
|
||||
/** Returns the {@code Marshaller} used by the gateway. */
|
||||
public final Marshaller getMarshaller() {
|
||||
return webServiceTemplate.getMarshaller();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@code Marshaller} used by the gateway. Setting this property is only required if the marshalling
|
||||
* functionality of {@code WebServiceTemplate} is to be used.
|
||||
*
|
||||
* @see WebServiceTemplate#marshalSendAndReceive
|
||||
*/
|
||||
public final void setMarshaller(Marshaller marshaller) {
|
||||
webServiceTemplate.setMarshaller(marshaller);
|
||||
}
|
||||
/**
|
||||
* Sets the {@code Marshaller} used by the gateway. Setting this property is only required if the marshalling
|
||||
* functionality of {@code WebServiceTemplate} is to be used.
|
||||
*
|
||||
* @see WebServiceTemplate#marshalSendAndReceive
|
||||
*/
|
||||
public final void setMarshaller(Marshaller marshaller) {
|
||||
webServiceTemplate.setMarshaller(marshaller);
|
||||
}
|
||||
|
||||
/** Returns the {@code Unmarshaller} used by the gateway. */
|
||||
public final Unmarshaller getUnmarshaller() {
|
||||
return webServiceTemplate.getUnmarshaller();
|
||||
}
|
||||
/** Returns the {@code Unmarshaller} used by the gateway. */
|
||||
public final Unmarshaller getUnmarshaller() {
|
||||
return webServiceTemplate.getUnmarshaller();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@code Unmarshaller} used by the gateway. Setting this property is only required if the marshalling
|
||||
* functionality of {@code WebServiceTemplate} is to be used.
|
||||
*
|
||||
* @see WebServiceTemplate#marshalSendAndReceive
|
||||
*/
|
||||
public final void setUnmarshaller(Unmarshaller unmarshaller) {
|
||||
webServiceTemplate.setUnmarshaller(unmarshaller);
|
||||
}
|
||||
/**
|
||||
* Sets the {@code Unmarshaller} used by the gateway. Setting this property is only required if the marshalling
|
||||
* functionality of {@code WebServiceTemplate} is to be used.
|
||||
*
|
||||
* @see WebServiceTemplate#marshalSendAndReceive
|
||||
*/
|
||||
public final void setUnmarshaller(Unmarshaller unmarshaller) {
|
||||
webServiceTemplate.setUnmarshaller(unmarshaller);
|
||||
}
|
||||
|
||||
/** Returns the {@code ClientInterceptors} used by the template. */
|
||||
public final ClientInterceptor[] getInterceptors() {
|
||||
return webServiceTemplate.getInterceptors();
|
||||
}
|
||||
/** Returns the {@code ClientInterceptors} used by the template. */
|
||||
public final ClientInterceptor[] getInterceptors() {
|
||||
return webServiceTemplate.getInterceptors();
|
||||
}
|
||||
|
||||
/** Sets the {@code ClientInterceptors} used by the gateway. */
|
||||
public final void setInterceptors(ClientInterceptor[] interceptors) {
|
||||
webServiceTemplate.setInterceptors(interceptors);
|
||||
}
|
||||
/** Sets the {@code ClientInterceptors} used by the gateway. */
|
||||
public final void setInterceptors(ClientInterceptor[] interceptors) {
|
||||
webServiceTemplate.setInterceptors(interceptors);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void afterPropertiesSet() throws Exception {
|
||||
webServiceTemplate.afterPropertiesSet();
|
||||
initGateway();
|
||||
}
|
||||
@Override
|
||||
public final void afterPropertiesSet() throws Exception {
|
||||
webServiceTemplate.afterPropertiesSet();
|
||||
initGateway();
|
||||
}
|
||||
|
||||
/**
|
||||
* Subclasses can override this for custom initialization behavior. Gets called after population of this instance's
|
||||
* bean properties.
|
||||
*
|
||||
* @throws java.lang.Exception if initialization fails
|
||||
*/
|
||||
protected void initGateway() throws Exception {
|
||||
}
|
||||
/**
|
||||
* Subclasses can override this for custom initialization behavior. Gets called after population of this instance's
|
||||
* bean properties.
|
||||
*
|
||||
* @throws java.lang.Exception if initialization fails
|
||||
*/
|
||||
protected void initGateway() throws Exception {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,85 +39,85 @@ import org.springframework.xml.transform.TransformerObjectSupport;
|
||||
*/
|
||||
public abstract class WebServiceAccessor extends TransformerObjectSupport implements InitializingBean {
|
||||
|
||||
private WebServiceMessageFactory messageFactory;
|
||||
private WebServiceMessageFactory messageFactory;
|
||||
|
||||
private WebServiceMessageSender[] messageSenders;
|
||||
private WebServiceMessageSender[] messageSenders;
|
||||
|
||||
/** Returns the message factory used for creating messages. */
|
||||
public WebServiceMessageFactory getMessageFactory() {
|
||||
return messageFactory;
|
||||
}
|
||||
/** Returns the message factory used for creating messages. */
|
||||
public WebServiceMessageFactory getMessageFactory() {
|
||||
return messageFactory;
|
||||
}
|
||||
|
||||
/** Sets the message factory used for creating messages. */
|
||||
public void setMessageFactory(WebServiceMessageFactory messageFactory) {
|
||||
this.messageFactory = messageFactory;
|
||||
}
|
||||
/** Sets the message factory used for creating messages. */
|
||||
public void setMessageFactory(WebServiceMessageFactory messageFactory) {
|
||||
this.messageFactory = messageFactory;
|
||||
}
|
||||
|
||||
/** Returns the message senders used for sending messages. */
|
||||
public WebServiceMessageSender[] getMessageSenders() {
|
||||
return messageSenders;
|
||||
}
|
||||
/** Returns the message senders used for sending messages. */
|
||||
public WebServiceMessageSender[] getMessageSenders() {
|
||||
return messageSenders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the single message sender used for sending messages.
|
||||
*
|
||||
* <p>This message sender will be used to resolve an URI to a {@link WebServiceConnection}.
|
||||
*
|
||||
* @see #createConnection(URI)
|
||||
*/
|
||||
public void setMessageSender(WebServiceMessageSender messageSender) {
|
||||
Assert.notNull(messageSender, "'messageSender' must not be null");
|
||||
messageSenders = new WebServiceMessageSender[]{messageSender};
|
||||
}
|
||||
/**
|
||||
* Sets the single message sender used for sending messages.
|
||||
*
|
||||
* <p>This message sender will be used to resolve an URI to a {@link WebServiceConnection}.
|
||||
*
|
||||
* @see #createConnection(URI)
|
||||
*/
|
||||
public void setMessageSender(WebServiceMessageSender messageSender) {
|
||||
Assert.notNull(messageSender, "'messageSender' must not be null");
|
||||
messageSenders = new WebServiceMessageSender[]{messageSender};
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the message senders used for sending messages.
|
||||
*
|
||||
* <p>These message senders will be used to resolve an URI to a {@link WebServiceConnection}.
|
||||
*
|
||||
* @see #createConnection(URI)
|
||||
*/
|
||||
public void setMessageSenders(WebServiceMessageSender[] messageSenders) {
|
||||
Assert.notEmpty(messageSenders, "'messageSenders' must not be empty");
|
||||
this.messageSenders = messageSenders;
|
||||
}
|
||||
/**
|
||||
* Sets the message senders used for sending messages.
|
||||
*
|
||||
* <p>These message senders will be used to resolve an URI to a {@link WebServiceConnection}.
|
||||
*
|
||||
* @see #createConnection(URI)
|
||||
*/
|
||||
public void setMessageSenders(WebServiceMessageSender[] messageSenders) {
|
||||
Assert.notEmpty(messageSenders, "'messageSenders' must not be empty");
|
||||
this.messageSenders = messageSenders;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
Assert.notNull(getMessageFactory(), "Property 'messageFactory' is required");
|
||||
Assert.notEmpty(getMessageSenders(), "Property 'messageSenders' is required");
|
||||
}
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
Assert.notNull(getMessageFactory(), "Property 'messageFactory' is required");
|
||||
Assert.notEmpty(getMessageSenders(), "Property 'messageSenders' is required");
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a connection to the given URI, or throws an exception when it cannot be resolved.
|
||||
*
|
||||
* <p>Default implementation iterates over all configured {@link WebServiceMessageSender} objects, and calls {@link
|
||||
* WebServiceMessageSender#supports(URI)} for each of them. If the sender supports the parameter URI, it creates a
|
||||
* connection using {@link WebServiceMessageSender#createConnection(URI)} .
|
||||
*
|
||||
* @param uri the URI to open a connection to
|
||||
* @return the created connection
|
||||
* @throws IllegalArgumentException when the uri cannot be resolved
|
||||
* @throws IOException when an I/O error occurs
|
||||
*/
|
||||
protected WebServiceConnection createConnection(URI uri) throws IOException {
|
||||
Assert.notEmpty(getMessageSenders(), "Property 'messageSenders' is required");
|
||||
WebServiceMessageSender[] messageSenders = getMessageSenders();
|
||||
for (WebServiceMessageSender messageSender : messageSenders) {
|
||||
if (messageSender.supports(uri)) {
|
||||
WebServiceConnection connection = messageSender.createConnection(uri);
|
||||
if (logger.isDebugEnabled()) {
|
||||
try {
|
||||
logger.debug("Opening [" + connection + "] to [" + connection.getUri() + "]");
|
||||
}
|
||||
catch (URISyntaxException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
return connection;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Could not resolve [" + uri + "] to a WebServiceMessageSender");
|
||||
}
|
||||
/**
|
||||
* Creates a connection to the given URI, or throws an exception when it cannot be resolved.
|
||||
*
|
||||
* <p>Default implementation iterates over all configured {@link WebServiceMessageSender} objects, and calls {@link
|
||||
* WebServiceMessageSender#supports(URI)} for each of them. If the sender supports the parameter URI, it creates a
|
||||
* connection using {@link WebServiceMessageSender#createConnection(URI)} .
|
||||
*
|
||||
* @param uri the URI to open a connection to
|
||||
* @return the created connection
|
||||
* @throws IllegalArgumentException when the uri cannot be resolved
|
||||
* @throws IOException when an I/O error occurs
|
||||
*/
|
||||
protected WebServiceConnection createConnection(URI uri) throws IOException {
|
||||
Assert.notEmpty(getMessageSenders(), "Property 'messageSenders' is required");
|
||||
WebServiceMessageSender[] messageSenders = getMessageSenders();
|
||||
for (WebServiceMessageSender messageSender : messageSenders) {
|
||||
if (messageSender.supports(uri)) {
|
||||
WebServiceConnection connection = messageSender.createConnection(uri);
|
||||
if (logger.isDebugEnabled()) {
|
||||
try {
|
||||
logger.debug("Opening [" + connection + "] to [" + connection.getUri() + "]");
|
||||
}
|
||||
catch (URISyntaxException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
return connection;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Could not resolve [" + uri + "] to a WebServiceMessageSender");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,41 +32,41 @@ import org.apache.commons.logging.LogFactory;
|
||||
*/
|
||||
public abstract class AbstractCachingDestinationProvider implements DestinationProvider {
|
||||
|
||||
/** Logger available to subclasses. */
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
/** Logger available to subclasses. */
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
private URI cachedUri;
|
||||
private URI cachedUri;
|
||||
|
||||
private boolean cache = true;
|
||||
private boolean cache = true;
|
||||
|
||||
/**
|
||||
* Set whether to cache resolved destinations. Default is {@code true}. This flag can be turned off to
|
||||
* re-lookup a destination for each operation, which allows for hot restarting of destinations. This is mainly
|
||||
* useful during development.
|
||||
*/
|
||||
public void setCache(boolean cache) {
|
||||
this.cache = cache;
|
||||
}
|
||||
/**
|
||||
* Set whether to cache resolved destinations. Default is {@code true}. This flag can be turned off to
|
||||
* re-lookup a destination for each operation, which allows for hot restarting of destinations. This is mainly
|
||||
* useful during development.
|
||||
*/
|
||||
public void setCache(boolean cache) {
|
||||
this.cache = cache;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final URI getDestination() {
|
||||
if (cache) {
|
||||
if (cachedUri == null) {
|
||||
cachedUri = lookupDestination();
|
||||
}
|
||||
return cachedUri;
|
||||
}
|
||||
else {
|
||||
return lookupDestination();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public final URI getDestination() {
|
||||
if (cache) {
|
||||
if (cachedUri == null) {
|
||||
cachedUri = lookupDestination();
|
||||
}
|
||||
return cachedUri;
|
||||
}
|
||||
else {
|
||||
return lookupDestination();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract template method that looks up the URI.
|
||||
*
|
||||
* <p>If {@linkplain #setCache(boolean) caching} is enabled, this method will only be called once.
|
||||
*
|
||||
* @return the destination URI
|
||||
*/
|
||||
protected abstract URI lookupDestination();
|
||||
/**
|
||||
* Abstract template method that looks up the URI.
|
||||
*
|
||||
* <p>If {@linkplain #setCache(boolean) caching} is enabled, this method will only be called once.
|
||||
*
|
||||
* @return the destination URI
|
||||
*/
|
||||
protected abstract URI lookupDestination();
|
||||
}
|
||||
|
||||
@@ -31,11 +31,11 @@ import java.net.URI;
|
||||
*/
|
||||
public interface DestinationProvider {
|
||||
|
||||
/**
|
||||
* Return the destination URI.
|
||||
*
|
||||
* @return the destination URI
|
||||
*/
|
||||
URI getDestination();
|
||||
/**
|
||||
* Return the destination URI.
|
||||
*
|
||||
* @return the destination URI
|
||||
*/
|
||||
URI getDestination();
|
||||
|
||||
}
|
||||
|
||||
@@ -27,11 +27,11 @@ import org.springframework.ws.client.WebServiceClientException;
|
||||
@SuppressWarnings("serial")
|
||||
public class DestinationProvisionException extends WebServiceClientException {
|
||||
|
||||
public DestinationProvisionException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
public DestinationProvisionException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public DestinationProvisionException(String msg, Throwable ex) {
|
||||
super(msg, ex);
|
||||
}
|
||||
public DestinationProvisionException(String msg, Throwable ex) {
|
||||
super(msg, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,70 +48,70 @@ import org.springframework.xml.xpath.XPathExpressionFactory;
|
||||
*/
|
||||
public class Wsdl11DestinationProvider extends AbstractCachingDestinationProvider {
|
||||
|
||||
/** Default XPath expression used for extracting all {@code location} attributes from the WSDL definition. */
|
||||
public static final String DEFAULT_WSDL_LOCATION_EXPRESSION =
|
||||
"/wsdl:definitions/wsdl:service/wsdl:port/soap:address/@location";
|
||||
/** Default XPath expression used for extracting all {@code location} attributes from the WSDL definition. */
|
||||
public static final String DEFAULT_WSDL_LOCATION_EXPRESSION =
|
||||
"/wsdl:definitions/wsdl:service/wsdl:port/soap:address/@location";
|
||||
|
||||
private static TransformerFactory transformerFactory = TransformerFactory.newInstance();
|
||||
private static TransformerFactory transformerFactory = TransformerFactory.newInstance();
|
||||
|
||||
private Map<String, String> expressionNamespaces = new HashMap<String, String>();
|
||||
private Map<String, String> expressionNamespaces = new HashMap<String, String>();
|
||||
|
||||
private XPathExpression locationXPathExpression;
|
||||
private XPathExpression locationXPathExpression;
|
||||
|
||||
private Resource wsdlResource;
|
||||
private Resource wsdlResource;
|
||||
|
||||
public Wsdl11DestinationProvider() {
|
||||
expressionNamespaces.put("wsdl", "http://schemas.xmlsoap.org/wsdl/");
|
||||
expressionNamespaces.put("soap", "http://schemas.xmlsoap.org/wsdl/soap/");
|
||||
expressionNamespaces.put("soap12", "http://schemas.xmlsoap.org/wsdl/soap12/");
|
||||
public Wsdl11DestinationProvider() {
|
||||
expressionNamespaces.put("wsdl", "http://schemas.xmlsoap.org/wsdl/");
|
||||
expressionNamespaces.put("soap", "http://schemas.xmlsoap.org/wsdl/soap/");
|
||||
expressionNamespaces.put("soap12", "http://schemas.xmlsoap.org/wsdl/soap12/");
|
||||
|
||||
locationXPathExpression = XPathExpressionFactory
|
||||
.createXPathExpression(DEFAULT_WSDL_LOCATION_EXPRESSION, expressionNamespaces);
|
||||
}
|
||||
locationXPathExpression = XPathExpressionFactory
|
||||
.createXPathExpression(DEFAULT_WSDL_LOCATION_EXPRESSION, expressionNamespaces);
|
||||
}
|
||||
|
||||
/** Sets a WSDL location from which the service destination {@code URI} will be resolved. */
|
||||
public void setWsdl(Resource wsdlResource) {
|
||||
Assert.notNull(wsdlResource, "'wsdl' must not be null");
|
||||
Assert.isTrue(wsdlResource.exists(), wsdlResource + " does not exist");
|
||||
this.wsdlResource = wsdlResource;
|
||||
}
|
||||
/** Sets a WSDL location from which the service destination {@code URI} will be resolved. */
|
||||
public void setWsdl(Resource wsdlResource) {
|
||||
Assert.notNull(wsdlResource, "'wsdl' must not be null");
|
||||
Assert.isTrue(wsdlResource.exists(), wsdlResource + " does not exist");
|
||||
this.wsdlResource = wsdlResource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XPath expression to use when extracting the service location {@code URI} from a WSDL.
|
||||
*
|
||||
* <p>The expression can use the following bound prefixes: <blockquote> <table> <tr><th>Prefix</th><th>Namespace</th></tr>
|
||||
* <tr><td>{@code wsdl}</td><td>{@code http://schemas.xmlsoap.org/wsdl/}</td></tr>
|
||||
* <tr><td>{@code soap}</td><td>{@code http://schemas.xmlsoap.org/wsdl/soap/}</td></tr>
|
||||
* <tr><td>{@code soap12}</td><td>{@code http://schemas.xmlsoap.org/wsdl/soap12/}</td></tr>
|
||||
* </table></blockquote>
|
||||
*
|
||||
* <p>Defaults to {@link #DEFAULT_WSDL_LOCATION_EXPRESSION}.
|
||||
*/
|
||||
public void setLocationExpression(String expression) {
|
||||
Assert.hasText(expression, "'expression' must not be empty");
|
||||
locationXPathExpression = XPathExpressionFactory
|
||||
.createXPathExpression(expression, expressionNamespaces);
|
||||
}
|
||||
/**
|
||||
* Sets the XPath expression to use when extracting the service location {@code URI} from a WSDL.
|
||||
*
|
||||
* <p>The expression can use the following bound prefixes: <blockquote> <table> <tr><th>Prefix</th><th>Namespace</th></tr>
|
||||
* <tr><td>{@code wsdl}</td><td>{@code http://schemas.xmlsoap.org/wsdl/}</td></tr>
|
||||
* <tr><td>{@code soap}</td><td>{@code http://schemas.xmlsoap.org/wsdl/soap/}</td></tr>
|
||||
* <tr><td>{@code soap12}</td><td>{@code http://schemas.xmlsoap.org/wsdl/soap12/}</td></tr>
|
||||
* </table></blockquote>
|
||||
*
|
||||
* <p>Defaults to {@link #DEFAULT_WSDL_LOCATION_EXPRESSION}.
|
||||
*/
|
||||
public void setLocationExpression(String expression) {
|
||||
Assert.hasText(expression, "'expression' must not be empty");
|
||||
locationXPathExpression = XPathExpressionFactory
|
||||
.createXPathExpression(expression, expressionNamespaces);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected URI lookupDestination() {
|
||||
try {
|
||||
DOMResult result = new DOMResult();
|
||||
Transformer transformer = transformerFactory.newTransformer();
|
||||
transformer.transform(new ResourceSource(wsdlResource), result);
|
||||
Document definitionDocument = (Document) result.getNode();
|
||||
String location = locationXPathExpression.evaluateAsString(definitionDocument);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Found location [" + location + "] in " + wsdlResource);
|
||||
}
|
||||
return location != null ? URI.create(location) : null;
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new WebServiceIOException("Error extracting location from WSDL [" + wsdlResource + "]", ex);
|
||||
}
|
||||
catch (TransformerException ex) {
|
||||
throw new WebServiceTransformerException("Error extracting location from WSDL [" + wsdlResource + "]", ex);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected URI lookupDestination() {
|
||||
try {
|
||||
DOMResult result = new DOMResult();
|
||||
Transformer transformer = transformerFactory.newTransformer();
|
||||
transformer.transform(new ResourceSource(wsdlResource), result);
|
||||
Document definitionDocument = (Document) result.getNode();
|
||||
String location = locationXPathExpression.evaluateAsString(definitionDocument);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Found location [" + location + "] in " + wsdlResource);
|
||||
}
|
||||
return location != null ? URI.create(location) : null;
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new WebServiceIOException("Error extracting location from WSDL [" + wsdlResource + "]", ex);
|
||||
}
|
||||
catch (TransformerException ex) {
|
||||
throw new WebServiceTransformerException("Error extracting location from WSDL [" + wsdlResource + "]", ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -50,216 +50,216 @@ import org.springframework.xml.xsd.XsdSchemaCollection;
|
||||
* @since 1.5.4
|
||||
*/
|
||||
public abstract class AbstractValidatingInterceptor extends TransformerObjectSupport
|
||||
implements ClientInterceptor, InitializingBean {
|
||||
implements ClientInterceptor, InitializingBean {
|
||||
|
||||
private String schemaLanguage = XmlValidatorFactory.SCHEMA_W3C_XML;
|
||||
private String schemaLanguage = XmlValidatorFactory.SCHEMA_W3C_XML;
|
||||
|
||||
private Resource[] schemas;
|
||||
private Resource[] schemas;
|
||||
|
||||
private boolean validateRequest = true;
|
||||
private boolean validateRequest = true;
|
||||
|
||||
private boolean validateResponse = false;
|
||||
private boolean validateResponse = false;
|
||||
|
||||
private XmlValidator validator;
|
||||
private XmlValidator validator;
|
||||
|
||||
public String getSchemaLanguage() {
|
||||
return schemaLanguage;
|
||||
}
|
||||
public String getSchemaLanguage() {
|
||||
return schemaLanguage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the schema language. Default is the W3C XML Schema: {@code http://www.w3.org/2001/XMLSchema"}.
|
||||
*
|
||||
* @see XmlValidatorFactory#SCHEMA_W3C_XML
|
||||
* @see XmlValidatorFactory#SCHEMA_RELAX_NG
|
||||
*/
|
||||
public void setSchemaLanguage(String schemaLanguage) {
|
||||
this.schemaLanguage = schemaLanguage;
|
||||
}
|
||||
/**
|
||||
* Sets the schema language. Default is the W3C XML Schema: {@code http://www.w3.org/2001/XMLSchema"}.
|
||||
*
|
||||
* @see XmlValidatorFactory#SCHEMA_W3C_XML
|
||||
* @see XmlValidatorFactory#SCHEMA_RELAX_NG
|
||||
*/
|
||||
public void setSchemaLanguage(String schemaLanguage) {
|
||||
this.schemaLanguage = schemaLanguage;
|
||||
}
|
||||
|
||||
/** Returns the schema resources to use for validation. */
|
||||
public Resource[] getSchemas() {
|
||||
return schemas;
|
||||
}
|
||||
/** Returns the schema resources to use for validation. */
|
||||
public Resource[] getSchemas() {
|
||||
return schemas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the schema resource to use for validation. Setting this property, {@link
|
||||
* #setXsdSchemaCollection(XsdSchemaCollection) xsdSchemaCollection}, {@link #setSchema(Resource) schema}, or {@link
|
||||
* #setSchemas(Resource[]) schemas} is required.
|
||||
*/
|
||||
public void setSchema(Resource schema) {
|
||||
setSchemas(new Resource[]{schema});
|
||||
}
|
||||
/**
|
||||
* Sets the schema resource to use for validation. Setting this property, {@link
|
||||
* #setXsdSchemaCollection(XsdSchemaCollection) xsdSchemaCollection}, {@link #setSchema(Resource) schema}, or {@link
|
||||
* #setSchemas(Resource[]) schemas} is required.
|
||||
*/
|
||||
public void setSchema(Resource schema) {
|
||||
setSchemas(new Resource[]{schema});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the schema resources to use for validation. Setting this property, {@link
|
||||
* #setXsdSchemaCollection(XsdSchemaCollection) xsdSchemaCollection}, {@link #setSchema(Resource) schema}, or {@link
|
||||
* #setSchemas(Resource[]) schemas} is required.
|
||||
*/
|
||||
public void setSchemas(Resource[] schemas) {
|
||||
Assert.notEmpty(schemas, "schemas must not be empty or null");
|
||||
for (Resource schema : schemas) {
|
||||
Assert.notNull(schema, "schema must not be null");
|
||||
Assert.isTrue(schema.exists(), "schema \"" + schema + "\" does not exit");
|
||||
}
|
||||
this.schemas = schemas;
|
||||
}
|
||||
/**
|
||||
* Sets the schema resources to use for validation. Setting this property, {@link
|
||||
* #setXsdSchemaCollection(XsdSchemaCollection) xsdSchemaCollection}, {@link #setSchema(Resource) schema}, or {@link
|
||||
* #setSchemas(Resource[]) schemas} is required.
|
||||
*/
|
||||
public void setSchemas(Resource[] schemas) {
|
||||
Assert.notEmpty(schemas, "schemas must not be empty or null");
|
||||
for (Resource schema : schemas) {
|
||||
Assert.notNull(schema, "schema must not be null");
|
||||
Assert.isTrue(schema.exists(), "schema \"" + schema + "\" does not exit");
|
||||
}
|
||||
this.schemas = schemas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@link XsdSchema} to use for validation. Setting this property, {@link
|
||||
* #setXsdSchemaCollection(XsdSchemaCollection) xsdSchemaCollection}, {@link #setSchema(Resource) schema}, or {@link
|
||||
* #setSchemas(Resource[]) schemas} is required.
|
||||
*
|
||||
* @param schema the xsd schema to use
|
||||
* @throws java.io.IOException in case of I/O errors
|
||||
*/
|
||||
public void setXsdSchema(XsdSchema schema) throws IOException {
|
||||
this.validator = schema.createValidator();
|
||||
}
|
||||
/**
|
||||
* Sets the {@link XsdSchema} to use for validation. Setting this property, {@link
|
||||
* #setXsdSchemaCollection(XsdSchemaCollection) xsdSchemaCollection}, {@link #setSchema(Resource) schema}, or {@link
|
||||
* #setSchemas(Resource[]) schemas} is required.
|
||||
*
|
||||
* @param schema the xsd schema to use
|
||||
* @throws java.io.IOException in case of I/O errors
|
||||
*/
|
||||
public void setXsdSchema(XsdSchema schema) throws IOException {
|
||||
this.validator = schema.createValidator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@link XsdSchemaCollection} to use for validation. Setting this property, {@link
|
||||
* #setXsdSchema(XsdSchema) xsdSchema}, {@link #setSchema(Resource) schema}, or {@link #setSchemas(Resource[])
|
||||
* schemas} is required.
|
||||
*
|
||||
* @param schemaCollection the xsd schema collection to use
|
||||
* @throws java.io.IOException in case of I/O errors
|
||||
*/
|
||||
public void setXsdSchemaCollection(XsdSchemaCollection schemaCollection) throws IOException {
|
||||
this.validator = schemaCollection.createValidator();
|
||||
}
|
||||
/**
|
||||
* Sets the {@link XsdSchemaCollection} to use for validation. Setting this property, {@link
|
||||
* #setXsdSchema(XsdSchema) xsdSchema}, {@link #setSchema(Resource) schema}, or {@link #setSchemas(Resource[])
|
||||
* schemas} is required.
|
||||
*
|
||||
* @param schemaCollection the xsd schema collection to use
|
||||
* @throws java.io.IOException in case of I/O errors
|
||||
*/
|
||||
public void setXsdSchemaCollection(XsdSchemaCollection schemaCollection) throws IOException {
|
||||
this.validator = schemaCollection.createValidator();
|
||||
}
|
||||
|
||||
/** Indicates whether the request should be validated against the schema. Default is {@code true}. */
|
||||
public void setValidateRequest(boolean validateRequest) {
|
||||
this.validateRequest = validateRequest;
|
||||
}
|
||||
/** Indicates whether the request should be validated against the schema. Default is {@code true}. */
|
||||
public void setValidateRequest(boolean validateRequest) {
|
||||
this.validateRequest = validateRequest;
|
||||
}
|
||||
|
||||
/** Indicates whether the response should be validated against the schema. Default is {@code false}. */
|
||||
public void setValidateResponse(boolean validateResponse) {
|
||||
this.validateResponse = validateResponse;
|
||||
}
|
||||
/** Indicates whether the response should be validated against the schema. Default is {@code false}. */
|
||||
public void setValidateResponse(boolean validateResponse) {
|
||||
this.validateResponse = validateResponse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
if (validator == null && !ObjectUtils.isEmpty(schemas)) {
|
||||
Assert.hasLength(schemaLanguage, "schemaLanguage is required");
|
||||
for (Resource schema : schemas) {
|
||||
Assert.isTrue(schema.exists(), "schema [" + schema + "] does not exist");
|
||||
}
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Validating using " + StringUtils.arrayToCommaDelimitedString(schemas));
|
||||
}
|
||||
validator = XmlValidatorFactory.createValidator(schemas, schemaLanguage);
|
||||
}
|
||||
Assert.notNull(validator, "Setting 'schema', 'schemas', 'xsdSchema', or 'xsdSchemaCollection' is required");
|
||||
}
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
if (validator == null && !ObjectUtils.isEmpty(schemas)) {
|
||||
Assert.hasLength(schemaLanguage, "schemaLanguage is required");
|
||||
for (Resource schema : schemas) {
|
||||
Assert.isTrue(schema.exists(), "schema [" + schema + "] does not exist");
|
||||
}
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Validating using " + StringUtils.arrayToCommaDelimitedString(schemas));
|
||||
}
|
||||
validator = XmlValidatorFactory.createValidator(schemas, schemaLanguage);
|
||||
}
|
||||
Assert.notNull(validator, "Setting 'schema', 'schemas', 'xsdSchema', or 'xsdSchemaCollection' is required");
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the request message in the given message context. Validation only occurs if {@link
|
||||
* #setValidateRequest(boolean) validateRequest} is set to {@code true}, which is the default.
|
||||
*
|
||||
* <p>Returns {@code true} if the request is valid, or {@code false} if it isn't.
|
||||
*
|
||||
* @param messageContext the message context
|
||||
* @return {@code true} if the message is valid; {@code false} otherwise
|
||||
* @see #setValidateRequest(boolean)
|
||||
*/
|
||||
@Override
|
||||
public boolean handleRequest(MessageContext messageContext) throws WebServiceClientException {
|
||||
if (validateRequest) {
|
||||
Source requestSource = getValidationRequestSource(messageContext.getRequest());
|
||||
if (requestSource != null) {
|
||||
SAXParseException[] errors;
|
||||
try {
|
||||
errors = validator.validate(requestSource);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new WebServiceIOException("Could not validate response: " + e.getMessage(), e);
|
||||
}
|
||||
if (!ObjectUtils.isEmpty(errors)) {
|
||||
return handleRequestValidationErrors(messageContext, errors);
|
||||
}
|
||||
else if (logger.isDebugEnabled()) {
|
||||
logger.debug("Request message validated");
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Validates the request message in the given message context. Validation only occurs if {@link
|
||||
* #setValidateRequest(boolean) validateRequest} is set to {@code true}, which is the default.
|
||||
*
|
||||
* <p>Returns {@code true} if the request is valid, or {@code false} if it isn't.
|
||||
*
|
||||
* @param messageContext the message context
|
||||
* @return {@code true} if the message is valid; {@code false} otherwise
|
||||
* @see #setValidateRequest(boolean)
|
||||
*/
|
||||
@Override
|
||||
public boolean handleRequest(MessageContext messageContext) throws WebServiceClientException {
|
||||
if (validateRequest) {
|
||||
Source requestSource = getValidationRequestSource(messageContext.getRequest());
|
||||
if (requestSource != null) {
|
||||
SAXParseException[] errors;
|
||||
try {
|
||||
errors = validator.validate(requestSource);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new WebServiceIOException("Could not validate response: " + e.getMessage(), e);
|
||||
}
|
||||
if (!ObjectUtils.isEmpty(errors)) {
|
||||
return handleRequestValidationErrors(messageContext, errors);
|
||||
}
|
||||
else if (logger.isDebugEnabled()) {
|
||||
logger.debug("Request message validated");
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Template method that is called when the request message contains validation errors.
|
||||
*
|
||||
* <p>Default implementation logs all errors, and throws a {@link WebServiceValidationException}. Subclasses can
|
||||
* override this method to customize this behavior.
|
||||
*
|
||||
* @param messageContext the message context
|
||||
* @param errors the validation errors
|
||||
* @return {@code true} to continue processing the request, {@code false} otherwise
|
||||
*/
|
||||
protected boolean handleRequestValidationErrors(MessageContext messageContext, SAXParseException[] errors) {
|
||||
for (SAXParseException error : errors) {
|
||||
logger.error("XML validation error on request: " + error.getMessage());
|
||||
}
|
||||
throw new WebServiceValidationException(errors);
|
||||
}
|
||||
/**
|
||||
* Template method that is called when the request message contains validation errors.
|
||||
*
|
||||
* <p>Default implementation logs all errors, and throws a {@link WebServiceValidationException}. Subclasses can
|
||||
* override this method to customize this behavior.
|
||||
*
|
||||
* @param messageContext the message context
|
||||
* @param errors the validation errors
|
||||
* @return {@code true} to continue processing the request, {@code false} otherwise
|
||||
*/
|
||||
protected boolean handleRequestValidationErrors(MessageContext messageContext, SAXParseException[] errors) {
|
||||
for (SAXParseException error : errors) {
|
||||
logger.error("XML validation error on request: " + error.getMessage());
|
||||
}
|
||||
throw new WebServiceValidationException(errors);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the response message in the given message context. Validation only occurs if {@link
|
||||
* #setValidateResponse(boolean) validateResponse} is set to {@code true}, which is <strong>not</strong> the
|
||||
* default.
|
||||
*
|
||||
* <p>Returns {@code true} if the request is valid, or {@code false} if it isn't.
|
||||
*
|
||||
* @param messageContext the message context.
|
||||
* @return {@code true} if the response is valid; {@code false} otherwise
|
||||
* @see #setValidateResponse(boolean)
|
||||
*/
|
||||
@Override
|
||||
public boolean handleResponse(MessageContext messageContext) throws WebServiceClientException {
|
||||
if (validateResponse) {
|
||||
Source responseSource = getValidationResponseSource(messageContext.getResponse());
|
||||
if (responseSource != null) {
|
||||
SAXParseException[] errors;
|
||||
try {
|
||||
errors = validator.validate(responseSource);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new WebServiceIOException("Could not validate response: " + e.getMessage(), e);
|
||||
}
|
||||
if (!ObjectUtils.isEmpty(errors)) {
|
||||
return handleResponseValidationErrors(messageContext, errors);
|
||||
}
|
||||
else if (logger.isDebugEnabled()) {
|
||||
logger.debug("Response message validated");
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Validates the response message in the given message context. Validation only occurs if {@link
|
||||
* #setValidateResponse(boolean) validateResponse} is set to {@code true}, which is <strong>not</strong> the
|
||||
* default.
|
||||
*
|
||||
* <p>Returns {@code true} if the request is valid, or {@code false} if it isn't.
|
||||
*
|
||||
* @param messageContext the message context.
|
||||
* @return {@code true} if the response is valid; {@code false} otherwise
|
||||
* @see #setValidateResponse(boolean)
|
||||
*/
|
||||
@Override
|
||||
public boolean handleResponse(MessageContext messageContext) throws WebServiceClientException {
|
||||
if (validateResponse) {
|
||||
Source responseSource = getValidationResponseSource(messageContext.getResponse());
|
||||
if (responseSource != null) {
|
||||
SAXParseException[] errors;
|
||||
try {
|
||||
errors = validator.validate(responseSource);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new WebServiceIOException("Could not validate response: " + e.getMessage(), e);
|
||||
}
|
||||
if (!ObjectUtils.isEmpty(errors)) {
|
||||
return handleResponseValidationErrors(messageContext, errors);
|
||||
}
|
||||
else if (logger.isDebugEnabled()) {
|
||||
logger.debug("Response message validated");
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Template method that is called when the response message contains validation errors.
|
||||
*
|
||||
* <p>Default implementation logs all errors, and returns {@code false}, i.e. do not cot continue to process the
|
||||
* respone interceptor chain.
|
||||
*
|
||||
* @param messageContext the message context
|
||||
* @param errors the validation errors
|
||||
* @return {@code true} to continue the reponse interceptor chain, {@code false} (the default) otherwise
|
||||
*/
|
||||
protected boolean handleResponseValidationErrors(MessageContext messageContext, SAXParseException[] errors)
|
||||
throws WebServiceValidationException {
|
||||
for (SAXParseException error : errors) {
|
||||
logger.warn("XML validation error on response: " + error.getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Template method that is called when the response message contains validation errors.
|
||||
*
|
||||
* <p>Default implementation logs all errors, and returns {@code false}, i.e. do not cot continue to process the
|
||||
* respone interceptor chain.
|
||||
*
|
||||
* @param messageContext the message context
|
||||
* @param errors the validation errors
|
||||
* @return {@code true} to continue the reponse interceptor chain, {@code false} (the default) otherwise
|
||||
*/
|
||||
protected boolean handleResponseValidationErrors(MessageContext messageContext, SAXParseException[] errors)
|
||||
throws WebServiceValidationException {
|
||||
for (SAXParseException error : errors) {
|
||||
logger.warn("XML validation error on response: " + error.getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Does nothing by default. Faults are not validated. */
|
||||
@Override
|
||||
public boolean handleFault(MessageContext messageContext) throws WebServiceClientException {
|
||||
return true;
|
||||
}
|
||||
/** Does nothing by default. Faults are not validated. */
|
||||
@Override
|
||||
public boolean handleFault(MessageContext messageContext) throws WebServiceClientException {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Does nothing by default.*/
|
||||
@Override
|
||||
@@ -268,18 +268,18 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract template method that returns the part of the request message that is to be validated.
|
||||
*
|
||||
* @param request the request message
|
||||
* @return the part of the message that is to validated, or {@code null} not to validate anything
|
||||
*/
|
||||
protected abstract Source getValidationRequestSource(WebServiceMessage request);
|
||||
* Abstract template method that returns the part of the request message that is to be validated.
|
||||
*
|
||||
* @param request the request message
|
||||
* @return the part of the message that is to validated, or {@code null} not to validate anything
|
||||
*/
|
||||
protected abstract Source getValidationRequestSource(WebServiceMessage request);
|
||||
|
||||
/**
|
||||
* Abstract template method that returns the part of the response message that is to be validated.
|
||||
*
|
||||
* @param response the response message
|
||||
* @return the part of the message that is to validated, or {@code null} not to validate anything
|
||||
*/
|
||||
protected abstract Source getValidationResponseSource(WebServiceMessage response);
|
||||
/**
|
||||
* Abstract template method that returns the part of the response message that is to be validated.
|
||||
*
|
||||
* @param response the response message
|
||||
* @return the part of the message that is to validated, or {@code null} not to validate anything
|
||||
*/
|
||||
protected abstract Source getValidationResponseSource(WebServiceMessage response);
|
||||
}
|
||||
|
||||
@@ -43,59 +43,59 @@ import org.springframework.ws.transport.WebServiceConnection;
|
||||
*/
|
||||
public interface ClientInterceptor {
|
||||
|
||||
/**
|
||||
* Processes the outgoing request message. Called after payload creation and callback invocation, but before the
|
||||
* message is sent.
|
||||
*
|
||||
* @param messageContext contains the outgoing request message
|
||||
* @return {@code true} to continue processing of the request interceptors; {@code false} to indicate
|
||||
* blocking of the request endpoint chain
|
||||
* @throws WebServiceClientException in case of errors
|
||||
* @see MessageContext#getRequest()
|
||||
*/
|
||||
boolean handleRequest(MessageContext messageContext) throws WebServiceClientException;
|
||||
|
||||
/**
|
||||
* Processes the incoming response message. Called for non-fault response messages before payload handling in the
|
||||
* {@link org.springframework.ws.client.core.WebServiceTemplate}.
|
||||
*
|
||||
* <p>Note: Will only be called if this interceptor's {@link #handleRequest} method has successfully completed.
|
||||
*
|
||||
* @param messageContext contains the outgoing request message
|
||||
* @return {@code true} to continue processing of the request interceptors; {@code false} to indicate
|
||||
* blocking of the response endpoint chain
|
||||
* @throws WebServiceClientException in case of errors
|
||||
* @see MessageContext#getResponse()
|
||||
*/
|
||||
boolean handleResponse(MessageContext messageContext) throws WebServiceClientException;
|
||||
|
||||
/**
|
||||
* Processes the incoming response fault. Called for response fault messages before payload handling in the {@link
|
||||
* org.springframework.ws.client.core.WebServiceTemplate}.
|
||||
*
|
||||
* <p>Note: Will only be called if this interceptor's {@link #handleRequest} method has successfully completed.
|
||||
*
|
||||
* @param messageContext contains the outgoing request message
|
||||
* @return {@code true} to continue processing of the request interceptors; {@code false} to indicate
|
||||
* blocking of the request endpoint chain
|
||||
* @throws WebServiceClientException in case of errors
|
||||
* @see MessageContext#getResponse()
|
||||
* @see org.springframework.ws.FaultAwareWebServiceMessage#hasFault()
|
||||
*/
|
||||
boolean handleFault(MessageContext messageContext) throws WebServiceClientException;
|
||||
/**
|
||||
* Processes the outgoing request message. Called after payload creation and callback invocation, but before the
|
||||
* message is sent.
|
||||
*
|
||||
* @param messageContext contains the outgoing request message
|
||||
* @return {@code true} to continue processing of the request interceptors; {@code false} to indicate
|
||||
* blocking of the request endpoint chain
|
||||
* @throws WebServiceClientException in case of errors
|
||||
* @see MessageContext#getRequest()
|
||||
*/
|
||||
boolean handleRequest(MessageContext messageContext) throws WebServiceClientException;
|
||||
|
||||
/**
|
||||
* Callback after completion of request and response (fault) processing. Will be called on any outcome, thus
|
||||
* Processes the incoming response message. Called for non-fault response messages before payload handling in the
|
||||
* {@link org.springframework.ws.client.core.WebServiceTemplate}.
|
||||
*
|
||||
* <p>Note: Will only be called if this interceptor's {@link #handleRequest} method has successfully completed.
|
||||
*
|
||||
* @param messageContext contains the outgoing request message
|
||||
* @return {@code true} to continue processing of the request interceptors; {@code false} to indicate
|
||||
* blocking of the response endpoint chain
|
||||
* @throws WebServiceClientException in case of errors
|
||||
* @see MessageContext#getResponse()
|
||||
*/
|
||||
boolean handleResponse(MessageContext messageContext) throws WebServiceClientException;
|
||||
|
||||
/**
|
||||
* Processes the incoming response fault. Called for response fault messages before payload handling in the {@link
|
||||
* org.springframework.ws.client.core.WebServiceTemplate}.
|
||||
*
|
||||
* <p>Note: Will only be called if this interceptor's {@link #handleRequest} method has successfully completed.
|
||||
*
|
||||
* @param messageContext contains the outgoing request message
|
||||
* @return {@code true} to continue processing of the request interceptors; {@code false} to indicate
|
||||
* blocking of the request endpoint chain
|
||||
* @throws WebServiceClientException in case of errors
|
||||
* @see MessageContext#getResponse()
|
||||
* @see org.springframework.ws.FaultAwareWebServiceMessage#hasFault()
|
||||
*/
|
||||
boolean handleFault(MessageContext messageContext) throws WebServiceClientException;
|
||||
|
||||
/**
|
||||
* Callback after completion of request and response (fault) processing. Will be called on any outcome, thus
|
||||
* allows for proper resource cleanup.
|
||||
*
|
||||
* <p>Note: Will only be called if this interceptor's {@link #handleRequest} method has successfully completed.
|
||||
*
|
||||
* @param messageContext contains both request and response messages, the response should contains a Fault
|
||||
* @param ex exception thrown on handler execution, if any
|
||||
* @throws WebServiceClientException in case of errors
|
||||
* @since 2.2
|
||||
*/
|
||||
void afterCompletion(MessageContext messageContext, Exception ex) throws WebServiceClientException;
|
||||
*
|
||||
* <p>Note: Will only be called if this interceptor's {@link #handleRequest} method has successfully completed.
|
||||
*
|
||||
* @param messageContext contains both request and response messages, the response should contains a Fault
|
||||
* @param ex exception thrown on handler execution, if any
|
||||
* @throws WebServiceClientException in case of errors
|
||||
* @since 2.2
|
||||
*/
|
||||
void afterCompletion(MessageContext messageContext, Exception ex) throws WebServiceClientException;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -41,25 +41,25 @@ import org.springframework.ws.WebServiceMessage;
|
||||
*/
|
||||
public class PayloadValidatingInterceptor extends AbstractValidatingInterceptor {
|
||||
|
||||
/**
|
||||
* Returns the part of the request message that is to be validated. Default
|
||||
*
|
||||
* @param request the request message
|
||||
* @return the part of the message that is to validated, or {@code null} not to validate anything
|
||||
*/
|
||||
@Override
|
||||
protected Source getValidationRequestSource(WebServiceMessage request) {
|
||||
return request.getPayloadSource();
|
||||
}
|
||||
/**
|
||||
* Returns the part of the request message that is to be validated. Default
|
||||
*
|
||||
* @param request the request message
|
||||
* @return the part of the message that is to validated, or {@code null} not to validate anything
|
||||
*/
|
||||
@Override
|
||||
protected Source getValidationRequestSource(WebServiceMessage request) {
|
||||
return request.getPayloadSource();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the part of the response message that is to be validated.
|
||||
*
|
||||
* @param response the response message
|
||||
* @return the part of the message that is to validated, or {@code null} not to validate anything
|
||||
*/
|
||||
@Override
|
||||
protected Source getValidationResponseSource(WebServiceMessage response) {
|
||||
return response.getPayloadSource();
|
||||
}
|
||||
/**
|
||||
* Returns the part of the response message that is to be validated.
|
||||
*
|
||||
* @param response the response message
|
||||
* @return the part of the message that is to validated, or {@code null} not to validate anything
|
||||
*/
|
||||
@Override
|
||||
protected Source getValidationResponseSource(WebServiceMessage response) {
|
||||
return response.getPayloadSource();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,27 +30,27 @@ import org.springframework.ws.client.WebServiceClientException;
|
||||
@SuppressWarnings("serial")
|
||||
public class WebServiceValidationException extends WebServiceClientException {
|
||||
|
||||
private SAXParseException[] validationErrors;
|
||||
private SAXParseException[] validationErrors;
|
||||
|
||||
/**
|
||||
* Create a new instance of the {@code WebServiceValidationException} class.
|
||||
*/
|
||||
public WebServiceValidationException(SAXParseException[] validationErrors) {
|
||||
super(createMessage(validationErrors));
|
||||
this.validationErrors = validationErrors;
|
||||
}
|
||||
/**
|
||||
* Create a new instance of the {@code WebServiceValidationException} class.
|
||||
*/
|
||||
public WebServiceValidationException(SAXParseException[] validationErrors) {
|
||||
super(createMessage(validationErrors));
|
||||
this.validationErrors = validationErrors;
|
||||
}
|
||||
|
||||
private static String createMessage(SAXParseException[] validationErrors) {
|
||||
StringBuilder builder = new StringBuilder("XML validation error on response: ");
|
||||
private static String createMessage(SAXParseException[] validationErrors) {
|
||||
StringBuilder builder = new StringBuilder("XML validation error on response: ");
|
||||
|
||||
for (SAXParseException validationError : validationErrors) {
|
||||
builder.append(validationError.getMessage());
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
for (SAXParseException validationError : validationErrors) {
|
||||
builder.append(validationError.getMessage());
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/** Returns the validation errors. */
|
||||
public SAXParseException[] getValidationErrors() {
|
||||
return validationErrors;
|
||||
}
|
||||
/** Returns the validation errors. */
|
||||
public SAXParseException[] getValidationErrors() {
|
||||
return validationErrors;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,158 +57,158 @@ import org.springframework.ws.soap.server.endpoint.mapping.SoapActionAnnotationM
|
||||
*/
|
||||
class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
|
||||
|
||||
private static final boolean dom4jPresent =
|
||||
ClassUtils.isPresent("org.dom4j.Element", AnnotationDrivenBeanDefinitionParser.class.getClassLoader());
|
||||
private static final boolean dom4jPresent =
|
||||
ClassUtils.isPresent("org.dom4j.Element", AnnotationDrivenBeanDefinitionParser.class.getClassLoader());
|
||||
|
||||
private static final boolean jaxb2Present =
|
||||
ClassUtils.isPresent("javax.xml.bind.Binder", AnnotationDrivenBeanDefinitionParser.class.getClassLoader());
|
||||
private static final boolean jaxb2Present =
|
||||
ClassUtils.isPresent("javax.xml.bind.Binder", AnnotationDrivenBeanDefinitionParser.class.getClassLoader());
|
||||
|
||||
private static final boolean jdomPresent =
|
||||
ClassUtils.isPresent("org.jdom2.Element", AnnotationDrivenBeanDefinitionParser.class.getClassLoader());
|
||||
private static final boolean jdomPresent =
|
||||
ClassUtils.isPresent("org.jdom2.Element", AnnotationDrivenBeanDefinitionParser.class.getClassLoader());
|
||||
|
||||
private static final boolean staxPresent = ClassUtils
|
||||
.isPresent("javax.xml.stream.XMLInputFactory", AnnotationDrivenBeanDefinitionParser.class.getClassLoader());
|
||||
private static final boolean staxPresent = ClassUtils
|
||||
.isPresent("javax.xml.stream.XMLInputFactory", AnnotationDrivenBeanDefinitionParser.class.getClassLoader());
|
||||
|
||||
private static final boolean xomPresent =
|
||||
ClassUtils.isPresent("nu.xom.Element", AnnotationDrivenBeanDefinitionParser.class.getClassLoader());
|
||||
private static final boolean xomPresent =
|
||||
ClassUtils.isPresent("nu.xom.Element", AnnotationDrivenBeanDefinitionParser.class.getClassLoader());
|
||||
|
||||
@Override
|
||||
public BeanDefinition parse(Element element, ParserContext parserContext) {
|
||||
Object source = parserContext.extractSource(element);
|
||||
@Override
|
||||
public BeanDefinition parse(Element element, ParserContext parserContext) {
|
||||
Object source = parserContext.extractSource(element);
|
||||
|
||||
CompositeComponentDefinition compDefinition = new CompositeComponentDefinition(element.getTagName(), source);
|
||||
parserContext.pushContainingComponent(compDefinition);
|
||||
CompositeComponentDefinition compDefinition = new CompositeComponentDefinition(element.getTagName(), source);
|
||||
parserContext.pushContainingComponent(compDefinition);
|
||||
|
||||
registerEndpointMappings(source, parserContext);
|
||||
registerEndpointMappings(source, parserContext);
|
||||
|
||||
registerEndpointAdapters(element, source, parserContext);
|
||||
registerEndpointAdapters(element, source, parserContext);
|
||||
|
||||
registerEndpointExceptionResolvers(source, parserContext);
|
||||
registerEndpointExceptionResolvers(source, parserContext);
|
||||
|
||||
parserContext.popAndRegisterContainingComponent();
|
||||
parserContext.popAndRegisterContainingComponent();
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void registerEndpointMappings(Object source, ParserContext parserContext) {
|
||||
RootBeanDefinition payloadRootMappingDef =
|
||||
createBeanDefinition(PayloadRootAnnotationMethodEndpointMapping.class, source);
|
||||
payloadRootMappingDef.getPropertyValues().add("order", 0);
|
||||
parserContext.getReaderContext().registerWithGeneratedName(payloadRootMappingDef);
|
||||
private void registerEndpointMappings(Object source, ParserContext parserContext) {
|
||||
RootBeanDefinition payloadRootMappingDef =
|
||||
createBeanDefinition(PayloadRootAnnotationMethodEndpointMapping.class, source);
|
||||
payloadRootMappingDef.getPropertyValues().add("order", 0);
|
||||
parserContext.getReaderContext().registerWithGeneratedName(payloadRootMappingDef);
|
||||
|
||||
RootBeanDefinition soapActionMappingDef =
|
||||
createBeanDefinition(SoapActionAnnotationMethodEndpointMapping.class, source);
|
||||
soapActionMappingDef.getPropertyValues().add("order", 1);
|
||||
parserContext.getReaderContext().registerWithGeneratedName(soapActionMappingDef);
|
||||
RootBeanDefinition soapActionMappingDef =
|
||||
createBeanDefinition(SoapActionAnnotationMethodEndpointMapping.class, source);
|
||||
soapActionMappingDef.getPropertyValues().add("order", 1);
|
||||
parserContext.getReaderContext().registerWithGeneratedName(soapActionMappingDef);
|
||||
|
||||
RootBeanDefinition annActionMappingDef =
|
||||
createBeanDefinition(AnnotationActionEndpointMapping.class, source);
|
||||
annActionMappingDef.getPropertyValues().add("order", 2);
|
||||
parserContext.getReaderContext().registerWithGeneratedName(annActionMappingDef);
|
||||
}
|
||||
RootBeanDefinition annActionMappingDef =
|
||||
createBeanDefinition(AnnotationActionEndpointMapping.class, source);
|
||||
annActionMappingDef.getPropertyValues().add("order", 2);
|
||||
parserContext.getReaderContext().registerWithGeneratedName(annActionMappingDef);
|
||||
}
|
||||
|
||||
private void registerEndpointAdapters(Element element, Object source, ParserContext parserContext) {
|
||||
RootBeanDefinition adapterDef = createBeanDefinition(DefaultMethodEndpointAdapter.class, source);
|
||||
private void registerEndpointAdapters(Element element, Object source, ParserContext parserContext) {
|
||||
RootBeanDefinition adapterDef = createBeanDefinition(DefaultMethodEndpointAdapter.class, source);
|
||||
|
||||
ManagedList<BeanMetadataElement> argumentResolvers = new ManagedList<BeanMetadataElement>();
|
||||
argumentResolvers.setSource(source);
|
||||
ManagedList<BeanMetadataElement> argumentResolvers = new ManagedList<BeanMetadataElement>();
|
||||
argumentResolvers.setSource(source);
|
||||
|
||||
ManagedList<BeanMetadataElement> returnValueHandlers = new ManagedList<BeanMetadataElement>();
|
||||
returnValueHandlers.setSource(source);
|
||||
ManagedList<BeanMetadataElement> returnValueHandlers = new ManagedList<BeanMetadataElement>();
|
||||
returnValueHandlers.setSource(source);
|
||||
|
||||
argumentResolvers.add(createBeanDefinition(MessageContextMethodArgumentResolver.class, source));
|
||||
argumentResolvers.add(createBeanDefinition(XPathParamMethodArgumentResolver.class, source));
|
||||
argumentResolvers.add(createBeanDefinition(SoapMethodArgumentResolver.class, source));
|
||||
argumentResolvers.add(createBeanDefinition(SoapHeaderElementMethodArgumentResolver.class, source));
|
||||
argumentResolvers.add(createBeanDefinition(MessageContextMethodArgumentResolver.class, source));
|
||||
argumentResolvers.add(createBeanDefinition(XPathParamMethodArgumentResolver.class, source));
|
||||
argumentResolvers.add(createBeanDefinition(SoapMethodArgumentResolver.class, source));
|
||||
argumentResolvers.add(createBeanDefinition(SoapHeaderElementMethodArgumentResolver.class, source));
|
||||
|
||||
RuntimeBeanReference domProcessor = createBeanReference(DomPayloadMethodProcessor.class, source, parserContext);
|
||||
argumentResolvers.add(domProcessor);
|
||||
returnValueHandlers.add(domProcessor);
|
||||
RuntimeBeanReference domProcessor = createBeanReference(DomPayloadMethodProcessor.class, source, parserContext);
|
||||
argumentResolvers.add(domProcessor);
|
||||
returnValueHandlers.add(domProcessor);
|
||||
|
||||
RuntimeBeanReference sourceProcessor =
|
||||
createBeanReference(SourcePayloadMethodProcessor.class, source, parserContext);
|
||||
argumentResolvers.add(sourceProcessor);
|
||||
returnValueHandlers.add(sourceProcessor);
|
||||
RuntimeBeanReference sourceProcessor =
|
||||
createBeanReference(SourcePayloadMethodProcessor.class, source, parserContext);
|
||||
argumentResolvers.add(sourceProcessor);
|
||||
returnValueHandlers.add(sourceProcessor);
|
||||
|
||||
if (dom4jPresent) {
|
||||
RuntimeBeanReference dom4jProcessor =
|
||||
createBeanReference(Dom4jPayloadMethodProcessor.class, source, parserContext);
|
||||
argumentResolvers.add(dom4jProcessor);
|
||||
returnValueHandlers.add(dom4jProcessor);
|
||||
}
|
||||
if (jaxb2Present) {
|
||||
RuntimeBeanReference xmlRootElementProcessor =
|
||||
createBeanReference(XmlRootElementPayloadMethodProcessor.class, source, parserContext);
|
||||
argumentResolvers.add(xmlRootElementProcessor);
|
||||
returnValueHandlers.add(xmlRootElementProcessor);
|
||||
if (dom4jPresent) {
|
||||
RuntimeBeanReference dom4jProcessor =
|
||||
createBeanReference(Dom4jPayloadMethodProcessor.class, source, parserContext);
|
||||
argumentResolvers.add(dom4jProcessor);
|
||||
returnValueHandlers.add(dom4jProcessor);
|
||||
}
|
||||
if (jaxb2Present) {
|
||||
RuntimeBeanReference xmlRootElementProcessor =
|
||||
createBeanReference(XmlRootElementPayloadMethodProcessor.class, source, parserContext);
|
||||
argumentResolvers.add(xmlRootElementProcessor);
|
||||
returnValueHandlers.add(xmlRootElementProcessor);
|
||||
|
||||
RuntimeBeanReference jaxbElementProcessor =
|
||||
createBeanReference(JaxbElementPayloadMethodProcessor.class, source, parserContext);
|
||||
argumentResolvers.add(jaxbElementProcessor);
|
||||
returnValueHandlers.add(jaxbElementProcessor);
|
||||
}
|
||||
if (jdomPresent) {
|
||||
RuntimeBeanReference jdomProcessor =
|
||||
createBeanReference(JDomPayloadMethodProcessor.class, source, parserContext);
|
||||
argumentResolvers.add(jdomProcessor);
|
||||
returnValueHandlers.add(jdomProcessor);
|
||||
}
|
||||
if (staxPresent) {
|
||||
argumentResolvers.add(createBeanDefinition(StaxPayloadMethodArgumentResolver.class, source));
|
||||
}
|
||||
if (xomPresent) {
|
||||
RuntimeBeanReference xomProcessor =
|
||||
createBeanReference(XomPayloadMethodProcessor.class, source, parserContext);
|
||||
argumentResolvers.add(xomProcessor);
|
||||
returnValueHandlers.add(xomProcessor);
|
||||
}
|
||||
if (element.hasAttribute("marshaller")) {
|
||||
RuntimeBeanReference marshallerReference = new RuntimeBeanReference(element.getAttribute("marshaller"));
|
||||
RuntimeBeanReference unmarshallerReference;
|
||||
if (element.hasAttribute("unmarshaller")) {
|
||||
unmarshallerReference = new RuntimeBeanReference(element.getAttribute("unmarshaller"));
|
||||
}
|
||||
else {
|
||||
unmarshallerReference = marshallerReference;
|
||||
}
|
||||
RuntimeBeanReference jaxbElementProcessor =
|
||||
createBeanReference(JaxbElementPayloadMethodProcessor.class, source, parserContext);
|
||||
argumentResolvers.add(jaxbElementProcessor);
|
||||
returnValueHandlers.add(jaxbElementProcessor);
|
||||
}
|
||||
if (jdomPresent) {
|
||||
RuntimeBeanReference jdomProcessor =
|
||||
createBeanReference(JDomPayloadMethodProcessor.class, source, parserContext);
|
||||
argumentResolvers.add(jdomProcessor);
|
||||
returnValueHandlers.add(jdomProcessor);
|
||||
}
|
||||
if (staxPresent) {
|
||||
argumentResolvers.add(createBeanDefinition(StaxPayloadMethodArgumentResolver.class, source));
|
||||
}
|
||||
if (xomPresent) {
|
||||
RuntimeBeanReference xomProcessor =
|
||||
createBeanReference(XomPayloadMethodProcessor.class, source, parserContext);
|
||||
argumentResolvers.add(xomProcessor);
|
||||
returnValueHandlers.add(xomProcessor);
|
||||
}
|
||||
if (element.hasAttribute("marshaller")) {
|
||||
RuntimeBeanReference marshallerReference = new RuntimeBeanReference(element.getAttribute("marshaller"));
|
||||
RuntimeBeanReference unmarshallerReference;
|
||||
if (element.hasAttribute("unmarshaller")) {
|
||||
unmarshallerReference = new RuntimeBeanReference(element.getAttribute("unmarshaller"));
|
||||
}
|
||||
else {
|
||||
unmarshallerReference = marshallerReference;
|
||||
}
|
||||
|
||||
RootBeanDefinition marshallingProcessorDef =
|
||||
createBeanDefinition(MarshallingPayloadMethodProcessor.class, source);
|
||||
marshallingProcessorDef.getPropertyValues().add("marshaller", marshallerReference);
|
||||
marshallingProcessorDef.getPropertyValues().add("unmarshaller", unmarshallerReference);
|
||||
argumentResolvers.add(marshallingProcessorDef);
|
||||
returnValueHandlers.add(marshallingProcessorDef);
|
||||
}
|
||||
RootBeanDefinition marshallingProcessorDef =
|
||||
createBeanDefinition(MarshallingPayloadMethodProcessor.class, source);
|
||||
marshallingProcessorDef.getPropertyValues().add("marshaller", marshallerReference);
|
||||
marshallingProcessorDef.getPropertyValues().add("unmarshaller", unmarshallerReference);
|
||||
argumentResolvers.add(marshallingProcessorDef);
|
||||
returnValueHandlers.add(marshallingProcessorDef);
|
||||
}
|
||||
|
||||
adapterDef.getPropertyValues().add("methodArgumentResolvers", argumentResolvers);
|
||||
adapterDef.getPropertyValues().add("methodReturnValueHandlers", returnValueHandlers);
|
||||
adapterDef.getPropertyValues().add("methodArgumentResolvers", argumentResolvers);
|
||||
adapterDef.getPropertyValues().add("methodReturnValueHandlers", returnValueHandlers);
|
||||
|
||||
parserContext.getReaderContext().registerWithGeneratedName(adapterDef);
|
||||
}
|
||||
parserContext.getReaderContext().registerWithGeneratedName(adapterDef);
|
||||
}
|
||||
|
||||
private void registerEndpointExceptionResolvers(Object source, ParserContext parserContext) {
|
||||
RootBeanDefinition annotationResolverDef =
|
||||
createBeanDefinition(SoapFaultAnnotationExceptionResolver.class, source);
|
||||
annotationResolverDef.getPropertyValues().add("order", 0);
|
||||
parserContext.getReaderContext().registerWithGeneratedName(annotationResolverDef);
|
||||
private void registerEndpointExceptionResolvers(Object source, ParserContext parserContext) {
|
||||
RootBeanDefinition annotationResolverDef =
|
||||
createBeanDefinition(SoapFaultAnnotationExceptionResolver.class, source);
|
||||
annotationResolverDef.getPropertyValues().add("order", 0);
|
||||
parserContext.getReaderContext().registerWithGeneratedName(annotationResolverDef);
|
||||
|
||||
RootBeanDefinition simpleResolverDef =
|
||||
createBeanDefinition(SimpleSoapExceptionResolver.class, source);
|
||||
simpleResolverDef.getPropertyValues().add("order", Ordered.LOWEST_PRECEDENCE);
|
||||
parserContext.getReaderContext().registerWithGeneratedName(simpleResolverDef);
|
||||
}
|
||||
RootBeanDefinition simpleResolverDef =
|
||||
createBeanDefinition(SimpleSoapExceptionResolver.class, source);
|
||||
simpleResolverDef.getPropertyValues().add("order", Ordered.LOWEST_PRECEDENCE);
|
||||
parserContext.getReaderContext().registerWithGeneratedName(simpleResolverDef);
|
||||
}
|
||||
|
||||
private RuntimeBeanReference createBeanReference(Class<?> beanClass, Object source, ParserContext parserContext) {
|
||||
RootBeanDefinition beanDefinition = createBeanDefinition(beanClass, source);
|
||||
String beanName = parserContext.getReaderContext().registerWithGeneratedName(beanDefinition);
|
||||
parserContext.registerComponent(new BeanComponentDefinition(beanDefinition, beanName));
|
||||
return new RuntimeBeanReference(beanName);
|
||||
}
|
||||
private RuntimeBeanReference createBeanReference(Class<?> beanClass, Object source, ParserContext parserContext) {
|
||||
RootBeanDefinition beanDefinition = createBeanDefinition(beanClass, source);
|
||||
String beanName = parserContext.getReaderContext().registerWithGeneratedName(beanDefinition);
|
||||
parserContext.registerComponent(new BeanComponentDefinition(beanDefinition, beanName));
|
||||
return new RuntimeBeanReference(beanName);
|
||||
}
|
||||
|
||||
private RootBeanDefinition createBeanDefinition(Class<?> beanClass, Object source) {
|
||||
RootBeanDefinition beanDefinition = new RootBeanDefinition(beanClass);
|
||||
beanDefinition.setSource(source);
|
||||
beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||
return beanDefinition;
|
||||
}
|
||||
private RootBeanDefinition createBeanDefinition(Class<?> beanClass, Object source) {
|
||||
RootBeanDefinition beanDefinition = new RootBeanDefinition(beanClass);
|
||||
beanDefinition.setSource(source);
|
||||
beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||
return beanDefinition;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,68 +42,68 @@ import org.w3c.dom.Element;
|
||||
*/
|
||||
class DynamicWsdlBeanDefinitionParser extends AbstractBeanDefinitionParser {
|
||||
|
||||
private static final boolean commonsSchemaPresent = ClassUtils.isPresent("org.apache.ws.commons.schema.XmlSchema",
|
||||
DynamicWsdlBeanDefinitionParser.class.getClassLoader());
|
||||
private static final boolean commonsSchemaPresent = ClassUtils.isPresent("org.apache.ws.commons.schema.XmlSchema",
|
||||
DynamicWsdlBeanDefinitionParser.class.getClassLoader());
|
||||
|
||||
@Override
|
||||
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
|
||||
Object source = parserContext.extractSource(element);
|
||||
@Override
|
||||
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
|
||||
Object source = parserContext.extractSource(element);
|
||||
|
||||
BeanDefinitionBuilder wsdlBuilder = BeanDefinitionBuilder.rootBeanDefinition(DefaultWsdl11Definition.class);
|
||||
wsdlBuilder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||
wsdlBuilder.getRawBeanDefinition().setSource(source);
|
||||
BeanDefinitionBuilder wsdlBuilder = BeanDefinitionBuilder.rootBeanDefinition(DefaultWsdl11Definition.class);
|
||||
wsdlBuilder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||
wsdlBuilder.getRawBeanDefinition().setSource(source);
|
||||
|
||||
addProperty(element, wsdlBuilder, "portTypeName");
|
||||
addProperty(element, wsdlBuilder, "targetNamespace");
|
||||
addProperty(element, wsdlBuilder, "requestSuffix");
|
||||
addProperty(element, wsdlBuilder, "responseSuffix");
|
||||
addProperty(element, wsdlBuilder, "faultSuffix");
|
||||
addProperty(element, wsdlBuilder, "createSoap11Binding");
|
||||
addProperty(element, wsdlBuilder, "createSoap12Binding");
|
||||
addProperty(element, wsdlBuilder, "transportUri");
|
||||
addProperty(element, wsdlBuilder, "locationUri");
|
||||
addProperty(element, wsdlBuilder, "serviceName");
|
||||
addProperty(element, wsdlBuilder, "portTypeName");
|
||||
addProperty(element, wsdlBuilder, "targetNamespace");
|
||||
addProperty(element, wsdlBuilder, "requestSuffix");
|
||||
addProperty(element, wsdlBuilder, "responseSuffix");
|
||||
addProperty(element, wsdlBuilder, "faultSuffix");
|
||||
addProperty(element, wsdlBuilder, "createSoap11Binding");
|
||||
addProperty(element, wsdlBuilder, "createSoap12Binding");
|
||||
addProperty(element, wsdlBuilder, "transportUri");
|
||||
addProperty(element, wsdlBuilder, "locationUri");
|
||||
addProperty(element, wsdlBuilder, "serviceName");
|
||||
|
||||
List<Element> schemas = DomUtils.getChildElementsByTagName(element, "xsd");
|
||||
if (commonsSchemaPresent) {
|
||||
RootBeanDefinition collectionDef = createBeanDefinition(CommonsXsdSchemaCollection.class, source);
|
||||
collectionDef.getPropertyValues().addPropertyValue("inline", "true");
|
||||
ManagedList<String> xsds = new ManagedList<String>();
|
||||
xsds.setSource(source);
|
||||
for (Element schema : schemas) {
|
||||
xsds.add(schema.getAttribute("location"));
|
||||
}
|
||||
collectionDef.getPropertyValues().addPropertyValue("xsds", xsds);
|
||||
String collectionName = parserContext.getReaderContext().registerWithGeneratedName(collectionDef);
|
||||
wsdlBuilder.addPropertyReference("schemaCollection", collectionName);
|
||||
}
|
||||
else {
|
||||
if (schemas.size() > 1) {
|
||||
throw new IllegalArgumentException(
|
||||
"Multiple <xsd/> elements requires Commons XMLSchema." +
|
||||
"Please put Commons XMLSchema on the classpath.");
|
||||
}
|
||||
RootBeanDefinition schemaDef = createBeanDefinition(SimpleXsdSchema.class, source);
|
||||
Element schema = schemas.iterator().next();
|
||||
schemaDef.getPropertyValues().addPropertyValue("xsd", schema.getAttribute("location"));
|
||||
String schemaName = parserContext.getReaderContext().registerWithGeneratedName(schemaDef);
|
||||
wsdlBuilder.addPropertyReference("schema", schemaName);
|
||||
}
|
||||
return wsdlBuilder.getBeanDefinition();
|
||||
}
|
||||
List<Element> schemas = DomUtils.getChildElementsByTagName(element, "xsd");
|
||||
if (commonsSchemaPresent) {
|
||||
RootBeanDefinition collectionDef = createBeanDefinition(CommonsXsdSchemaCollection.class, source);
|
||||
collectionDef.getPropertyValues().addPropertyValue("inline", "true");
|
||||
ManagedList<String> xsds = new ManagedList<String>();
|
||||
xsds.setSource(source);
|
||||
for (Element schema : schemas) {
|
||||
xsds.add(schema.getAttribute("location"));
|
||||
}
|
||||
collectionDef.getPropertyValues().addPropertyValue("xsds", xsds);
|
||||
String collectionName = parserContext.getReaderContext().registerWithGeneratedName(collectionDef);
|
||||
wsdlBuilder.addPropertyReference("schemaCollection", collectionName);
|
||||
}
|
||||
else {
|
||||
if (schemas.size() > 1) {
|
||||
throw new IllegalArgumentException(
|
||||
"Multiple <xsd/> elements requires Commons XMLSchema." +
|
||||
"Please put Commons XMLSchema on the classpath.");
|
||||
}
|
||||
RootBeanDefinition schemaDef = createBeanDefinition(SimpleXsdSchema.class, source);
|
||||
Element schema = schemas.iterator().next();
|
||||
schemaDef.getPropertyValues().addPropertyValue("xsd", schema.getAttribute("location"));
|
||||
String schemaName = parserContext.getReaderContext().registerWithGeneratedName(schemaDef);
|
||||
wsdlBuilder.addPropertyReference("schema", schemaName);
|
||||
}
|
||||
return wsdlBuilder.getBeanDefinition();
|
||||
}
|
||||
|
||||
private void addProperty(Element element, BeanDefinitionBuilder builder, String propertyName) {
|
||||
String propertyValue = element.getAttribute(propertyName);
|
||||
if (StringUtils.hasText(propertyValue)) {
|
||||
builder.addPropertyValue(propertyName, propertyValue);
|
||||
}
|
||||
}
|
||||
private void addProperty(Element element, BeanDefinitionBuilder builder, String propertyName) {
|
||||
String propertyValue = element.getAttribute(propertyName);
|
||||
if (StringUtils.hasText(propertyValue)) {
|
||||
builder.addPropertyValue(propertyName, propertyValue);
|
||||
}
|
||||
}
|
||||
|
||||
private RootBeanDefinition createBeanDefinition(Class<?> beanClass, Object source) {
|
||||
RootBeanDefinition beanDefinition = new RootBeanDefinition(beanClass);
|
||||
beanDefinition.setSource(source);
|
||||
beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||
return beanDefinition;
|
||||
}
|
||||
private RootBeanDefinition createBeanDefinition(Class<?> beanClass, Object source) {
|
||||
RootBeanDefinition beanDefinition = new RootBeanDefinition(beanClass);
|
||||
beanDefinition.setSource(source);
|
||||
beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||
return beanDefinition;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -44,151 +44,151 @@ import org.springframework.ws.soap.server.endpoint.interceptor.SoapActionSmartEn
|
||||
*/
|
||||
class InterceptorsBeanDefinitionParser implements BeanDefinitionParser {
|
||||
|
||||
@Override
|
||||
public BeanDefinition parse(Element element, ParserContext parserContext) {
|
||||
CompositeComponentDefinition compDefinition =
|
||||
new CompositeComponentDefinition(element.getTagName(), parserContext.extractSource(element));
|
||||
parserContext.pushContainingComponent(compDefinition);
|
||||
@Override
|
||||
public BeanDefinition parse(Element element, ParserContext parserContext) {
|
||||
CompositeComponentDefinition compDefinition =
|
||||
new CompositeComponentDefinition(element.getTagName(), parserContext.extractSource(element));
|
||||
parserContext.pushContainingComponent(compDefinition);
|
||||
|
||||
List<Element> childElements = DomUtils.getChildElements(element);
|
||||
for (Element childElement : childElements) {
|
||||
if ("bean".equals(childElement.getLocalName())) {
|
||||
RootBeanDefinition smartInterceptorDef =
|
||||
createSmartInterceptorDefinition(DelegatingSmartSoapEndpointInterceptor.class, childElement,
|
||||
parserContext);
|
||||
BeanDefinitionHolder interceptorDef = createInterceptorDefinition(parserContext, childElement);
|
||||
List<Element> childElements = DomUtils.getChildElements(element);
|
||||
for (Element childElement : childElements) {
|
||||
if ("bean".equals(childElement.getLocalName())) {
|
||||
RootBeanDefinition smartInterceptorDef =
|
||||
createSmartInterceptorDefinition(DelegatingSmartSoapEndpointInterceptor.class, childElement,
|
||||
parserContext);
|
||||
BeanDefinitionHolder interceptorDef = createInterceptorDefinition(parserContext, childElement);
|
||||
|
||||
smartInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(0, interceptorDef);
|
||||
smartInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(0, interceptorDef);
|
||||
|
||||
registerSmartInterceptor(parserContext, smartInterceptorDef);
|
||||
}
|
||||
else if ("ref".equals(childElement.getLocalName())) {
|
||||
RootBeanDefinition smartInterceptorDef =
|
||||
createSmartInterceptorDefinition(DelegatingSmartSoapEndpointInterceptor.class, childElement,
|
||||
parserContext);
|
||||
registerSmartInterceptor(parserContext, smartInterceptorDef);
|
||||
}
|
||||
else if ("ref".equals(childElement.getLocalName())) {
|
||||
RootBeanDefinition smartInterceptorDef =
|
||||
createSmartInterceptorDefinition(DelegatingSmartSoapEndpointInterceptor.class, childElement,
|
||||
parserContext);
|
||||
|
||||
BeanReference interceptorRef = createInterceptorReference(parserContext, childElement);
|
||||
BeanReference interceptorRef = createInterceptorReference(parserContext, childElement);
|
||||
|
||||
smartInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(0, interceptorRef);
|
||||
smartInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(0, interceptorRef);
|
||||
|
||||
registerSmartInterceptor(parserContext, smartInterceptorDef);
|
||||
registerSmartInterceptor(parserContext, smartInterceptorDef);
|
||||
|
||||
}
|
||||
else if ("payloadRoot".equals(childElement.getLocalName())) {
|
||||
List<Element> payloadRootChildren = DomUtils.getChildElements(childElement);
|
||||
for (Element payloadRootChild : payloadRootChildren) {
|
||||
if ("bean".equals(payloadRootChild.getLocalName())) {
|
||||
RootBeanDefinition smartInterceptorDef =
|
||||
createSmartInterceptorDefinition(PayloadRootSmartSoapEndpointInterceptor.class,
|
||||
childElement, parserContext);
|
||||
BeanDefinitionHolder interceptorDef =
|
||||
createInterceptorDefinition(parserContext, payloadRootChild);
|
||||
}
|
||||
else if ("payloadRoot".equals(childElement.getLocalName())) {
|
||||
List<Element> payloadRootChildren = DomUtils.getChildElements(childElement);
|
||||
for (Element payloadRootChild : payloadRootChildren) {
|
||||
if ("bean".equals(payloadRootChild.getLocalName())) {
|
||||
RootBeanDefinition smartInterceptorDef =
|
||||
createSmartInterceptorDefinition(PayloadRootSmartSoapEndpointInterceptor.class,
|
||||
childElement, parserContext);
|
||||
BeanDefinitionHolder interceptorDef =
|
||||
createInterceptorDefinition(parserContext, payloadRootChild);
|
||||
|
||||
String namespaceUri = childElement.getAttribute("namespaceUri");
|
||||
String localPart = childElement.getAttribute("localPart");
|
||||
String namespaceUri = childElement.getAttribute("namespaceUri");
|
||||
String localPart = childElement.getAttribute("localPart");
|
||||
|
||||
smartInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(0, interceptorDef);
|
||||
smartInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(1, namespaceUri);
|
||||
smartInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(2, localPart);
|
||||
smartInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(0, interceptorDef);
|
||||
smartInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(1, namespaceUri);
|
||||
smartInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(2, localPart);
|
||||
|
||||
registerSmartInterceptor(parserContext, smartInterceptorDef);
|
||||
}
|
||||
else if ("ref".equals(payloadRootChild.getLocalName())) {
|
||||
RootBeanDefinition smartInterceptorDef =
|
||||
createSmartInterceptorDefinition(PayloadRootSmartSoapEndpointInterceptor.class,
|
||||
childElement, parserContext);
|
||||
BeanReference interceptorRef = createInterceptorReference(parserContext, payloadRootChild);
|
||||
registerSmartInterceptor(parserContext, smartInterceptorDef);
|
||||
}
|
||||
else if ("ref".equals(payloadRootChild.getLocalName())) {
|
||||
RootBeanDefinition smartInterceptorDef =
|
||||
createSmartInterceptorDefinition(PayloadRootSmartSoapEndpointInterceptor.class,
|
||||
childElement, parserContext);
|
||||
BeanReference interceptorRef = createInterceptorReference(parserContext, payloadRootChild);
|
||||
|
||||
String namespaceUri = childElement.getAttribute("namespaceUri");
|
||||
String localPart = childElement.getAttribute("localPart");
|
||||
String namespaceUri = childElement.getAttribute("namespaceUri");
|
||||
String localPart = childElement.getAttribute("localPart");
|
||||
|
||||
smartInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(0, interceptorRef);
|
||||
smartInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(1, namespaceUri);
|
||||
smartInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(2, localPart);
|
||||
smartInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(0, interceptorRef);
|
||||
smartInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(1, namespaceUri);
|
||||
smartInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(2, localPart);
|
||||
|
||||
registerSmartInterceptor(parserContext, smartInterceptorDef);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ("soapAction".equals(childElement.getLocalName())) {
|
||||
List<Element> soapActionChildren = DomUtils.getChildElements(childElement);
|
||||
for (Element soapActionChild : soapActionChildren) {
|
||||
if ("bean".equals(soapActionChild.getLocalName())) {
|
||||
RootBeanDefinition smartInterceptorDef =
|
||||
createSmartInterceptorDefinition(SoapActionSmartEndpointInterceptor.class, childElement,
|
||||
parserContext);
|
||||
BeanDefinitionHolder interceptorDef =
|
||||
createInterceptorDefinition(parserContext, soapActionChild);
|
||||
registerSmartInterceptor(parserContext, smartInterceptorDef);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ("soapAction".equals(childElement.getLocalName())) {
|
||||
List<Element> soapActionChildren = DomUtils.getChildElements(childElement);
|
||||
for (Element soapActionChild : soapActionChildren) {
|
||||
if ("bean".equals(soapActionChild.getLocalName())) {
|
||||
RootBeanDefinition smartInterceptorDef =
|
||||
createSmartInterceptorDefinition(SoapActionSmartEndpointInterceptor.class, childElement,
|
||||
parserContext);
|
||||
BeanDefinitionHolder interceptorDef =
|
||||
createInterceptorDefinition(parserContext, soapActionChild);
|
||||
|
||||
String soapAction = childElement.getAttribute("value");
|
||||
String soapAction = childElement.getAttribute("value");
|
||||
|
||||
smartInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(0, interceptorDef);
|
||||
smartInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(1, soapAction);
|
||||
smartInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(0, interceptorDef);
|
||||
smartInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(1, soapAction);
|
||||
|
||||
registerSmartInterceptor(parserContext, smartInterceptorDef);
|
||||
}
|
||||
else if ("ref".equals(soapActionChild.getLocalName())) {
|
||||
RootBeanDefinition smartInterceptorDef =
|
||||
createSmartInterceptorDefinition(SoapActionSmartEndpointInterceptor.class, childElement,
|
||||
parserContext);
|
||||
BeanReference interceptorRef = createInterceptorReference(parserContext, soapActionChild);
|
||||
registerSmartInterceptor(parserContext, smartInterceptorDef);
|
||||
}
|
||||
else if ("ref".equals(soapActionChild.getLocalName())) {
|
||||
RootBeanDefinition smartInterceptorDef =
|
||||
createSmartInterceptorDefinition(SoapActionSmartEndpointInterceptor.class, childElement,
|
||||
parserContext);
|
||||
BeanReference interceptorRef = createInterceptorReference(parserContext, soapActionChild);
|
||||
|
||||
String soapAction = childElement.getAttribute("value");
|
||||
String soapAction = childElement.getAttribute("value");
|
||||
|
||||
smartInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(0, interceptorRef);
|
||||
smartInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(1, soapAction);
|
||||
smartInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(0, interceptorRef);
|
||||
smartInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(1, soapAction);
|
||||
|
||||
registerSmartInterceptor(parserContext, smartInterceptorDef);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
registerSmartInterceptor(parserContext, smartInterceptorDef);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
parserContext.popAndRegisterContainingComponent();
|
||||
return null;
|
||||
}
|
||||
parserContext.popAndRegisterContainingComponent();
|
||||
return null;
|
||||
}
|
||||
|
||||
private void registerSmartInterceptor(ParserContext parserContext, RootBeanDefinition smartInterceptorDef) {
|
||||
String mappedInterceptorName = parserContext.getReaderContext().registerWithGeneratedName(smartInterceptorDef);
|
||||
parserContext.registerComponent(new BeanComponentDefinition(smartInterceptorDef, mappedInterceptorName));
|
||||
}
|
||||
private void registerSmartInterceptor(ParserContext parserContext, RootBeanDefinition smartInterceptorDef) {
|
||||
String mappedInterceptorName = parserContext.getReaderContext().registerWithGeneratedName(smartInterceptorDef);
|
||||
parserContext.registerComponent(new BeanComponentDefinition(smartInterceptorDef, mappedInterceptorName));
|
||||
}
|
||||
|
||||
private BeanDefinitionHolder createInterceptorDefinition(ParserContext parserContext, Element element) {
|
||||
BeanDefinitionHolder interceptorDef = parserContext.getDelegate().parseBeanDefinitionElement(element);
|
||||
interceptorDef = parserContext.getDelegate().decorateBeanDefinitionIfRequired(element, interceptorDef);
|
||||
return interceptorDef;
|
||||
}
|
||||
private BeanDefinitionHolder createInterceptorDefinition(ParserContext parserContext, Element element) {
|
||||
BeanDefinitionHolder interceptorDef = parserContext.getDelegate().parseBeanDefinitionElement(element);
|
||||
interceptorDef = parserContext.getDelegate().decorateBeanDefinitionIfRequired(element, interceptorDef);
|
||||
return interceptorDef;
|
||||
}
|
||||
|
||||
private BeanReference createInterceptorReference(ParserContext parserContext, Element element) {
|
||||
// A generic reference to any name of any bean.
|
||||
String refName = element.getAttribute("bean");
|
||||
if (!StringUtils.hasLength(refName)) {
|
||||
// A reference to the id of another bean in the same XML file.
|
||||
refName = element.getAttribute("local");
|
||||
if (!StringUtils.hasLength(refName)) {
|
||||
error(parserContext, "Either 'bean' or 'local' is required for <ref> element", element);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (!StringUtils.hasText(refName)) {
|
||||
error(parserContext, "<ref> element contains empty target attribute", element);
|
||||
return null;
|
||||
}
|
||||
RuntimeBeanReference ref = new RuntimeBeanReference(refName);
|
||||
ref.setSource(parserContext.extractSource(element));
|
||||
return ref;
|
||||
}
|
||||
private BeanReference createInterceptorReference(ParserContext parserContext, Element element) {
|
||||
// A generic reference to any name of any bean.
|
||||
String refName = element.getAttribute("bean");
|
||||
if (!StringUtils.hasLength(refName)) {
|
||||
// A reference to the id of another bean in the same XML file.
|
||||
refName = element.getAttribute("local");
|
||||
if (!StringUtils.hasLength(refName)) {
|
||||
error(parserContext, "Either 'bean' or 'local' is required for <ref> element", element);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (!StringUtils.hasText(refName)) {
|
||||
error(parserContext, "<ref> element contains empty target attribute", element);
|
||||
return null;
|
||||
}
|
||||
RuntimeBeanReference ref = new RuntimeBeanReference(refName);
|
||||
ref.setSource(parserContext.extractSource(element));
|
||||
return ref;
|
||||
}
|
||||
|
||||
private RootBeanDefinition createSmartInterceptorDefinition(Class<? extends SmartEndpointInterceptor> interceptorClass,
|
||||
Element element,
|
||||
ParserContext parserContext) {
|
||||
RootBeanDefinition smartInterceptorDef = new RootBeanDefinition(interceptorClass);
|
||||
smartInterceptorDef.setSource(parserContext.extractSource(element));
|
||||
smartInterceptorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||
return smartInterceptorDef;
|
||||
}
|
||||
private RootBeanDefinition createSmartInterceptorDefinition(Class<? extends SmartEndpointInterceptor> interceptorClass,
|
||||
Element element,
|
||||
ParserContext parserContext) {
|
||||
RootBeanDefinition smartInterceptorDef = new RootBeanDefinition(interceptorClass);
|
||||
smartInterceptorDef.setSource(parserContext.extractSource(element));
|
||||
smartInterceptorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||
return smartInterceptorDef;
|
||||
}
|
||||
|
||||
private void error(ParserContext parserContext, String message, Object source) {
|
||||
parserContext.getDelegate().getReaderContext().error(message, source);
|
||||
}
|
||||
private void error(ParserContext parserContext, String message, Object source) {
|
||||
parserContext.getDelegate().getReaderContext().error(message, source);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,39 +34,39 @@ import org.w3c.dom.Element;
|
||||
@Deprecated
|
||||
class MarshallingEndpointsBeanDefinitionParser extends AbstractSimpleBeanDefinitionParser {
|
||||
|
||||
private static final String GENERIC_MARSHALLING_METHOD_ENDPOINT_ADAPTER_CLASS_NAME =
|
||||
"org.springframework.ws.server.endpoint.adapter.GenericMarshallingMethodEndpointAdapter";
|
||||
private static final String GENERIC_MARSHALLING_METHOD_ENDPOINT_ADAPTER_CLASS_NAME =
|
||||
"org.springframework.ws.server.endpoint.adapter.GenericMarshallingMethodEndpointAdapter";
|
||||
|
||||
private static final boolean genericAdapterPresent =
|
||||
ClassUtils.isPresent(GENERIC_MARSHALLING_METHOD_ENDPOINT_ADAPTER_CLASS_NAME,
|
||||
MarshallingEndpointsBeanDefinitionParser.class.getClassLoader());
|
||||
private static final boolean genericAdapterPresent =
|
||||
ClassUtils.isPresent(GENERIC_MARSHALLING_METHOD_ENDPOINT_ADAPTER_CLASS_NAME,
|
||||
MarshallingEndpointsBeanDefinitionParser.class.getClassLoader());
|
||||
|
||||
private static final String MARSHALLING_METHOD_ENDPOINT_ADAPTER_CLASS_NAME =
|
||||
"org.springframework.ws.server.endpoint.adapter.MarshallingMethodEndpointAdapter";
|
||||
private static final String MARSHALLING_METHOD_ENDPOINT_ADAPTER_CLASS_NAME =
|
||||
"org.springframework.ws.server.endpoint.adapter.MarshallingMethodEndpointAdapter";
|
||||
|
||||
@Override
|
||||
protected boolean shouldGenerateIdAsFallback() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
protected boolean shouldGenerateIdAsFallback() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBeanClassName(Element element) {
|
||||
if (genericAdapterPresent) {
|
||||
return GENERIC_MARSHALLING_METHOD_ENDPOINT_ADAPTER_CLASS_NAME;
|
||||
}
|
||||
return MARSHALLING_METHOD_ENDPOINT_ADAPTER_CLASS_NAME;
|
||||
}
|
||||
@Override
|
||||
protected String getBeanClassName(Element element) {
|
||||
if (genericAdapterPresent) {
|
||||
return GENERIC_MARSHALLING_METHOD_ENDPOINT_ADAPTER_CLASS_NAME;
|
||||
}
|
||||
return MARSHALLING_METHOD_ENDPOINT_ADAPTER_CLASS_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder beanDefinitionBuilder) {
|
||||
String marshallerName = element.getAttribute("marshaller");
|
||||
if (StringUtils.hasText(marshallerName)) {
|
||||
beanDefinitionBuilder.addPropertyReference("marshaller", marshallerName);
|
||||
}
|
||||
String unmarshallerName = element.getAttribute("unmarshaller");
|
||||
if (StringUtils.hasText(unmarshallerName)) {
|
||||
beanDefinitionBuilder.addPropertyReference("unmarshaller", unmarshallerName);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder beanDefinitionBuilder) {
|
||||
String marshallerName = element.getAttribute("marshaller");
|
||||
if (StringUtils.hasText(marshallerName)) {
|
||||
beanDefinitionBuilder.addPropertyReference("marshaller", marshallerName);
|
||||
}
|
||||
String unmarshallerName = element.getAttribute("unmarshaller");
|
||||
if (StringUtils.hasText(unmarshallerName)) {
|
||||
beanDefinitionBuilder.addPropertyReference("unmarshaller", unmarshallerName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,39 +33,39 @@ import org.w3c.dom.Element;
|
||||
*/
|
||||
class StaticWsdlBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
|
||||
|
||||
private static final String CLASS_NAME = "org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition";
|
||||
private static final String CLASS_NAME = "org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition";
|
||||
|
||||
@Override
|
||||
protected boolean shouldGenerateIdAsFallback() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
protected boolean shouldGenerateIdAsFallback() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBeanClassName(Element element) {
|
||||
return CLASS_NAME;
|
||||
}
|
||||
@Override
|
||||
protected String getBeanClassName(Element element) {
|
||||
return CLASS_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String resolveId(Element element, AbstractBeanDefinition definition, ParserContext parserContext)
|
||||
throws BeanDefinitionStoreException {
|
||||
String id = element.getAttribute(ID_ATTRIBUTE);
|
||||
if (StringUtils.hasLength(id)) {
|
||||
return id;
|
||||
}
|
||||
String location = element.getAttribute("location");
|
||||
if (StringUtils.hasLength(location)) {
|
||||
String filename = StringUtils.stripFilenameExtension(StringUtils.getFilename(location));
|
||||
if (StringUtils.hasLength(filename)) {
|
||||
return filename;
|
||||
}
|
||||
}
|
||||
return parserContext.getReaderContext().generateBeanName(definition);
|
||||
}
|
||||
@Override
|
||||
protected String resolveId(Element element, AbstractBeanDefinition definition, ParserContext parserContext)
|
||||
throws BeanDefinitionStoreException {
|
||||
String id = element.getAttribute(ID_ATTRIBUTE);
|
||||
if (StringUtils.hasLength(id)) {
|
||||
return id;
|
||||
}
|
||||
String location = element.getAttribute("location");
|
||||
if (StringUtils.hasLength(location)) {
|
||||
String filename = StringUtils.stripFilenameExtension(StringUtils.getFilename(location));
|
||||
if (StringUtils.hasLength(filename)) {
|
||||
return filename;
|
||||
}
|
||||
}
|
||||
return parserContext.getReaderContext().generateBeanName(definition);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder beanDefinitionBuilder) {
|
||||
String location = element.getAttribute("location");
|
||||
beanDefinitionBuilder.addPropertyValue("wsdl", location);
|
||||
}
|
||||
@Override
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder beanDefinitionBuilder) {
|
||||
String location = element.getAttribute("location");
|
||||
beanDefinitionBuilder.addPropertyValue("wsdl", location);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,14 +27,14 @@ import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
|
||||
*/
|
||||
public class WebServicesNamespaceHandler extends NamespaceHandlerSupport {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void init() {
|
||||
registerBeanDefinitionParser("annotation-driven", new AnnotationDrivenBeanDefinitionParser());
|
||||
registerBeanDefinitionParser("interceptors", new InterceptorsBeanDefinitionParser());
|
||||
registerBeanDefinitionParser("static-wsdl", new StaticWsdlBeanDefinitionParser());
|
||||
registerBeanDefinitionParser("dynamic-wsdl", new DynamicWsdlBeanDefinitionParser());
|
||||
registerBeanDefinitionParser("marshalling-endpoints", new MarshallingEndpointsBeanDefinitionParser());
|
||||
registerBeanDefinitionParser("xpath-endpoints", new XPathEndpointsBeanDefinitionParser());
|
||||
}
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void init() {
|
||||
registerBeanDefinitionParser("annotation-driven", new AnnotationDrivenBeanDefinitionParser());
|
||||
registerBeanDefinitionParser("interceptors", new InterceptorsBeanDefinitionParser());
|
||||
registerBeanDefinitionParser("static-wsdl", new StaticWsdlBeanDefinitionParser());
|
||||
registerBeanDefinitionParser("dynamic-wsdl", new DynamicWsdlBeanDefinitionParser());
|
||||
registerBeanDefinitionParser("marshalling-endpoints", new MarshallingEndpointsBeanDefinitionParser());
|
||||
registerBeanDefinitionParser("xpath-endpoints", new XPathEndpointsBeanDefinitionParser());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,31 +36,31 @@ import org.w3c.dom.Element;
|
||||
@Deprecated
|
||||
class XPathEndpointsBeanDefinitionParser extends AbstractSimpleBeanDefinitionParser {
|
||||
|
||||
private static final String XPATH_PARAM_ANNOTATION_METHOD_ENDPOINT_ADAPTER_CLASS_NAME =
|
||||
"org.springframework.ws.server.endpoint.adapter.XPathParamAnnotationMethodEndpointAdapter";
|
||||
private static final String XPATH_PARAM_ANNOTATION_METHOD_ENDPOINT_ADAPTER_CLASS_NAME =
|
||||
"org.springframework.ws.server.endpoint.adapter.XPathParamAnnotationMethodEndpointAdapter";
|
||||
|
||||
@Override
|
||||
protected boolean shouldGenerateIdAsFallback() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
protected boolean shouldGenerateIdAsFallback() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBeanClassName(Element element) {
|
||||
return XPATH_PARAM_ANNOTATION_METHOD_ENDPOINT_ADAPTER_CLASS_NAME;
|
||||
}
|
||||
@Override
|
||||
protected String getBeanClassName(Element element) {
|
||||
return XPATH_PARAM_ANNOTATION_METHOD_ENDPOINT_ADAPTER_CLASS_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder beanDefinitionBuilder) {
|
||||
List<Element> namespaceElements = DomUtils.getChildElementsByTagName(element, "namespace");
|
||||
if (!namespaceElements.isEmpty()) {
|
||||
Properties namespaces = new Properties();
|
||||
for (Element namespaceElement : namespaceElements) {
|
||||
String prefix = namespaceElement.getAttribute("prefix");
|
||||
String uri = namespaceElement.getAttribute("uri");
|
||||
namespaces.setProperty(prefix, uri);
|
||||
}
|
||||
beanDefinitionBuilder.addPropertyValue("namespaces", namespaces);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder beanDefinitionBuilder) {
|
||||
List<Element> namespaceElements = DomUtils.getChildElementsByTagName(element, "namespace");
|
||||
if (!namespaceElements.isEmpty()) {
|
||||
Properties namespaces = new Properties();
|
||||
for (Element namespaceElement : namespaceElements) {
|
||||
String prefix = namespaceElement.getAttribute("prefix");
|
||||
String uri = namespaceElement.getAttribute("uri");
|
||||
namespaces.setProperty(prefix, uri);
|
||||
}
|
||||
beanDefinitionBuilder.addPropertyValue("namespaces", namespaces);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -48,17 +48,17 @@ import org.springframework.context.annotation.Import;
|
||||
* @ComponentScan(basePackageClasses = { MyConfiguration.class })
|
||||
* public class MyConfiguration extends WsConfigurerAdapter {
|
||||
*
|
||||
* @Override
|
||||
* public void addInterceptors(List<EndpointInterceptor> interceptors) {
|
||||
* interceptors.add(new MyInterceptor());
|
||||
* }
|
||||
* @Override
|
||||
* public void addInterceptors(List<EndpointInterceptor> interceptors) {
|
||||
* interceptors.add(new MyInterceptor());
|
||||
* }
|
||||
*
|
||||
* @Override
|
||||
* public void addArgumentResolvers(List<MethodArgumentResolver> argumentResolvers) {
|
||||
* argumentResolvers.add(new MyArgumentResolver());
|
||||
* }
|
||||
* @Override
|
||||
* public void addArgumentResolvers(List<MethodArgumentResolver> argumentResolvers) {
|
||||
* argumentResolvers.add(new MyArgumentResolver());
|
||||
* }
|
||||
*
|
||||
* // More overridden methods ...
|
||||
* // More overridden methods ...
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
@@ -72,17 +72,17 @@ import org.springframework.context.annotation.Import;
|
||||
* @ComponentScan(basePackageClasses = { MyConfiguration.class })
|
||||
* public class MyConfiguration extends WsConfigurationSupport {
|
||||
*
|
||||
* @Override
|
||||
* public void addInterceptors(List<EndpointInterceptor> interceptors) {
|
||||
* interceptors.add(new MyInterceptor());
|
||||
* }
|
||||
* @Override
|
||||
* public void addInterceptors(List<EndpointInterceptor> interceptors) {
|
||||
* interceptors.add(new MyInterceptor());
|
||||
* }
|
||||
*
|
||||
* @Bean
|
||||
* @Override
|
||||
* public DefaultMethodEndpointAdapter defaultMethodEndpointAdapter() {
|
||||
* @Bean
|
||||
* @Override
|
||||
* public DefaultMethodEndpointAdapter defaultMethodEndpointAdapter() {
|
||||
* // Create or delegate to "super" to create and
|
||||
* // customize properties of DefaultMethodEndpointAdapter
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -50,28 +50,28 @@ import org.springframework.ws.soap.server.endpoint.mapping.SoapActionAnnotationM
|
||||
*
|
||||
* <p>This class registers the following {@link EndpointMapping}s:
|
||||
* <ul>
|
||||
* <li>{@link PayloadRootAnnotationMethodEndpointMapping}
|
||||
* ordered at 0 for mapping requests to {@link PayloadRoot @PayloadRoot} annotated
|
||||
* controller methods.
|
||||
* <li>{@link SoapActionAnnotationMethodEndpointMapping}
|
||||
* ordered at 1 for mapping requests to {@link SoapAction @SoapAction} annotated
|
||||
* controller methods.
|
||||
* <li>{@link AnnotationActionEndpointMapping}
|
||||
* ordered at 2 for mapping requests to {@link Action @Action} annotated
|
||||
* controller methods.
|
||||
* <li>{@link PayloadRootAnnotationMethodEndpointMapping}
|
||||
* ordered at 0 for mapping requests to {@link PayloadRoot @PayloadRoot} annotated
|
||||
* controller methods.
|
||||
* <li>{@link SoapActionAnnotationMethodEndpointMapping}
|
||||
* ordered at 1 for mapping requests to {@link SoapAction @SoapAction} annotated
|
||||
* controller methods.
|
||||
* <li>{@link AnnotationActionEndpointMapping}
|
||||
* ordered at 2 for mapping requests to {@link Action @Action} annotated
|
||||
* controller methods.
|
||||
* </ul>
|
||||
*
|
||||
* <p>Registers one {@link EndpointAdapter}:
|
||||
* <ul>
|
||||
* <li>{@link DefaultMethodEndpointAdapter}
|
||||
* for processing requests with annotated endpoint methods.
|
||||
* <li>{@link DefaultMethodEndpointAdapter}
|
||||
* for processing requests with annotated endpoint methods.
|
||||
* </ul>
|
||||
*
|
||||
* <p>Registers the following {@link EndpointExceptionResolver}s:
|
||||
* <ul>
|
||||
* <li>{@link SoapFaultAnnotationExceptionResolver} for handling exceptions
|
||||
* annotated with {@link SoapFault @SoapFault}.
|
||||
* <li>{@link SimpleSoapExceptionResolver} for creating default exceptions.
|
||||
* <li>{@link SoapFaultAnnotationExceptionResolver} for handling exceptions
|
||||
* annotated with {@link SoapFault @SoapFault}.
|
||||
* <li>{@link SimpleSoapExceptionResolver} for creating default exceptions.
|
||||
* </ul>
|
||||
*
|
||||
* @see EnableWs
|
||||
@@ -149,8 +149,8 @@ public class WsConfigurationSupport {
|
||||
* through annotated endpoint methods. Consider overriding one of these
|
||||
* other more fine-grained methods:
|
||||
* <ul>
|
||||
* <li>{@link #addArgumentResolvers(List)} for adding custom argument resolvers.
|
||||
* <li>{@link #addReturnValueHandlers(List)} for adding custom return value handlers.
|
||||
* <li>{@link #addArgumentResolvers(List)} for adding custom argument resolvers.
|
||||
* <li>{@link #addReturnValueHandlers(List)} for adding custom return value handlers.
|
||||
* </ul>
|
||||
*/
|
||||
@Bean
|
||||
@@ -174,7 +174,7 @@ public class WsConfigurationSupport {
|
||||
* Add custom {@link MethodArgumentResolver}s to use in addition to
|
||||
* the ones registered by default.
|
||||
* @param argumentResolvers the list of custom converters;
|
||||
* initially an empty list.
|
||||
* initially an empty list.
|
||||
*/
|
||||
protected void addArgumentResolvers(List<MethodArgumentResolver> argumentResolvers) {
|
||||
}
|
||||
|
||||
@@ -29,41 +29,41 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
public abstract class AbstractMessageContext implements MessageContext {
|
||||
|
||||
/**
|
||||
* Keys are {@code Strings}, values are {@code Objects}. Lazily initialized by
|
||||
* {@code getProperties()}.
|
||||
*/
|
||||
private Map<String, Object> properties;
|
||||
/**
|
||||
* Keys are {@code Strings}, values are {@code Objects}. Lazily initialized by
|
||||
* {@code getProperties()}.
|
||||
*/
|
||||
private Map<String, Object> properties;
|
||||
|
||||
@Override
|
||||
public boolean containsProperty(String name) {
|
||||
return getProperties().containsKey(name);
|
||||
}
|
||||
@Override
|
||||
public boolean containsProperty(String name) {
|
||||
return getProperties().containsKey(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getProperty(String name) {
|
||||
return getProperties().get(name);
|
||||
}
|
||||
@Override
|
||||
public Object getProperty(String name) {
|
||||
return getProperties().get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getPropertyNames() {
|
||||
return StringUtils.toStringArray(getProperties().keySet());
|
||||
}
|
||||
@Override
|
||||
public String[] getPropertyNames() {
|
||||
return StringUtils.toStringArray(getProperties().keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeProperty(String name) {
|
||||
getProperties().remove(name);
|
||||
}
|
||||
@Override
|
||||
public void removeProperty(String name) {
|
||||
getProperties().remove(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProperty(String name, Object value) {
|
||||
getProperties().put(name, value);
|
||||
}
|
||||
@Override
|
||||
public void setProperty(String name, Object value) {
|
||||
getProperties().put(name, value);
|
||||
}
|
||||
|
||||
private Map<String, Object> getProperties() {
|
||||
if (properties == null) {
|
||||
properties = new HashMap<String, Object>();
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
private Map<String, Object> getProperties() {
|
||||
if (properties == null) {
|
||||
properties = new HashMap<String, Object>();
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,70 +31,70 @@ import org.springframework.ws.WebServiceMessageFactory;
|
||||
*/
|
||||
public class DefaultMessageContext extends AbstractMessageContext {
|
||||
|
||||
private final WebServiceMessageFactory messageFactory;
|
||||
private final WebServiceMessageFactory messageFactory;
|
||||
|
||||
private final WebServiceMessage request;
|
||||
private final WebServiceMessage request;
|
||||
|
||||
private WebServiceMessage response;
|
||||
private WebServiceMessage response;
|
||||
|
||||
/** Construct a new, empty instance of the {@code DefaultMessageContext} with the given message factory. */
|
||||
public DefaultMessageContext(WebServiceMessageFactory messageFactory) {
|
||||
this(messageFactory.createWebServiceMessage(), messageFactory);
|
||||
}
|
||||
/** Construct a new, empty instance of the {@code DefaultMessageContext} with the given message factory. */
|
||||
public DefaultMessageContext(WebServiceMessageFactory messageFactory) {
|
||||
this(messageFactory.createWebServiceMessage(), messageFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new instance of the {@code DefaultMessageContext} with the given request message and message
|
||||
* factory.
|
||||
*/
|
||||
public DefaultMessageContext(WebServiceMessage request, WebServiceMessageFactory messageFactory) {
|
||||
Assert.notNull(request, "request must not be null");
|
||||
Assert.notNull(messageFactory, "messageFactory must not be null");
|
||||
this.request = request;
|
||||
this.messageFactory = messageFactory;
|
||||
}
|
||||
/**
|
||||
* Construct a new instance of the {@code DefaultMessageContext} with the given request message and message
|
||||
* factory.
|
||||
*/
|
||||
public DefaultMessageContext(WebServiceMessage request, WebServiceMessageFactory messageFactory) {
|
||||
Assert.notNull(request, "request must not be null");
|
||||
Assert.notNull(messageFactory, "messageFactory must not be null");
|
||||
this.request = request;
|
||||
this.messageFactory = messageFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebServiceMessage getRequest() {
|
||||
return request;
|
||||
}
|
||||
@Override
|
||||
public WebServiceMessage getRequest() {
|
||||
return request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasResponse() {
|
||||
return response != null;
|
||||
}
|
||||
@Override
|
||||
public boolean hasResponse() {
|
||||
return response != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebServiceMessage getResponse() {
|
||||
if (response == null) {
|
||||
response = messageFactory.createWebServiceMessage();
|
||||
}
|
||||
return response;
|
||||
}
|
||||
@Override
|
||||
public WebServiceMessage getResponse() {
|
||||
if (response == null) {
|
||||
response = messageFactory.createWebServiceMessage();
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResponse(WebServiceMessage response) {
|
||||
checkForResponse();
|
||||
this.response = response;
|
||||
}
|
||||
@Override
|
||||
public void setResponse(WebServiceMessage response) {
|
||||
checkForResponse();
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearResponse() {
|
||||
response = null;
|
||||
}
|
||||
@Override
|
||||
public void clearResponse() {
|
||||
response = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readResponse(InputStream inputStream) throws IOException {
|
||||
checkForResponse();
|
||||
response = messageFactory.createWebServiceMessage(inputStream);
|
||||
}
|
||||
@Override
|
||||
public void readResponse(InputStream inputStream) throws IOException {
|
||||
checkForResponse();
|
||||
response = messageFactory.createWebServiceMessage(inputStream);
|
||||
}
|
||||
|
||||
public WebServiceMessageFactory getMessageFactory() {
|
||||
return messageFactory;
|
||||
}
|
||||
public WebServiceMessageFactory getMessageFactory() {
|
||||
return messageFactory;
|
||||
}
|
||||
|
||||
private void checkForResponse() throws IllegalStateException {
|
||||
if (response != null) {
|
||||
throw new IllegalStateException("Response message already created");
|
||||
}
|
||||
}
|
||||
private void checkForResponse() throws IllegalStateException {
|
||||
if (response != null) {
|
||||
throw new IllegalStateException("Response message already created");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,90 +36,90 @@ import org.springframework.ws.server.EndpointInterceptor;
|
||||
*/
|
||||
public interface MessageContext {
|
||||
|
||||
/**
|
||||
* Returns the request message.
|
||||
*
|
||||
* @return the request message
|
||||
*/
|
||||
WebServiceMessage getRequest();
|
||||
/**
|
||||
* Returns the request message.
|
||||
*
|
||||
* @return the request message
|
||||
*/
|
||||
WebServiceMessage getRequest();
|
||||
|
||||
/**
|
||||
* Indicates whether this context has a response.
|
||||
*
|
||||
* @return {@code true} if this context has a response; {@code false} otherwise
|
||||
*/
|
||||
boolean hasResponse();
|
||||
/**
|
||||
* Indicates whether this context has a response.
|
||||
*
|
||||
* @return {@code true} if this context has a response; {@code false} otherwise
|
||||
*/
|
||||
boolean hasResponse();
|
||||
|
||||
/**
|
||||
* Returns the response message. Creates a new response if no response is present.
|
||||
*
|
||||
* @return the response message
|
||||
* @see #hasResponse()
|
||||
*/
|
||||
WebServiceMessage getResponse();
|
||||
/**
|
||||
* Returns the response message. Creates a new response if no response is present.
|
||||
*
|
||||
* @return the response message
|
||||
* @see #hasResponse()
|
||||
*/
|
||||
WebServiceMessage getResponse();
|
||||
|
||||
/**
|
||||
* Sets the response message.
|
||||
*
|
||||
* @param response the response message
|
||||
* @throws IllegalStateException if a response has already been created
|
||||
* @since 1.5.0
|
||||
*/
|
||||
void setResponse(WebServiceMessage response);
|
||||
/**
|
||||
* Sets the response message.
|
||||
*
|
||||
* @param response the response message
|
||||
* @throws IllegalStateException if a response has already been created
|
||||
* @since 1.5.0
|
||||
*/
|
||||
void setResponse(WebServiceMessage response);
|
||||
|
||||
/**
|
||||
* Removes the response message, if any.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
void clearResponse();
|
||||
/**
|
||||
* Removes the response message, if any.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
void clearResponse();
|
||||
|
||||
/**
|
||||
* Reads a response message from the given input stream.
|
||||
*
|
||||
* @param inputStream the stream to read the response from
|
||||
* @throws IOException in case of I/O errors
|
||||
* @throws IllegalStateException if a response has already been created
|
||||
*/
|
||||
void readResponse(InputStream inputStream) throws IOException;
|
||||
/**
|
||||
* Reads a response message from the given input stream.
|
||||
*
|
||||
* @param inputStream the stream to read the response from
|
||||
* @throws IOException in case of I/O errors
|
||||
* @throws IllegalStateException if a response has already been created
|
||||
*/
|
||||
void readResponse(InputStream inputStream) throws IOException;
|
||||
|
||||
/**
|
||||
* Sets the name and value of a property associated with the {@code MessageContext}. If the
|
||||
* {@code MessageContext} contains a value of the same property, the old value is replaced.
|
||||
*
|
||||
* @param name name of the property associated with the value
|
||||
* @param value value of the property
|
||||
*/
|
||||
void setProperty(String name, Object value);
|
||||
/**
|
||||
* Sets the name and value of a property associated with the {@code MessageContext}. If the
|
||||
* {@code MessageContext} contains a value of the same property, the old value is replaced.
|
||||
*
|
||||
* @param name name of the property associated with the value
|
||||
* @param value value of the property
|
||||
*/
|
||||
void setProperty(String name, Object value);
|
||||
|
||||
/**
|
||||
* Gets the value of a specific property from the {@code MessageContext}.
|
||||
*
|
||||
* @param name name of the property whose value is to be retrieved
|
||||
* @return value of the property
|
||||
*/
|
||||
Object getProperty(String name);
|
||||
/**
|
||||
* Gets the value of a specific property from the {@code MessageContext}.
|
||||
*
|
||||
* @param name name of the property whose value is to be retrieved
|
||||
* @return value of the property
|
||||
*/
|
||||
Object getProperty(String name);
|
||||
|
||||
/**
|
||||
* Removes a property from the {@code MessageContext}.
|
||||
*
|
||||
* @param name name of the property to be removed
|
||||
*/
|
||||
void removeProperty(String name);
|
||||
/**
|
||||
* Removes a property from the {@code MessageContext}.
|
||||
*
|
||||
* @param name name of the property to be removed
|
||||
*/
|
||||
void removeProperty(String name);
|
||||
|
||||
/**
|
||||
* Check if this message context contains a property with the given name.
|
||||
*
|
||||
* @param name the name of the property to look for
|
||||
* @return {@code true} if the {@code MessageContext} contains the property; {@code false} otherwise
|
||||
*/
|
||||
boolean containsProperty(String name);
|
||||
/**
|
||||
* Check if this message context contains a property with the given name.
|
||||
*
|
||||
* @param name the name of the property to look for
|
||||
* @return {@code true} if the {@code MessageContext} contains the property; {@code false} otherwise
|
||||
*/
|
||||
boolean containsProperty(String name);
|
||||
|
||||
/**
|
||||
* Return the names of all properties in this {@code MessageContext}.
|
||||
*
|
||||
* @return the names of all properties in this context, or an empty array if none defined
|
||||
*/
|
||||
String[] getPropertyNames();
|
||||
/**
|
||||
* Return the names of all properties in this {@code MessageContext}.
|
||||
*
|
||||
* @return the names of all properties in this context, or an empty array if none defined
|
||||
*/
|
||||
String[] getPropertyNames();
|
||||
|
||||
}
|
||||
@@ -36,69 +36,69 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public abstract class AbstractMimeMessage implements MimeMessage {
|
||||
|
||||
@Override
|
||||
public final Attachment addAttachment(String contentId, File file) throws AttachmentException {
|
||||
Assert.hasLength(contentId, "contentId must not be empty");
|
||||
Assert.notNull(file, "File must not be null");
|
||||
DataHandler dataHandler = new DataHandler(new FileDataSource(file));
|
||||
return addAttachment(contentId, dataHandler);
|
||||
}
|
||||
@Override
|
||||
public final Attachment addAttachment(String contentId, File file) throws AttachmentException {
|
||||
Assert.hasLength(contentId, "contentId must not be empty");
|
||||
Assert.notNull(file, "File must not be null");
|
||||
DataHandler dataHandler = new DataHandler(new FileDataSource(file));
|
||||
return addAttachment(contentId, dataHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Attachment addAttachment(String contentId, InputStreamSource inputStreamSource, String contentType) {
|
||||
Assert.hasLength(contentId, "contentId must not be empty");
|
||||
Assert.notNull(inputStreamSource, "InputStreamSource must not be null");
|
||||
if (inputStreamSource instanceof Resource && ((Resource) inputStreamSource).isOpen()) {
|
||||
throw new IllegalArgumentException("Passed-in Resource contains an open stream: invalid argument. " +
|
||||
"MIME requires an InputStreamSource that creates a fresh stream for every call.");
|
||||
}
|
||||
DataHandler dataHandler = new DataHandler(new InputStreamSourceDataSource(inputStreamSource, contentType));
|
||||
return addAttachment(contentId, dataHandler);
|
||||
}
|
||||
@Override
|
||||
public final Attachment addAttachment(String contentId, InputStreamSource inputStreamSource, String contentType) {
|
||||
Assert.hasLength(contentId, "contentId must not be empty");
|
||||
Assert.notNull(inputStreamSource, "InputStreamSource must not be null");
|
||||
if (inputStreamSource instanceof Resource && ((Resource) inputStreamSource).isOpen()) {
|
||||
throw new IllegalArgumentException("Passed-in Resource contains an open stream: invalid argument. " +
|
||||
"MIME requires an InputStreamSource that creates a fresh stream for every call.");
|
||||
}
|
||||
DataHandler dataHandler = new DataHandler(new InputStreamSourceDataSource(inputStreamSource, contentType));
|
||||
return addAttachment(contentId, dataHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Activation framework {@code DataSource} that wraps a Spring {@code InputStreamSource}.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private static class InputStreamSourceDataSource implements DataSource {
|
||||
/**
|
||||
* Activation framework {@code DataSource} that wraps a Spring {@code InputStreamSource}.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private static class InputStreamSourceDataSource implements DataSource {
|
||||
|
||||
private final InputStreamSource inputStreamSource;
|
||||
private final InputStreamSource inputStreamSource;
|
||||
|
||||
private final String contentType;
|
||||
private final String contentType;
|
||||
|
||||
public InputStreamSourceDataSource(InputStreamSource inputStreamSource, String contentType) {
|
||||
this.inputStreamSource = inputStreamSource;
|
||||
this.contentType = contentType;
|
||||
}
|
||||
public InputStreamSourceDataSource(InputStreamSource inputStreamSource, String contentType) {
|
||||
this.inputStreamSource = inputStreamSource;
|
||||
this.contentType = contentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getInputStream() throws IOException {
|
||||
return inputStreamSource.getInputStream();
|
||||
}
|
||||
@Override
|
||||
public InputStream getInputStream() throws IOException {
|
||||
return inputStreamSource.getInputStream();
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutputStream getOutputStream() {
|
||||
throw new UnsupportedOperationException("Read-only javax.activation.DataSource");
|
||||
}
|
||||
@Override
|
||||
public OutputStream getOutputStream() {
|
||||
throw new UnsupportedOperationException("Read-only javax.activation.DataSource");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentType() {
|
||||
return contentType;
|
||||
}
|
||||
@Override
|
||||
public String getContentType() {
|
||||
return contentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
if (inputStreamSource instanceof Resource) {
|
||||
Resource resource = (Resource) inputStreamSource;
|
||||
return resource.getFilename();
|
||||
}
|
||||
else {
|
||||
throw new UnsupportedOperationException("DataSource name not available");
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
if (inputStreamSource instanceof Resource) {
|
||||
Resource resource = (Resource) inputStreamSource;
|
||||
return resource.getFilename();
|
||||
}
|
||||
else {
|
||||
throw new UnsupportedOperationException("DataSource name not available");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,40 +30,40 @@ import javax.activation.DataHandler;
|
||||
*/
|
||||
public interface Attachment {
|
||||
|
||||
/**
|
||||
* Returns the content identifier of the attachment.
|
||||
*
|
||||
* @return the content id, or {@code null} if empty or not defined
|
||||
*/
|
||||
String getContentId();
|
||||
/**
|
||||
* Returns the content identifier of the attachment.
|
||||
*
|
||||
* @return the content id, or {@code null} if empty or not defined
|
||||
*/
|
||||
String getContentId();
|
||||
|
||||
/**
|
||||
* Returns the content type of the attachment.
|
||||
*
|
||||
* @return the content type, or {@code null} if empty or not defined
|
||||
*/
|
||||
String getContentType();
|
||||
/**
|
||||
* Returns the content type of the attachment.
|
||||
*
|
||||
* @return the content type, or {@code null} if empty or not defined
|
||||
*/
|
||||
String getContentType();
|
||||
|
||||
/**
|
||||
* Return an {@code InputStream} to read the contents of the attachment from. The user is responsible for
|
||||
* closing the stream.
|
||||
*
|
||||
* @return the contents of the file as stream, or an empty stream if empty
|
||||
* @throws IOException in case of access I/O errors
|
||||
*/
|
||||
InputStream getInputStream() throws IOException;
|
||||
/**
|
||||
* Return an {@code InputStream} to read the contents of the attachment from. The user is responsible for
|
||||
* closing the stream.
|
||||
*
|
||||
* @return the contents of the file as stream, or an empty stream if empty
|
||||
* @throws IOException in case of access I/O errors
|
||||
*/
|
||||
InputStream getInputStream() throws IOException;
|
||||
|
||||
/**
|
||||
* Returns the size of the attachment in bytes. Returns {@code -1} if the size cannot be determined.
|
||||
*
|
||||
* @return the size of the attachment, {@code 0} if empty, or {@code -1} if the size cannot be determined
|
||||
*/
|
||||
long getSize();
|
||||
/**
|
||||
* Returns the size of the attachment in bytes. Returns {@code -1} if the size cannot be determined.
|
||||
*
|
||||
* @return the size of the attachment, {@code 0} if empty, or {@code -1} if the size cannot be determined
|
||||
*/
|
||||
long getSize();
|
||||
|
||||
/**
|
||||
* Returns the data handler of the attachment.
|
||||
*
|
||||
* @return the data handler of the attachment
|
||||
*/
|
||||
DataHandler getDataHandler();
|
||||
/**
|
||||
* Returns the data handler of the attachment.
|
||||
*
|
||||
* @return the data handler of the attachment
|
||||
*/
|
||||
DataHandler getDataHandler();
|
||||
}
|
||||
|
||||
@@ -28,16 +28,16 @@ import org.springframework.ws.WebServiceMessageException;
|
||||
@SuppressWarnings("serial")
|
||||
public class AttachmentException extends WebServiceMessageException {
|
||||
|
||||
public AttachmentException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
public AttachmentException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public AttachmentException(String msg, Throwable ex) {
|
||||
super(msg, ex);
|
||||
}
|
||||
public AttachmentException(String msg, Throwable ex) {
|
||||
super(msg, ex);
|
||||
}
|
||||
|
||||
public AttachmentException(Throwable ex) {
|
||||
super("Could not access body: " + ex.getMessage(), ex);
|
||||
}
|
||||
public AttachmentException(Throwable ex) {
|
||||
super("Could not access body: " + ex.getMessage(), ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,75 +33,75 @@ import org.springframework.ws.WebServiceMessage;
|
||||
*/
|
||||
public interface MimeMessage extends WebServiceMessage {
|
||||
|
||||
/**
|
||||
* Indicates whether this message is a XOP package.
|
||||
*
|
||||
* @return {@code true} when the constraints specified in <a href="http://www.w3.org/TR/2005/REC-xop10-20050125/#identifying_xop_documents">Identifying
|
||||
* XOP Documents</a> are met.
|
||||
* @see <a href="http://www.w3.org/TR/2005/REC-xop10-20050125/#xop_packages">XOP Packages</a>
|
||||
*/
|
||||
boolean isXopPackage();
|
||||
/**
|
||||
* Indicates whether this message is a XOP package.
|
||||
*
|
||||
* @return {@code true} when the constraints specified in <a href="http://www.w3.org/TR/2005/REC-xop10-20050125/#identifying_xop_documents">Identifying
|
||||
* XOP Documents</a> are met.
|
||||
* @see <a href="http://www.w3.org/TR/2005/REC-xop10-20050125/#xop_packages">XOP Packages</a>
|
||||
*/
|
||||
boolean isXopPackage();
|
||||
|
||||
/**
|
||||
* Turns this message into a XOP package.
|
||||
*
|
||||
* @return {@code true} when the message is a XOP package
|
||||
* @see <a href="http://www.w3.org/TR/2005/REC-xop10-20050125/#xop_packages">XOP Packages</a>
|
||||
*/
|
||||
boolean convertToXopPackage();
|
||||
/**
|
||||
* Turns this message into a XOP package.
|
||||
*
|
||||
* @return {@code true} when the message is a XOP package
|
||||
* @see <a href="http://www.w3.org/TR/2005/REC-xop10-20050125/#xop_packages">XOP Packages</a>
|
||||
*/
|
||||
boolean convertToXopPackage();
|
||||
|
||||
/**
|
||||
* Returns the {@link Attachment} with the specified content Id.
|
||||
*
|
||||
* @return the attachment with the specified content id; or {@code null} if it cannot be found
|
||||
* @throws AttachmentException in case of errors
|
||||
*/
|
||||
Attachment getAttachment(String contentId) throws AttachmentException;
|
||||
/**
|
||||
* Returns the {@link Attachment} with the specified content Id.
|
||||
*
|
||||
* @return the attachment with the specified content id; or {@code null} if it cannot be found
|
||||
* @throws AttachmentException in case of errors
|
||||
*/
|
||||
Attachment getAttachment(String contentId) throws AttachmentException;
|
||||
|
||||
/**
|
||||
* Returns an {@code Iterator} over all {@link Attachment} objects that are part of this message.
|
||||
*
|
||||
* @return an iterator over all attachments
|
||||
* @throws AttachmentException in case of errors
|
||||
* @see Attachment
|
||||
*/
|
||||
Iterator<Attachment> getAttachments() throws AttachmentException;
|
||||
/**
|
||||
* Returns an {@code Iterator} over all {@link Attachment} objects that are part of this message.
|
||||
*
|
||||
* @return an iterator over all attachments
|
||||
* @throws AttachmentException in case of errors
|
||||
* @see Attachment
|
||||
*/
|
||||
Iterator<Attachment> getAttachments() throws AttachmentException;
|
||||
|
||||
/**
|
||||
* Add an attachment to the message, taking the content from a {@link File}.
|
||||
*
|
||||
* <p>The content type will be determined by the name of the given content file. Do not use this for temporary files
|
||||
* with arbitrary filenames (possibly ending in ".tmp" or the like)!
|
||||
*
|
||||
* @param contentId the content Id of the attachment
|
||||
* @param file the file to take the content from
|
||||
* @return the added attachment
|
||||
* @throws AttachmentException in case of errors
|
||||
*/
|
||||
Attachment addAttachment(String contentId, File file) throws AttachmentException;
|
||||
/**
|
||||
* Add an attachment to the message, taking the content from a {@link File}.
|
||||
*
|
||||
* <p>The content type will be determined by the name of the given content file. Do not use this for temporary files
|
||||
* with arbitrary filenames (possibly ending in ".tmp" or the like)!
|
||||
*
|
||||
* @param contentId the content Id of the attachment
|
||||
* @param file the file to take the content from
|
||||
* @return the added attachment
|
||||
* @throws AttachmentException in case of errors
|
||||
*/
|
||||
Attachment addAttachment(String contentId, File file) throws AttachmentException;
|
||||
|
||||
/**
|
||||
* Add an attachment to the message, taking the content from an {@link InputStreamSource}.
|
||||
*
|
||||
* <p>Note that the stream returned by the source needs to be a <em>fresh one on each call</em>, as underlying
|
||||
* implementations can invoke {@link InputStreamSource#getInputStream()} multiple times.
|
||||
*
|
||||
* @param contentId the content Id of the attachment
|
||||
* @param inputStreamSource the resource to take the content from (all of Spring's Resource implementations can be
|
||||
* passed in here)
|
||||
* @param contentType the content type to use for the element
|
||||
* @return the added attachment
|
||||
* @throws AttachmentException in case of errors
|
||||
* @see org.springframework.core.io.Resource
|
||||
*/
|
||||
Attachment addAttachment(String contentId, InputStreamSource inputStreamSource, String contentType);
|
||||
/**
|
||||
* Add an attachment to the message, taking the content from an {@link InputStreamSource}.
|
||||
*
|
||||
* <p>Note that the stream returned by the source needs to be a <em>fresh one on each call</em>, as underlying
|
||||
* implementations can invoke {@link InputStreamSource#getInputStream()} multiple times.
|
||||
*
|
||||
* @param contentId the content Id of the attachment
|
||||
* @param inputStreamSource the resource to take the content from (all of Spring's Resource implementations can be
|
||||
* passed in here)
|
||||
* @param contentType the content type to use for the element
|
||||
* @return the added attachment
|
||||
* @throws AttachmentException in case of errors
|
||||
* @see org.springframework.core.io.Resource
|
||||
*/
|
||||
Attachment addAttachment(String contentId, InputStreamSource inputStreamSource, String contentType);
|
||||
|
||||
/**
|
||||
* Add an attachment to the message, taking the content from a {@link DataHandler}.
|
||||
*
|
||||
* @param dataHandler the data handler to take the content from
|
||||
* @return the added attachment
|
||||
* @throws AttachmentException in case of errors
|
||||
*/
|
||||
Attachment addAttachment(String contentId, DataHandler dataHandler);
|
||||
/**
|
||||
* Add an attachment to the message, taking the content from a {@link DataHandler}.
|
||||
*
|
||||
* @param dataHandler the data handler to take the content from
|
||||
* @return the added attachment
|
||||
* @throws AttachmentException in case of errors
|
||||
*/
|
||||
Attachment addAttachment(String contentId, DataHandler dataHandler);
|
||||
}
|
||||
|
||||
@@ -27,11 +27,11 @@ import org.springframework.ws.WebServiceMessageException;
|
||||
@SuppressWarnings("serial")
|
||||
public abstract class PoxMessageException extends WebServiceMessageException {
|
||||
|
||||
public PoxMessageException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
public PoxMessageException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public PoxMessageException(String msg, Throwable ex) {
|
||||
super(msg, ex);
|
||||
}
|
||||
public PoxMessageException(String msg, Throwable ex) {
|
||||
super(msg, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,74 +45,74 @@ import org.springframework.xml.namespace.QNameUtils;
|
||||
*/
|
||||
public class DomPoxMessage implements PoxMessage {
|
||||
|
||||
private final String contentType;
|
||||
private final String contentType;
|
||||
|
||||
private final Document document;
|
||||
private final Document document;
|
||||
|
||||
private final Transformer transformer;
|
||||
private final Transformer transformer;
|
||||
|
||||
/**
|
||||
* Constructs a new instance of the {@code DomPoxMessage} with the given document.
|
||||
*
|
||||
* @param document the document to base the message on
|
||||
*/
|
||||
public DomPoxMessage(Document document, Transformer transformer, String contentType) {
|
||||
Assert.notNull(document, "'document' must not be null");
|
||||
Assert.notNull(transformer, "'transformer' must not be null");
|
||||
Assert.hasLength(contentType, "'contentType' must not be empty");
|
||||
this.document = document;
|
||||
this.transformer = transformer;
|
||||
this.contentType = contentType;
|
||||
}
|
||||
/**
|
||||
* Constructs a new instance of the {@code DomPoxMessage} with the given document.
|
||||
*
|
||||
* @param document the document to base the message on
|
||||
*/
|
||||
public DomPoxMessage(Document document, Transformer transformer, String contentType) {
|
||||
Assert.notNull(document, "'document' must not be null");
|
||||
Assert.notNull(transformer, "'transformer' must not be null");
|
||||
Assert.hasLength(contentType, "'contentType' must not be empty");
|
||||
this.document = document;
|
||||
this.transformer = transformer;
|
||||
this.contentType = contentType;
|
||||
}
|
||||
|
||||
/** Returns the document underlying this message. */
|
||||
public Document getDocument() {
|
||||
return document;
|
||||
}
|
||||
/** Returns the document underlying this message. */
|
||||
public Document getDocument() {
|
||||
return document;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result getPayloadResult() {
|
||||
NodeList children = document.getChildNodes();
|
||||
for (int i = 0; i < children.getLength(); i++) {
|
||||
document.removeChild(children.item(i));
|
||||
}
|
||||
return new DOMResult(document);
|
||||
}
|
||||
@Override
|
||||
public Result getPayloadResult() {
|
||||
NodeList children = document.getChildNodes();
|
||||
for (int i = 0; i < children.getLength(); i++) {
|
||||
document.removeChild(children.item(i));
|
||||
}
|
||||
return new DOMResult(document);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Source getPayloadSource() {
|
||||
return new DOMSource(document);
|
||||
}
|
||||
@Override
|
||||
public Source getPayloadSource() {
|
||||
return new DOMSource(document);
|
||||
}
|
||||
|
||||
public boolean hasFault() {
|
||||
return false;
|
||||
}
|
||||
public boolean hasFault() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getFaultReason() {
|
||||
return null;
|
||||
}
|
||||
public String getFaultReason() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder("DomPoxMessage ");
|
||||
Element root = document.getDocumentElement();
|
||||
if (root != null) {
|
||||
builder.append(' ');
|
||||
builder.append(QNameUtils.getQNameForNode(root));
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder("DomPoxMessage ");
|
||||
Element root = document.getDocumentElement();
|
||||
if (root != null) {
|
||||
builder.append(' ');
|
||||
builder.append(QNameUtils.getQNameForNode(root));
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(OutputStream outputStream) throws IOException {
|
||||
try {
|
||||
if (outputStream instanceof TransportOutputStream) {
|
||||
TransportOutputStream transportOutputStream = (TransportOutputStream) outputStream;
|
||||
transportOutputStream.addHeader(TransportConstants.HEADER_CONTENT_TYPE, contentType);
|
||||
}
|
||||
transformer.transform(getPayloadSource(), new StreamResult(outputStream));
|
||||
}
|
||||
catch (TransformerException ex) {
|
||||
throw new DomPoxMessageException("Could write document: " + ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void writeTo(OutputStream outputStream) throws IOException {
|
||||
try {
|
||||
if (outputStream instanceof TransportOutputStream) {
|
||||
TransportOutputStream transportOutputStream = (TransportOutputStream) outputStream;
|
||||
transportOutputStream.addHeader(TransportConstants.HEADER_CONTENT_TYPE, contentType);
|
||||
}
|
||||
transformer.transform(getPayloadSource(), new StreamResult(outputStream));
|
||||
}
|
||||
catch (TransformerException ex) {
|
||||
throw new DomPoxMessageException("Could write document: " + ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,11 +27,11 @@ import org.springframework.ws.pox.PoxMessageException;
|
||||
@SuppressWarnings("serial")
|
||||
public class DomPoxMessageException extends PoxMessageException {
|
||||
|
||||
public DomPoxMessageException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
public DomPoxMessageException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public DomPoxMessageException(String msg, Throwable ex) {
|
||||
super(msg, ex);
|
||||
}
|
||||
public DomPoxMessageException(String msg, Throwable ex) {
|
||||
super(msg, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,34 +39,34 @@ import org.springframework.xml.transform.TransformerObjectSupport;
|
||||
*/
|
||||
public class DomPoxMessageFactory extends TransformerObjectSupport implements WebServiceMessageFactory {
|
||||
|
||||
/** The default content type for the POX messages. */
|
||||
public static final String DEFAULT_CONTENT_TYPE = "application/xml";
|
||||
/** The default content type for the POX messages. */
|
||||
public static final String DEFAULT_CONTENT_TYPE = "application/xml";
|
||||
|
||||
private DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
|
||||
private DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
|
||||
|
||||
private String contentType = DEFAULT_CONTENT_TYPE;
|
||||
private String contentType = DEFAULT_CONTENT_TYPE;
|
||||
|
||||
public DomPoxMessageFactory() {
|
||||
documentBuilderFactory.setNamespaceAware(true);
|
||||
documentBuilderFactory.setValidating(false);
|
||||
documentBuilderFactory.setExpandEntityReferences(false);
|
||||
}
|
||||
public DomPoxMessageFactory() {
|
||||
documentBuilderFactory.setNamespaceAware(true);
|
||||
documentBuilderFactory.setValidating(false);
|
||||
documentBuilderFactory.setExpandEntityReferences(false);
|
||||
}
|
||||
|
||||
/** Sets the content-type for the {@link DomPoxMessage}. */
|
||||
public void setContentType(String contentType) {
|
||||
Assert.hasLength(contentType, "'contentType' must not be empty");
|
||||
this.contentType = contentType;
|
||||
}
|
||||
/** Sets the content-type for the {@link DomPoxMessage}. */
|
||||
public void setContentType(String contentType) {
|
||||
Assert.hasLength(contentType, "'contentType' must not be empty");
|
||||
this.contentType = contentType;
|
||||
}
|
||||
|
||||
/** Set whether or not the XML parser should be XML namespace aware. Default is {@code true}. */
|
||||
public void setNamespaceAware(boolean namespaceAware) {
|
||||
documentBuilderFactory.setNamespaceAware(namespaceAware);
|
||||
}
|
||||
/** Set whether or not the XML parser should be XML namespace aware. Default is {@code true}. */
|
||||
public void setNamespaceAware(boolean namespaceAware) {
|
||||
documentBuilderFactory.setNamespaceAware(namespaceAware);
|
||||
}
|
||||
|
||||
/** Set if the XML parser should validate the document. Default is {@code false}. */
|
||||
public void setValidating(boolean validating) {
|
||||
documentBuilderFactory.setValidating(validating);
|
||||
}
|
||||
/** Set if the XML parser should validate the document. Default is {@code false}. */
|
||||
public void setValidating(boolean validating) {
|
||||
documentBuilderFactory.setValidating(validating);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set if the XML parser should expand entity reference nodes. Default is
|
||||
@@ -76,36 +76,36 @@ public class DomPoxMessageFactory extends TransformerObjectSupport implements We
|
||||
documentBuilderFactory.setExpandEntityReferences(expandEntityRef);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomPoxMessage createWebServiceMessage() {
|
||||
try {
|
||||
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
|
||||
Document request = documentBuilder.newDocument();
|
||||
return new DomPoxMessage(request, createTransformer(), contentType);
|
||||
}
|
||||
catch (ParserConfigurationException ex) {
|
||||
throw new DomPoxMessageException("Could not create message context", ex);
|
||||
}
|
||||
catch (TransformerConfigurationException ex) {
|
||||
throw new DomPoxMessageException("Could not create transformer", ex);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public DomPoxMessage createWebServiceMessage() {
|
||||
try {
|
||||
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
|
||||
Document request = documentBuilder.newDocument();
|
||||
return new DomPoxMessage(request, createTransformer(), contentType);
|
||||
}
|
||||
catch (ParserConfigurationException ex) {
|
||||
throw new DomPoxMessageException("Could not create message context", ex);
|
||||
}
|
||||
catch (TransformerConfigurationException ex) {
|
||||
throw new DomPoxMessageException("Could not create transformer", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomPoxMessage createWebServiceMessage(InputStream inputStream) throws IOException {
|
||||
try {
|
||||
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
|
||||
Document request = documentBuilder.parse(inputStream);
|
||||
return new DomPoxMessage(request, createTransformer(), contentType);
|
||||
}
|
||||
catch (ParserConfigurationException ex) {
|
||||
throw new DomPoxMessageException("Could not create message context", ex);
|
||||
}
|
||||
catch (SAXException ex) {
|
||||
throw new DomPoxMessageException("Could not parse request message", ex);
|
||||
}
|
||||
catch (TransformerConfigurationException ex) {
|
||||
throw new DomPoxMessageException("Could not create transformer", ex);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public DomPoxMessage createWebServiceMessage(InputStream inputStream) throws IOException {
|
||||
try {
|
||||
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
|
||||
Document request = documentBuilder.parse(inputStream);
|
||||
return new DomPoxMessage(request, createTransformer(), contentType);
|
||||
}
|
||||
catch (ParserConfigurationException ex) {
|
||||
throw new DomPoxMessageException("Could not create message context", ex);
|
||||
}
|
||||
catch (SAXException ex) {
|
||||
throw new DomPoxMessageException("Could not parse request message", ex);
|
||||
}
|
||||
catch (TransformerConfigurationException ex) {
|
||||
throw new DomPoxMessageException("Could not create transformer", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,23 +32,23 @@ import org.springframework.ws.context.MessageContext;
|
||||
*/
|
||||
public interface EndpointAdapter {
|
||||
|
||||
/**
|
||||
* Does this {@code EndpointAdapter} support the given {@code endpoint}?
|
||||
*
|
||||
* <p>Typical {@code EndpointAdapters} will base the decision on the endpoint type.
|
||||
*
|
||||
* @param endpoint endpoint object to check
|
||||
* @return {@code true} if this {@code EndpointAdapter} supports the supplied {@code endpoint}
|
||||
*/
|
||||
boolean supports(Object endpoint);
|
||||
/**
|
||||
* Does this {@code EndpointAdapter} support the given {@code endpoint}?
|
||||
*
|
||||
* <p>Typical {@code EndpointAdapters} will base the decision on the endpoint type.
|
||||
*
|
||||
* @param endpoint endpoint object to check
|
||||
* @return {@code true} if this {@code EndpointAdapter} supports the supplied {@code endpoint}
|
||||
*/
|
||||
boolean supports(Object endpoint);
|
||||
|
||||
/**
|
||||
* Use the given {@code endpoint} to handle the request.
|
||||
*
|
||||
* @param messageContext the current message context
|
||||
* @param endpoint the endpoint to use. This object must have previously been passed to the {@link
|
||||
* #supports(Object)} method of this interface, which must have returned {@code true}
|
||||
* @throws Exception in case of errors
|
||||
*/
|
||||
void invoke(MessageContext messageContext, Object endpoint) throws Exception;
|
||||
/**
|
||||
* Use the given {@code endpoint} to handle the request.
|
||||
*
|
||||
* @param messageContext the current message context
|
||||
* @param endpoint the endpoint to use. This object must have previously been passed to the {@link
|
||||
* #supports(Object)} method of this interface, which must have returned {@code true}
|
||||
* @throws Exception in case of errors
|
||||
*/
|
||||
void invoke(MessageContext messageContext, Object endpoint) throws Exception;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -26,13 +26,13 @@ import org.springframework.ws.context.MessageContext;
|
||||
*/
|
||||
public interface EndpointExceptionResolver {
|
||||
|
||||
/**
|
||||
* Try to resolve the given exception that got thrown during on endpoint execution.
|
||||
*
|
||||
* @param messageContext current message context
|
||||
* @param endpoint the executed endpoint, or null if none chosen at the time of the exception
|
||||
* @param ex the exception that got thrown during endpoint execution
|
||||
* @return {@code true} if resolved; {@code false} otherwise
|
||||
*/
|
||||
boolean resolveException(MessageContext messageContext, Object endpoint, Exception ex);
|
||||
/**
|
||||
* Try to resolve the given exception that got thrown during on endpoint execution.
|
||||
*
|
||||
* @param messageContext current message context
|
||||
* @param endpoint the executed endpoint, or null if none chosen at the time of the exception
|
||||
* @param ex the exception that got thrown during endpoint execution
|
||||
* @return {@code true} if resolved; {@code false} otherwise
|
||||
*/
|
||||
boolean resolveException(MessageContext messageContext, Object endpoint, Exception ex);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -42,75 +42,75 @@ import org.springframework.ws.context.MessageContext;
|
||||
*/
|
||||
public interface EndpointInterceptor {
|
||||
|
||||
/**
|
||||
* Processes the incoming request message. Called after {@link EndpointMapping} determined an appropriate endpoint
|
||||
* object, but before {@link EndpointAdapter} invokes the endpoint.
|
||||
*
|
||||
* <p>{@link MessageDispatcher} processes an endpoint in an invocation chain, consisting of any number of interceptors,
|
||||
* with the endpoint itself at the end. With this method, each interceptor can decide to abort the chain, typically
|
||||
* creating a custom response.
|
||||
*
|
||||
* @param messageContext contains the incoming request message
|
||||
* @param endpoint chosen endpoint to invoke
|
||||
* @return {@code true} to continue processing of the request interceptor chain; {@code false} to indicate
|
||||
* blocking of the request endpoint chain, <em>without invoking the endpoint</em>
|
||||
* @throws Exception in case of errors
|
||||
* @see MessageContext#getRequest()
|
||||
*/
|
||||
boolean handleRequest(MessageContext messageContext, Object endpoint) throws Exception;
|
||||
/**
|
||||
* Processes the incoming request message. Called after {@link EndpointMapping} determined an appropriate endpoint
|
||||
* object, but before {@link EndpointAdapter} invokes the endpoint.
|
||||
*
|
||||
* <p>{@link MessageDispatcher} processes an endpoint in an invocation chain, consisting of any number of interceptors,
|
||||
* with the endpoint itself at the end. With this method, each interceptor can decide to abort the chain, typically
|
||||
* creating a custom response.
|
||||
*
|
||||
* @param messageContext contains the incoming request message
|
||||
* @param endpoint chosen endpoint to invoke
|
||||
* @return {@code true} to continue processing of the request interceptor chain; {@code false} to indicate
|
||||
* blocking of the request endpoint chain, <em>without invoking the endpoint</em>
|
||||
* @throws Exception in case of errors
|
||||
* @see MessageContext#getRequest()
|
||||
*/
|
||||
boolean handleRequest(MessageContext messageContext, Object endpoint) throws Exception;
|
||||
|
||||
/**
|
||||
* Processes the outgoing response message. Called after {@link EndpointAdapter} actually invoked the endpoint. Can
|
||||
* manipulate the response, if any, by adding new headers, etc.
|
||||
*
|
||||
* <p>{@link MessageDispatcher} processes an endpoint in an invocation chain, consisting of any number of interceptors,
|
||||
* with the endpoint itself at the end. With this method, each interceptor can post-process an invocation, getting
|
||||
* applied in inverse order of the execution chain.
|
||||
*
|
||||
* <p>Note: Will only be called if this interceptor's {@link #handleRequest} method has successfully completed.
|
||||
*
|
||||
* @param messageContext contains both request and response messages
|
||||
* @param endpoint chosen endpoint to invoke
|
||||
* @return {@code true} to continue processing of the response interceptor chain; {@code false} to indicate
|
||||
* blocking of the response endpoint chain.
|
||||
* @throws Exception in case of errors
|
||||
* @see MessageContext#getRequest()
|
||||
* @see MessageContext#hasResponse()
|
||||
* @see MessageContext#getResponse()
|
||||
*/
|
||||
boolean handleResponse(MessageContext messageContext, Object endpoint) throws Exception;
|
||||
/**
|
||||
* Processes the outgoing response message. Called after {@link EndpointAdapter} actually invoked the endpoint. Can
|
||||
* manipulate the response, if any, by adding new headers, etc.
|
||||
*
|
||||
* <p>{@link MessageDispatcher} processes an endpoint in an invocation chain, consisting of any number of interceptors,
|
||||
* with the endpoint itself at the end. With this method, each interceptor can post-process an invocation, getting
|
||||
* applied in inverse order of the execution chain.
|
||||
*
|
||||
* <p>Note: Will only be called if this interceptor's {@link #handleRequest} method has successfully completed.
|
||||
*
|
||||
* @param messageContext contains both request and response messages
|
||||
* @param endpoint chosen endpoint to invoke
|
||||
* @return {@code true} to continue processing of the response interceptor chain; {@code false} to indicate
|
||||
* blocking of the response endpoint chain.
|
||||
* @throws Exception in case of errors
|
||||
* @see MessageContext#getRequest()
|
||||
* @see MessageContext#hasResponse()
|
||||
* @see MessageContext#getResponse()
|
||||
*/
|
||||
boolean handleResponse(MessageContext messageContext, Object endpoint) throws Exception;
|
||||
|
||||
/**
|
||||
* Processes the outgoing response fault. Called after {@link EndpointAdapter} actually invoked the endpoint. Can
|
||||
* manipulate the response, if any, by adding new headers, etc.
|
||||
*
|
||||
* <p>{@link MessageDispatcher} processes an endpoint in an invocation chain, consisting of any number of interceptors,
|
||||
* with the endpoint itself at the end. With this method, each interceptor can post-process an invocation, getting
|
||||
* applied in inverse order of the execution chain.
|
||||
*
|
||||
* <p>Note: Will only be called if this interceptor's {@link #handleRequest} method has successfully completed.
|
||||
*
|
||||
* @param messageContext contains both request and response messages, the response should contains a Fault
|
||||
* @param endpoint chosen endpoint to invoke
|
||||
* @return {@code true} to continue processing of the response interceptor chain; {@code false} to indicate
|
||||
* blocking of the response handler chain.
|
||||
*/
|
||||
boolean handleFault(MessageContext messageContext, Object endpoint) throws Exception;
|
||||
/**
|
||||
* Processes the outgoing response fault. Called after {@link EndpointAdapter} actually invoked the endpoint. Can
|
||||
* manipulate the response, if any, by adding new headers, etc.
|
||||
*
|
||||
* <p>{@link MessageDispatcher} processes an endpoint in an invocation chain, consisting of any number of interceptors,
|
||||
* with the endpoint itself at the end. With this method, each interceptor can post-process an invocation, getting
|
||||
* applied in inverse order of the execution chain.
|
||||
*
|
||||
* <p>Note: Will only be called if this interceptor's {@link #handleRequest} method has successfully completed.
|
||||
*
|
||||
* @param messageContext contains both request and response messages, the response should contains a Fault
|
||||
* @param endpoint chosen endpoint to invoke
|
||||
* @return {@code true} to continue processing of the response interceptor chain; {@code false} to indicate
|
||||
* blocking of the response handler chain.
|
||||
*/
|
||||
boolean handleFault(MessageContext messageContext, Object endpoint) throws Exception;
|
||||
|
||||
/**
|
||||
* Callback after completion of request and response (fault) processing. Will be called on any outcome of endpoint
|
||||
* invocation, thus allows for proper resource cleanup.
|
||||
*
|
||||
* <p>Note: Will only be called if this interceptor's {@link #handleRequest} method has successfully completed.
|
||||
*
|
||||
* <p>As with the {@link #handleResponse} method, the method will be invoked on each interceptor in the chain in
|
||||
* reverse order, so the first interceptor will be the last to be invoked.
|
||||
*
|
||||
* @param messageContext contains both request and response messages, the response should contains a Fault
|
||||
* @param endpoint chosen endpoint to invoke
|
||||
* @param ex exception thrown on handler execution, if any
|
||||
* @throws Exception in case of errors
|
||||
* @since 2.0.2
|
||||
*/
|
||||
void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex) throws Exception;
|
||||
/**
|
||||
* Callback after completion of request and response (fault) processing. Will be called on any outcome of endpoint
|
||||
* invocation, thus allows for proper resource cleanup.
|
||||
*
|
||||
* <p>Note: Will only be called if this interceptor's {@link #handleRequest} method has successfully completed.
|
||||
*
|
||||
* <p>As with the {@link #handleResponse} method, the method will be invoked on each interceptor in the chain in
|
||||
* reverse order, so the first interceptor will be the last to be invoked.
|
||||
*
|
||||
* @param messageContext contains both request and response messages, the response should contains a Fault
|
||||
* @param endpoint chosen endpoint to invoke
|
||||
* @param ex exception thrown on handler execution, if any
|
||||
* @throws Exception in case of errors
|
||||
* @since 2.0.2
|
||||
*/
|
||||
void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex) throws Exception;
|
||||
}
|
||||
|
||||
@@ -25,46 +25,46 @@ package org.springframework.ws.server;
|
||||
*/
|
||||
public class EndpointInvocationChain {
|
||||
|
||||
private Object endpoint;
|
||||
private Object endpoint;
|
||||
|
||||
private EndpointInterceptor[] interceptors;
|
||||
private EndpointInterceptor[] interceptors;
|
||||
|
||||
/**
|
||||
* Create new {@code EndpointInvocationChain}.
|
||||
*
|
||||
* @param endpoint the endpoint object to invoke
|
||||
*/
|
||||
public EndpointInvocationChain(Object endpoint) {
|
||||
this.endpoint = endpoint;
|
||||
}
|
||||
/**
|
||||
* Create new {@code EndpointInvocationChain}.
|
||||
*
|
||||
* @param endpoint the endpoint object to invoke
|
||||
*/
|
||||
public EndpointInvocationChain(Object endpoint) {
|
||||
this.endpoint = endpoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new {@code EndpointInvocationChain}.
|
||||
*
|
||||
* @param endpoint the endpoint object to invoke
|
||||
* @param interceptors the array of interceptors to apply
|
||||
*/
|
||||
public EndpointInvocationChain(Object endpoint, EndpointInterceptor[] interceptors) {
|
||||
this.endpoint = endpoint;
|
||||
this.interceptors = interceptors;
|
||||
}
|
||||
/**
|
||||
* Create new {@code EndpointInvocationChain}.
|
||||
*
|
||||
* @param endpoint the endpoint object to invoke
|
||||
* @param interceptors the array of interceptors to apply
|
||||
*/
|
||||
public EndpointInvocationChain(Object endpoint, EndpointInterceptor[] interceptors) {
|
||||
this.endpoint = endpoint;
|
||||
this.interceptors = interceptors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the endpoint object to invoke.
|
||||
*
|
||||
* @return the endpoint object
|
||||
*/
|
||||
public Object getEndpoint() {
|
||||
return endpoint;
|
||||
}
|
||||
/**
|
||||
* Returns the endpoint object to invoke.
|
||||
*
|
||||
* @return the endpoint object
|
||||
*/
|
||||
public Object getEndpoint() {
|
||||
return endpoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the array of interceptors to apply before the handler executes.
|
||||
*
|
||||
* @return the array of interceptors
|
||||
*/
|
||||
public EndpointInterceptor[] getInterceptors() {
|
||||
return interceptors;
|
||||
}
|
||||
/**
|
||||
* Returns the array of interceptors to apply before the handler executes.
|
||||
*
|
||||
* @return the array of interceptors
|
||||
*/
|
||||
public EndpointInterceptor[] getInterceptors() {
|
||||
return interceptors;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -38,22 +38,22 @@ import org.springframework.ws.context.MessageContext;
|
||||
*/
|
||||
public interface EndpointMapping {
|
||||
|
||||
/**
|
||||
* Returns an endpoint and any interceptors for this message context. The choice may be made on message contents,
|
||||
* transport request url, a routing table, or any factor the implementing class chooses.
|
||||
*
|
||||
* <p>The returned {@code EndpointExecutionChain} contains an endpoint Object, rather than even a tag interface,
|
||||
* so that endpoints are not constrained in any way. For example, a {@code EndpointAdapter} could be written to
|
||||
* allow another framework's endpoint objects to be used.
|
||||
*
|
||||
* <p>Returns {@code null} if no match was found. This is by design. The {@code MessageDispatcher} will query
|
||||
* all registered {@code EndpointMapping} beans to find a match, and only decide there is an error if none can
|
||||
* find an endpoint.
|
||||
*
|
||||
* @return a HandlerExecutionChain instance containing endpoint object and any interceptors, or {@code null} if
|
||||
* no mapping is found
|
||||
* @throws Exception if there is an internal error
|
||||
*/
|
||||
EndpointInvocationChain getEndpoint(MessageContext messageContext) throws Exception;
|
||||
/**
|
||||
* Returns an endpoint and any interceptors for this message context. The choice may be made on message contents,
|
||||
* transport request url, a routing table, or any factor the implementing class chooses.
|
||||
*
|
||||
* <p>The returned {@code EndpointExecutionChain} contains an endpoint Object, rather than even a tag interface,
|
||||
* so that endpoints are not constrained in any way. For example, a {@code EndpointAdapter} could be written to
|
||||
* allow another framework's endpoint objects to be used.
|
||||
*
|
||||
* <p>Returns {@code null} if no match was found. This is by design. The {@code MessageDispatcher} will query
|
||||
* all registered {@code EndpointMapping} beans to find a match, and only decide there is an error if none can
|
||||
* find an endpoint.
|
||||
*
|
||||
* @return a HandlerExecutionChain instance containing endpoint object and any interceptors, or {@code null} if
|
||||
* no mapping is found
|
||||
* @throws Exception if there is an internal error
|
||||
*/
|
||||
EndpointInvocationChain getEndpoint(MessageContext messageContext) throws Exception;
|
||||
|
||||
}
|
||||
|
||||
@@ -78,408 +78,408 @@ import org.springframework.ws.transport.WebServiceMessageReceiver;
|
||||
*/
|
||||
public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAware, ApplicationContextAware {
|
||||
|
||||
/** Logger available to subclasses. */
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
/** Logger available to subclasses. */
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
/** Log category to use when no mapped endpoint is found for a request. */
|
||||
public static final String ENDPOINT_NOT_FOUND_LOG_CATEGORY = "org.springframework.ws.server.EndpointNotFound";
|
||||
/** Log category to use when no mapped endpoint is found for a request. */
|
||||
public static final String ENDPOINT_NOT_FOUND_LOG_CATEGORY = "org.springframework.ws.server.EndpointNotFound";
|
||||
|
||||
/** Additional logger to use when no mapped endpoint is found for a request. */
|
||||
protected static final Log endpointNotFoundLogger =
|
||||
LogFactory.getLog(MessageDispatcher.ENDPOINT_NOT_FOUND_LOG_CATEGORY);
|
||||
/** Additional logger to use when no mapped endpoint is found for a request. */
|
||||
protected static final Log endpointNotFoundLogger =
|
||||
LogFactory.getLog(MessageDispatcher.ENDPOINT_NOT_FOUND_LOG_CATEGORY);
|
||||
|
||||
/** Log category to use for message tracing. */
|
||||
public static final String MESSAGE_TRACING_LOG_CATEGORY = "org.springframework.ws.server.MessageTracing";
|
||||
/** Log category to use for message tracing. */
|
||||
public static final String MESSAGE_TRACING_LOG_CATEGORY = "org.springframework.ws.server.MessageTracing";
|
||||
|
||||
/** Additional logger to use for sent message tracing. */
|
||||
protected static final Log sentMessageTracingLogger =
|
||||
LogFactory.getLog(MessageDispatcher.MESSAGE_TRACING_LOG_CATEGORY + ".sent");
|
||||
/** Additional logger to use for sent message tracing. */
|
||||
protected static final Log sentMessageTracingLogger =
|
||||
LogFactory.getLog(MessageDispatcher.MESSAGE_TRACING_LOG_CATEGORY + ".sent");
|
||||
|
||||
/** Additional logger to use for received message tracing. */
|
||||
protected static final Log receivedMessageTracingLogger =
|
||||
LogFactory.getLog(MessageDispatcher.MESSAGE_TRACING_LOG_CATEGORY + ".received");
|
||||
/** Additional logger to use for received message tracing. */
|
||||
protected static final Log receivedMessageTracingLogger =
|
||||
LogFactory.getLog(MessageDispatcher.MESSAGE_TRACING_LOG_CATEGORY + ".received");
|
||||
|
||||
private final DefaultStrategiesHelper defaultStrategiesHelper;
|
||||
private final DefaultStrategiesHelper defaultStrategiesHelper;
|
||||
|
||||
/** The registered bean name for this dispatcher. */
|
||||
private String beanName;
|
||||
/** The registered bean name for this dispatcher. */
|
||||
private String beanName;
|
||||
|
||||
/** List of EndpointAdapters used in this dispatcher. */
|
||||
private List<EndpointAdapter> endpointAdapters;
|
||||
/** List of EndpointAdapters used in this dispatcher. */
|
||||
private List<EndpointAdapter> endpointAdapters;
|
||||
|
||||
/** List of EndpointExceptionResolvers used in this dispatcher. */
|
||||
private List<EndpointExceptionResolver> endpointExceptionResolvers;
|
||||
/** List of EndpointExceptionResolvers used in this dispatcher. */
|
||||
private List<EndpointExceptionResolver> endpointExceptionResolvers;
|
||||
|
||||
/** List of EndpointMappings used in this dispatcher. */
|
||||
private List<EndpointMapping> endpointMappings;
|
||||
/** List of EndpointMappings used in this dispatcher. */
|
||||
private List<EndpointMapping> endpointMappings;
|
||||
|
||||
/** Initializes a new instance of the {@code MessageDispatcher}. */
|
||||
public MessageDispatcher() {
|
||||
defaultStrategiesHelper = new DefaultStrategiesHelper(getClass());
|
||||
}
|
||||
/** Initializes a new instance of the {@code MessageDispatcher}. */
|
||||
public MessageDispatcher() {
|
||||
defaultStrategiesHelper = new DefaultStrategiesHelper(getClass());
|
||||
}
|
||||
|
||||
/** Returns the {@code EndpointAdapter}s to use by this {@code MessageDispatcher}. */
|
||||
public List<EndpointAdapter> getEndpointAdapters() {
|
||||
return endpointAdapters;
|
||||
}
|
||||
/** Returns the {@code EndpointAdapter}s to use by this {@code MessageDispatcher}. */
|
||||
public List<EndpointAdapter> getEndpointAdapters() {
|
||||
return endpointAdapters;
|
||||
}
|
||||
|
||||
/** Sets the {@code EndpointAdapter}s to use by this {@code MessageDispatcher}. */
|
||||
public void setEndpointAdapters(List<EndpointAdapter> endpointAdapters) {
|
||||
this.endpointAdapters = endpointAdapters;
|
||||
}
|
||||
/** Sets the {@code EndpointAdapter}s to use by this {@code MessageDispatcher}. */
|
||||
public void setEndpointAdapters(List<EndpointAdapter> endpointAdapters) {
|
||||
this.endpointAdapters = endpointAdapters;
|
||||
}
|
||||
|
||||
/** Returns the {@code EndpointExceptionResolver}s to use by this {@code MessageDispatcher}. */
|
||||
public List<EndpointExceptionResolver> getEndpointExceptionResolvers() {
|
||||
return endpointExceptionResolvers;
|
||||
}
|
||||
/** Returns the {@code EndpointExceptionResolver}s to use by this {@code MessageDispatcher}. */
|
||||
public List<EndpointExceptionResolver> getEndpointExceptionResolvers() {
|
||||
return endpointExceptionResolvers;
|
||||
}
|
||||
|
||||
/** Sets the {@code EndpointExceptionResolver}s to use by this {@code MessageDispatcher}. */
|
||||
public void setEndpointExceptionResolvers(List<EndpointExceptionResolver> endpointExceptionResolvers) {
|
||||
this.endpointExceptionResolvers = endpointExceptionResolvers;
|
||||
}
|
||||
/** Sets the {@code EndpointExceptionResolver}s to use by this {@code MessageDispatcher}. */
|
||||
public void setEndpointExceptionResolvers(List<EndpointExceptionResolver> endpointExceptionResolvers) {
|
||||
this.endpointExceptionResolvers = endpointExceptionResolvers;
|
||||
}
|
||||
|
||||
/** Returns the {@code EndpointMapping}s to use by this {@code MessageDispatcher}. */
|
||||
public List<EndpointMapping> getEndpointMappings() {
|
||||
return endpointMappings;
|
||||
}
|
||||
/** Returns the {@code EndpointMapping}s to use by this {@code MessageDispatcher}. */
|
||||
public List<EndpointMapping> getEndpointMappings() {
|
||||
return endpointMappings;
|
||||
}
|
||||
|
||||
/** Sets the {@code EndpointMapping}s to use by this {@code MessageDispatcher}. */
|
||||
public void setEndpointMappings(List<EndpointMapping> endpointMappings) {
|
||||
this.endpointMappings = endpointMappings;
|
||||
}
|
||||
/** Sets the {@code EndpointMapping}s to use by this {@code MessageDispatcher}. */
|
||||
public void setEndpointMappings(List<EndpointMapping> endpointMappings) {
|
||||
this.endpointMappings = endpointMappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setBeanName(String beanName) {
|
||||
this.beanName = beanName;
|
||||
}
|
||||
@Override
|
||||
public final void setBeanName(String beanName) {
|
||||
this.beanName = beanName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
initEndpointAdapters(applicationContext);
|
||||
initEndpointExceptionResolvers(applicationContext);
|
||||
initEndpointMappings(applicationContext);
|
||||
}
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
initEndpointAdapters(applicationContext);
|
||||
initEndpointExceptionResolvers(applicationContext);
|
||||
initEndpointMappings(applicationContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive(MessageContext messageContext) throws Exception {
|
||||
// Let's keep a reference to the request content as it came in, it might be changed by interceptors in dispatch()
|
||||
String requestContent = "";
|
||||
if (receivedMessageTracingLogger.isTraceEnabled() || sentMessageTracingLogger.isTraceEnabled()) {
|
||||
requestContent = getMessageContent(messageContext.getRequest());
|
||||
}
|
||||
if (receivedMessageTracingLogger.isTraceEnabled()) {
|
||||
receivedMessageTracingLogger.trace("Received request [" + requestContent + "]");
|
||||
}
|
||||
else if (receivedMessageTracingLogger.isDebugEnabled()) {
|
||||
receivedMessageTracingLogger.debug("Received request [" + messageContext.getRequest() + "]");
|
||||
}
|
||||
dispatch(messageContext);
|
||||
if (messageContext.hasResponse()) {
|
||||
WebServiceMessage response = messageContext.getResponse();
|
||||
if (sentMessageTracingLogger.isTraceEnabled()) {
|
||||
String responseContent = getMessageContent(response);
|
||||
sentMessageTracingLogger.trace("Sent response [" + responseContent + "] for request [" +
|
||||
requestContent + "]");
|
||||
}
|
||||
else if (sentMessageTracingLogger.isDebugEnabled()) {
|
||||
sentMessageTracingLogger.debug("Sent response [" + response + "] for request [" +
|
||||
messageContext.getRequest() + "]");
|
||||
}
|
||||
}
|
||||
else if (sentMessageTracingLogger.isDebugEnabled()) {
|
||||
sentMessageTracingLogger
|
||||
.debug("MessageDispatcher with name '" + beanName + "' sends no response for request [" +
|
||||
messageContext.getRequest() + "]");
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void receive(MessageContext messageContext) throws Exception {
|
||||
// Let's keep a reference to the request content as it came in, it might be changed by interceptors in dispatch()
|
||||
String requestContent = "";
|
||||
if (receivedMessageTracingLogger.isTraceEnabled() || sentMessageTracingLogger.isTraceEnabled()) {
|
||||
requestContent = getMessageContent(messageContext.getRequest());
|
||||
}
|
||||
if (receivedMessageTracingLogger.isTraceEnabled()) {
|
||||
receivedMessageTracingLogger.trace("Received request [" + requestContent + "]");
|
||||
}
|
||||
else if (receivedMessageTracingLogger.isDebugEnabled()) {
|
||||
receivedMessageTracingLogger.debug("Received request [" + messageContext.getRequest() + "]");
|
||||
}
|
||||
dispatch(messageContext);
|
||||
if (messageContext.hasResponse()) {
|
||||
WebServiceMessage response = messageContext.getResponse();
|
||||
if (sentMessageTracingLogger.isTraceEnabled()) {
|
||||
String responseContent = getMessageContent(response);
|
||||
sentMessageTracingLogger.trace("Sent response [" + responseContent + "] for request [" +
|
||||
requestContent + "]");
|
||||
}
|
||||
else if (sentMessageTracingLogger.isDebugEnabled()) {
|
||||
sentMessageTracingLogger.debug("Sent response [" + response + "] for request [" +
|
||||
messageContext.getRequest() + "]");
|
||||
}
|
||||
}
|
||||
else if (sentMessageTracingLogger.isDebugEnabled()) {
|
||||
sentMessageTracingLogger
|
||||
.debug("MessageDispatcher with name '" + beanName + "' sends no response for request [" +
|
||||
messageContext.getRequest() + "]");
|
||||
}
|
||||
}
|
||||
|
||||
private String getMessageContent(WebServiceMessage message) throws IOException {
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
message.writeTo(bos);
|
||||
return bos.toString("UTF-8");
|
||||
}
|
||||
private String getMessageContent(WebServiceMessage message) throws IOException {
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
message.writeTo(bos);
|
||||
return bos.toString("UTF-8");
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatches the request in the given MessageContext according to the configuration.
|
||||
*
|
||||
* @param messageContext the message context
|
||||
* @throws org.springframework.ws.NoEndpointFoundException
|
||||
* thrown when an endpoint cannot be resolved for the incoming message
|
||||
*/
|
||||
protected final void dispatch(MessageContext messageContext) throws Exception {
|
||||
EndpointInvocationChain mappedEndpoint = null;
|
||||
int interceptorIndex = -1;
|
||||
try {
|
||||
try {
|
||||
// Determine endpoint for the current context
|
||||
mappedEndpoint = getEndpoint(messageContext);
|
||||
if (mappedEndpoint == null || mappedEndpoint.getEndpoint() == null) {
|
||||
throw new NoEndpointFoundException(messageContext.getRequest());
|
||||
}
|
||||
if (!handleRequest(mappedEndpoint, messageContext)) {
|
||||
return;
|
||||
}
|
||||
// Apply handleRequest of registered interceptors
|
||||
if (mappedEndpoint.getInterceptors() != null) {
|
||||
for (int i = 0; i < mappedEndpoint.getInterceptors().length; i++) {
|
||||
EndpointInterceptor interceptor = mappedEndpoint.getInterceptors()[i];
|
||||
interceptorIndex = i;
|
||||
if (!interceptor.handleRequest(messageContext, mappedEndpoint.getEndpoint())) {
|
||||
triggerHandleResponse(mappedEndpoint, interceptorIndex, messageContext);
|
||||
triggerAfterCompletion(mappedEndpoint, interceptorIndex, messageContext, null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Actually invoke the endpoint
|
||||
EndpointAdapter endpointAdapter = getEndpointAdapter(mappedEndpoint.getEndpoint());
|
||||
endpointAdapter.invoke(messageContext, mappedEndpoint.getEndpoint());
|
||||
/**
|
||||
* Dispatches the request in the given MessageContext according to the configuration.
|
||||
*
|
||||
* @param messageContext the message context
|
||||
* @throws org.springframework.ws.NoEndpointFoundException
|
||||
* thrown when an endpoint cannot be resolved for the incoming message
|
||||
*/
|
||||
protected final void dispatch(MessageContext messageContext) throws Exception {
|
||||
EndpointInvocationChain mappedEndpoint = null;
|
||||
int interceptorIndex = -1;
|
||||
try {
|
||||
try {
|
||||
// Determine endpoint for the current context
|
||||
mappedEndpoint = getEndpoint(messageContext);
|
||||
if (mappedEndpoint == null || mappedEndpoint.getEndpoint() == null) {
|
||||
throw new NoEndpointFoundException(messageContext.getRequest());
|
||||
}
|
||||
if (!handleRequest(mappedEndpoint, messageContext)) {
|
||||
return;
|
||||
}
|
||||
// Apply handleRequest of registered interceptors
|
||||
if (mappedEndpoint.getInterceptors() != null) {
|
||||
for (int i = 0; i < mappedEndpoint.getInterceptors().length; i++) {
|
||||
EndpointInterceptor interceptor = mappedEndpoint.getInterceptors()[i];
|
||||
interceptorIndex = i;
|
||||
if (!interceptor.handleRequest(messageContext, mappedEndpoint.getEndpoint())) {
|
||||
triggerHandleResponse(mappedEndpoint, interceptorIndex, messageContext);
|
||||
triggerAfterCompletion(mappedEndpoint, interceptorIndex, messageContext, null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Actually invoke the endpoint
|
||||
EndpointAdapter endpointAdapter = getEndpointAdapter(mappedEndpoint.getEndpoint());
|
||||
endpointAdapter.invoke(messageContext, mappedEndpoint.getEndpoint());
|
||||
|
||||
// Apply handleResponse methods of registered interceptors
|
||||
triggerHandleResponse(mappedEndpoint, interceptorIndex, messageContext);
|
||||
}
|
||||
catch (NoEndpointFoundException ex) {
|
||||
// No triggering of interceptors if no endpoint is found
|
||||
if (endpointNotFoundLogger.isWarnEnabled()) {
|
||||
endpointNotFoundLogger.warn("No endpoint mapping found for [" + messageContext.getRequest() + "]");
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Object endpoint = mappedEndpoint != null ? mappedEndpoint.getEndpoint() : null;
|
||||
processEndpointException(messageContext, endpoint, ex);
|
||||
triggerHandleResponse(mappedEndpoint, interceptorIndex, messageContext);
|
||||
}
|
||||
triggerAfterCompletion(mappedEndpoint, interceptorIndex, messageContext, null);
|
||||
}
|
||||
catch (NoEndpointFoundException ex) {
|
||||
throw ex;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
// Apply handleResponse methods of registered interceptors
|
||||
triggerHandleResponse(mappedEndpoint, interceptorIndex, messageContext);
|
||||
}
|
||||
catch (NoEndpointFoundException ex) {
|
||||
// No triggering of interceptors if no endpoint is found
|
||||
if (endpointNotFoundLogger.isWarnEnabled()) {
|
||||
endpointNotFoundLogger.warn("No endpoint mapping found for [" + messageContext.getRequest() + "]");
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Object endpoint = mappedEndpoint != null ? mappedEndpoint.getEndpoint() : null;
|
||||
processEndpointException(messageContext, endpoint, ex);
|
||||
triggerHandleResponse(mappedEndpoint, interceptorIndex, messageContext);
|
||||
}
|
||||
triggerAfterCompletion(mappedEndpoint, interceptorIndex, messageContext, null);
|
||||
}
|
||||
catch (NoEndpointFoundException ex) {
|
||||
throw ex;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
// Trigger after-completion for thrown exception.
|
||||
triggerAfterCompletion(mappedEndpoint, interceptorIndex, messageContext, ex);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
triggerAfterCompletion(mappedEndpoint, interceptorIndex, messageContext, ex);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the endpoint for this request. All endpoint mappings are tried, in order.
|
||||
*
|
||||
* @return the {@code EndpointInvocationChain}, or {@code null} if no endpoint could be found.
|
||||
*/
|
||||
protected EndpointInvocationChain getEndpoint(MessageContext messageContext) throws Exception {
|
||||
for (EndpointMapping endpointMapping : getEndpointMappings()) {
|
||||
EndpointInvocationChain endpoint = endpointMapping.getEndpoint(messageContext);
|
||||
if (endpoint != null) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Endpoint mapping [" + endpointMapping + "] maps request to endpoint [" +
|
||||
endpoint.getEndpoint() + "]");
|
||||
}
|
||||
return endpoint;
|
||||
}
|
||||
else if (logger.isDebugEnabled()) {
|
||||
logger.debug("Endpoint mapping [" + endpointMapping + "] has no mapping for request");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Returns the endpoint for this request. All endpoint mappings are tried, in order.
|
||||
*
|
||||
* @return the {@code EndpointInvocationChain}, or {@code null} if no endpoint could be found.
|
||||
*/
|
||||
protected EndpointInvocationChain getEndpoint(MessageContext messageContext) throws Exception {
|
||||
for (EndpointMapping endpointMapping : getEndpointMappings()) {
|
||||
EndpointInvocationChain endpoint = endpointMapping.getEndpoint(messageContext);
|
||||
if (endpoint != null) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Endpoint mapping [" + endpointMapping + "] maps request to endpoint [" +
|
||||
endpoint.getEndpoint() + "]");
|
||||
}
|
||||
return endpoint;
|
||||
}
|
||||
else if (logger.isDebugEnabled()) {
|
||||
logger.debug("Endpoint mapping [" + endpointMapping + "] has no mapping for request");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@code EndpointAdapter} for the given endpoint.
|
||||
*
|
||||
* @param endpoint the endpoint to find an adapter for
|
||||
* @return the adapter
|
||||
*/
|
||||
protected EndpointAdapter getEndpointAdapter(Object endpoint) {
|
||||
for (EndpointAdapter endpointAdapter : getEndpointAdapters()) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Testing endpoint adapter [" + endpointAdapter + "]");
|
||||
}
|
||||
if (endpointAdapter.supports(endpoint)) {
|
||||
return endpointAdapter;
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException("No adapter for endpoint [" + endpoint + "]: Is your endpoint annotated with " +
|
||||
"@Endpoint, or does it implement a supported interface like MessageHandler or PayloadEndpoint?");
|
||||
}
|
||||
/**
|
||||
* Returns the {@code EndpointAdapter} for the given endpoint.
|
||||
*
|
||||
* @param endpoint the endpoint to find an adapter for
|
||||
* @return the adapter
|
||||
*/
|
||||
protected EndpointAdapter getEndpointAdapter(Object endpoint) {
|
||||
for (EndpointAdapter endpointAdapter : getEndpointAdapters()) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Testing endpoint adapter [" + endpointAdapter + "]");
|
||||
}
|
||||
if (endpointAdapter.supports(endpoint)) {
|
||||
return endpointAdapter;
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException("No adapter for endpoint [" + endpoint + "]: Is your endpoint annotated with " +
|
||||
"@Endpoint, or does it implement a supported interface like MessageHandler or PayloadEndpoint?");
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for pre-processing of given invocation chain and message context. Gets called before invocation of
|
||||
* {@code handleRequest} on the interceptors.
|
||||
*
|
||||
* <p>Default implementation does nothing, and returns {@code true}.
|
||||
*
|
||||
* @param mappedEndpoint the mapped {@code EndpointInvocationChain}
|
||||
* @param messageContext the message context
|
||||
* @return {@code true} if processing should continue; {@code false} otherwise
|
||||
*/
|
||||
protected boolean handleRequest(EndpointInvocationChain mappedEndpoint, MessageContext messageContext) {
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Callback for pre-processing of given invocation chain and message context. Gets called before invocation of
|
||||
* {@code handleRequest} on the interceptors.
|
||||
*
|
||||
* <p>Default implementation does nothing, and returns {@code true}.
|
||||
*
|
||||
* @param mappedEndpoint the mapped {@code EndpointInvocationChain}
|
||||
* @param messageContext the message context
|
||||
* @return {@code true} if processing should continue; {@code false} otherwise
|
||||
*/
|
||||
protected boolean handleRequest(EndpointInvocationChain mappedEndpoint, MessageContext messageContext) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine an error {@code SOAPMessage} response via the registered {@code EndpointExceptionResolvers}.
|
||||
* Most likely, the response contains a {@code SOAPFault}. If no suitable resolver was found, the exception is
|
||||
* rethrown.
|
||||
*
|
||||
* @param messageContext current SOAPMessage request
|
||||
* @param endpoint the executed endpoint, or null if none chosen at the time of the exception
|
||||
* @param ex the exception that got thrown during handler execution
|
||||
* @throws Exception if no suitable resolver is found
|
||||
*/
|
||||
protected void processEndpointException(MessageContext messageContext, Object endpoint, Exception ex)
|
||||
throws Exception {
|
||||
if (!CollectionUtils.isEmpty(getEndpointExceptionResolvers())) {
|
||||
for (EndpointExceptionResolver resolver : getEndpointExceptionResolvers()) {
|
||||
if (resolver.resolveException(messageContext, endpoint, ex)) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Endpoint invocation resulted in exception - responding with Fault", ex);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// exception not resolved
|
||||
throw ex;
|
||||
}
|
||||
/**
|
||||
* Determine an error {@code SOAPMessage} response via the registered {@code EndpointExceptionResolvers}.
|
||||
* Most likely, the response contains a {@code SOAPFault}. If no suitable resolver was found, the exception is
|
||||
* rethrown.
|
||||
*
|
||||
* @param messageContext current SOAPMessage request
|
||||
* @param endpoint the executed endpoint, or null if none chosen at the time of the exception
|
||||
* @param ex the exception that got thrown during handler execution
|
||||
* @throws Exception if no suitable resolver is found
|
||||
*/
|
||||
protected void processEndpointException(MessageContext messageContext, Object endpoint, Exception ex)
|
||||
throws Exception {
|
||||
if (!CollectionUtils.isEmpty(getEndpointExceptionResolvers())) {
|
||||
for (EndpointExceptionResolver resolver : getEndpointExceptionResolvers()) {
|
||||
if (resolver.resolveException(messageContext, endpoint, ex)) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Endpoint invocation resulted in exception - responding with Fault", ex);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// exception not resolved
|
||||
throw ex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger handleResponse or handleFault on the mapped EndpointInterceptors. Will just invoke said method on all
|
||||
* interceptors whose handleRequest invocation returned {@code true}, in addition to the last interceptor who
|
||||
* returned {@code false}.
|
||||
*
|
||||
* @param mappedEndpoint the mapped EndpointInvocationChain
|
||||
* @param interceptorIndex index of last interceptor that was called
|
||||
* @param messageContext the message context, whose request and response are filled
|
||||
* @see EndpointInterceptor#handleResponse(MessageContext,Object)
|
||||
* @see EndpointInterceptor#handleFault(MessageContext, Object)
|
||||
*/
|
||||
private void triggerHandleResponse(EndpointInvocationChain mappedEndpoint,
|
||||
int interceptorIndex,
|
||||
MessageContext messageContext) throws Exception {
|
||||
if (mappedEndpoint != null && messageContext.hasResponse() &&
|
||||
!ObjectUtils.isEmpty(mappedEndpoint.getInterceptors())) {
|
||||
boolean hasFault = false;
|
||||
WebServiceMessage response = messageContext.getResponse();
|
||||
if (response instanceof FaultAwareWebServiceMessage) {
|
||||
hasFault = ((FaultAwareWebServiceMessage) response).hasFault();
|
||||
}
|
||||
boolean resume = true;
|
||||
for (int i = interceptorIndex; resume && i >= 0; i--) {
|
||||
EndpointInterceptor interceptor = mappedEndpoint.getInterceptors()[i];
|
||||
if (!hasFault) {
|
||||
resume = interceptor.handleResponse(messageContext, mappedEndpoint.getEndpoint());
|
||||
}
|
||||
else {
|
||||
resume = interceptor.handleFault(messageContext, mappedEndpoint.getEndpoint());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Trigger handleResponse or handleFault on the mapped EndpointInterceptors. Will just invoke said method on all
|
||||
* interceptors whose handleRequest invocation returned {@code true}, in addition to the last interceptor who
|
||||
* returned {@code false}.
|
||||
*
|
||||
* @param mappedEndpoint the mapped EndpointInvocationChain
|
||||
* @param interceptorIndex index of last interceptor that was called
|
||||
* @param messageContext the message context, whose request and response are filled
|
||||
* @see EndpointInterceptor#handleResponse(MessageContext,Object)
|
||||
* @see EndpointInterceptor#handleFault(MessageContext, Object)
|
||||
*/
|
||||
private void triggerHandleResponse(EndpointInvocationChain mappedEndpoint,
|
||||
int interceptorIndex,
|
||||
MessageContext messageContext) throws Exception {
|
||||
if (mappedEndpoint != null && messageContext.hasResponse() &&
|
||||
!ObjectUtils.isEmpty(mappedEndpoint.getInterceptors())) {
|
||||
boolean hasFault = false;
|
||||
WebServiceMessage response = messageContext.getResponse();
|
||||
if (response instanceof FaultAwareWebServiceMessage) {
|
||||
hasFault = ((FaultAwareWebServiceMessage) response).hasFault();
|
||||
}
|
||||
boolean resume = true;
|
||||
for (int i = interceptorIndex; resume && i >= 0; i--) {
|
||||
EndpointInterceptor interceptor = mappedEndpoint.getInterceptors()[i];
|
||||
if (!hasFault) {
|
||||
resume = interceptor.handleResponse(messageContext, mappedEndpoint.getEndpoint());
|
||||
}
|
||||
else {
|
||||
resume = interceptor.handleFault(messageContext, mappedEndpoint.getEndpoint());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger afterCompletion callbacks on the mapped EndpointInterceptors.
|
||||
* Will just invoke afterCompletion for all interceptors whose handleRequest invocation
|
||||
* has successfully completed and returned true, in addition to the last interceptor who
|
||||
* returned {@code false}.
|
||||
*
|
||||
* @param mappedEndpoint the mapped EndpointInvocationChain
|
||||
* @param interceptorIndex index of last interceptor that successfully completed
|
||||
* @param ex Exception thrown on handler execution, or {@code null} if none
|
||||
* @see EndpointInterceptor#afterCompletion
|
||||
*/
|
||||
private void triggerAfterCompletion(EndpointInvocationChain mappedEndpoint,
|
||||
int interceptorIndex,
|
||||
MessageContext messageContext,
|
||||
Exception ex) throws Exception {
|
||||
/**
|
||||
* Trigger afterCompletion callbacks on the mapped EndpointInterceptors.
|
||||
* Will just invoke afterCompletion for all interceptors whose handleRequest invocation
|
||||
* has successfully completed and returned true, in addition to the last interceptor who
|
||||
* returned {@code false}.
|
||||
*
|
||||
* @param mappedEndpoint the mapped EndpointInvocationChain
|
||||
* @param interceptorIndex index of last interceptor that successfully completed
|
||||
* @param ex Exception thrown on handler execution, or {@code null} if none
|
||||
* @see EndpointInterceptor#afterCompletion
|
||||
*/
|
||||
private void triggerAfterCompletion(EndpointInvocationChain mappedEndpoint,
|
||||
int interceptorIndex,
|
||||
MessageContext messageContext,
|
||||
Exception ex) throws Exception {
|
||||
|
||||
// Apply afterCompletion methods of registered interceptors.
|
||||
if (mappedEndpoint != null) {
|
||||
EndpointInterceptor[] interceptors = mappedEndpoint.getInterceptors();
|
||||
if (interceptors != null) {
|
||||
for (int i = interceptorIndex; i >= 0; i--) {
|
||||
EndpointInterceptor interceptor = interceptors[i];
|
||||
try {
|
||||
interceptor.afterCompletion(messageContext, mappedEndpoint.getEndpoint(), ex);
|
||||
}
|
||||
catch (Throwable ex2) {
|
||||
logger.error("EndpointInterceptor.afterCompletion threw exception", ex2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Apply afterCompletion methods of registered interceptors.
|
||||
if (mappedEndpoint != null) {
|
||||
EndpointInterceptor[] interceptors = mappedEndpoint.getInterceptors();
|
||||
if (interceptors != null) {
|
||||
for (int i = interceptorIndex; i >= 0; i--) {
|
||||
EndpointInterceptor interceptor = interceptors[i];
|
||||
try {
|
||||
interceptor.afterCompletion(messageContext, mappedEndpoint.getEndpoint(), ex);
|
||||
}
|
||||
catch (Throwable ex2) {
|
||||
logger.error("EndpointInterceptor.afterCompletion threw exception", ex2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the {@code EndpointAdapters} used by this class. If no adapter beans are explicitly set by using
|
||||
* the {@code endpointAdapters} property, we use the default strategies.
|
||||
*
|
||||
* @see #setEndpointAdapters(java.util.List)
|
||||
*/
|
||||
private void initEndpointAdapters(ApplicationContext applicationContext) throws BeansException {
|
||||
if (endpointAdapters == null) {
|
||||
Map<String, EndpointAdapter> matchingBeans = BeanFactoryUtils
|
||||
.beansOfTypeIncludingAncestors(applicationContext, EndpointAdapter.class, true, false);
|
||||
if (!matchingBeans.isEmpty()) {
|
||||
endpointAdapters = new ArrayList<EndpointAdapter>(matchingBeans.values());
|
||||
Collections.sort(endpointAdapters, new OrderComparator());
|
||||
}
|
||||
else {
|
||||
endpointAdapters =
|
||||
defaultStrategiesHelper.getDefaultStrategies(EndpointAdapter.class, applicationContext);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("No EndpointAdapters found, using defaults");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Initialize the {@code EndpointAdapters} used by this class. If no adapter beans are explicitly set by using
|
||||
* the {@code endpointAdapters} property, we use the default strategies.
|
||||
*
|
||||
* @see #setEndpointAdapters(java.util.List)
|
||||
*/
|
||||
private void initEndpointAdapters(ApplicationContext applicationContext) throws BeansException {
|
||||
if (endpointAdapters == null) {
|
||||
Map<String, EndpointAdapter> matchingBeans = BeanFactoryUtils
|
||||
.beansOfTypeIncludingAncestors(applicationContext, EndpointAdapter.class, true, false);
|
||||
if (!matchingBeans.isEmpty()) {
|
||||
endpointAdapters = new ArrayList<EndpointAdapter>(matchingBeans.values());
|
||||
Collections.sort(endpointAdapters, new OrderComparator());
|
||||
}
|
||||
else {
|
||||
endpointAdapters =
|
||||
defaultStrategiesHelper.getDefaultStrategies(EndpointAdapter.class, applicationContext);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("No EndpointAdapters found, using defaults");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the {@code EndpointExceptionResolver} used by this class. If no resolver beans are explicitly set
|
||||
* by using the {@code endpointExceptionResolvers} property, we use the default strategies.
|
||||
*
|
||||
* @see #setEndpointExceptionResolvers(java.util.List)
|
||||
*/
|
||||
private void initEndpointExceptionResolvers(ApplicationContext applicationContext) throws BeansException {
|
||||
if (endpointExceptionResolvers == null) {
|
||||
Map<String, EndpointExceptionResolver> matchingBeans = BeanFactoryUtils
|
||||
.beansOfTypeIncludingAncestors(applicationContext, EndpointExceptionResolver.class, true, false);
|
||||
if (!matchingBeans.isEmpty()) {
|
||||
endpointExceptionResolvers = new ArrayList<EndpointExceptionResolver>(matchingBeans.values());
|
||||
Collections.sort(endpointExceptionResolvers, new OrderComparator());
|
||||
}
|
||||
else {
|
||||
endpointExceptionResolvers = defaultStrategiesHelper
|
||||
.getDefaultStrategies(EndpointExceptionResolver.class, applicationContext);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("No EndpointExceptionResolvers found, using defaults");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Initialize the {@code EndpointExceptionResolver} used by this class. If no resolver beans are explicitly set
|
||||
* by using the {@code endpointExceptionResolvers} property, we use the default strategies.
|
||||
*
|
||||
* @see #setEndpointExceptionResolvers(java.util.List)
|
||||
*/
|
||||
private void initEndpointExceptionResolvers(ApplicationContext applicationContext) throws BeansException {
|
||||
if (endpointExceptionResolvers == null) {
|
||||
Map<String, EndpointExceptionResolver> matchingBeans = BeanFactoryUtils
|
||||
.beansOfTypeIncludingAncestors(applicationContext, EndpointExceptionResolver.class, true, false);
|
||||
if (!matchingBeans.isEmpty()) {
|
||||
endpointExceptionResolvers = new ArrayList<EndpointExceptionResolver>(matchingBeans.values());
|
||||
Collections.sort(endpointExceptionResolvers, new OrderComparator());
|
||||
}
|
||||
else {
|
||||
endpointExceptionResolvers = defaultStrategiesHelper
|
||||
.getDefaultStrategies(EndpointExceptionResolver.class, applicationContext);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("No EndpointExceptionResolvers found, using defaults");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the {@code EndpointMappings} used by this class. If no mapping beans are explictely set by using
|
||||
* the {@code endpointMappings} property, we use the default strategies.
|
||||
*
|
||||
* @see #setEndpointMappings(java.util.List)
|
||||
*/
|
||||
private void initEndpointMappings(ApplicationContext applicationContext) throws BeansException {
|
||||
if (endpointMappings == null) {
|
||||
Map<String, EndpointMapping> matchingBeans = BeanFactoryUtils
|
||||
.beansOfTypeIncludingAncestors(applicationContext, EndpointMapping.class, true, false);
|
||||
if (!matchingBeans.isEmpty()) {
|
||||
endpointMappings = new ArrayList<EndpointMapping>(matchingBeans.values());
|
||||
Collections.sort(endpointMappings, new OrderComparator());
|
||||
}
|
||||
else {
|
||||
endpointMappings =
|
||||
defaultStrategiesHelper.getDefaultStrategies(EndpointMapping.class, applicationContext);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("No EndpointMappings found, using defaults");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Initialize the {@code EndpointMappings} used by this class. If no mapping beans are explictely set by using
|
||||
* the {@code endpointMappings} property, we use the default strategies.
|
||||
*
|
||||
* @see #setEndpointMappings(java.util.List)
|
||||
*/
|
||||
private void initEndpointMappings(ApplicationContext applicationContext) throws BeansException {
|
||||
if (endpointMappings == null) {
|
||||
Map<String, EndpointMapping> matchingBeans = BeanFactoryUtils
|
||||
.beansOfTypeIncludingAncestors(applicationContext, EndpointMapping.class, true, false);
|
||||
if (!matchingBeans.isEmpty()) {
|
||||
endpointMappings = new ArrayList<EndpointMapping>(matchingBeans.values());
|
||||
Collections.sort(endpointMappings, new OrderComparator());
|
||||
}
|
||||
else {
|
||||
endpointMappings =
|
||||
defaultStrategiesHelper.getDefaultStrategies(EndpointMapping.class, applicationContext);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("No EndpointMappings found, using defaults");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user