diff --git a/org.springframework.integration.ws/src/main/java/org/springframework/integration/ws/AbstractWebServiceOutboundGateway.java b/org.springframework.integration.ws/src/main/java/org/springframework/integration/ws/AbstractWebServiceOutboundGateway.java
index 05ad08db9f..e75e92c108 100644
--- a/org.springframework.integration.ws/src/main/java/org/springframework/integration/ws/AbstractWebServiceOutboundGateway.java
+++ b/org.springframework.integration.ws/src/main/java/org/springframework/integration/ws/AbstractWebServiceOutboundGateway.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2009 the original author or authors.
+ * Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@ import org.springframework.ws.client.core.FaultMessageResolver;
import org.springframework.ws.client.core.WebServiceMessageCallback;
import org.springframework.ws.client.core.WebServiceTemplate;
import org.springframework.ws.client.support.destination.DestinationProvider;
+import org.springframework.ws.client.support.interceptor.ClientInterceptor;
import org.springframework.ws.soap.SoapMessage;
import org.springframework.ws.soap.client.core.SoapActionCallback;
import org.springframework.ws.transport.WebServiceMessageSender;
@@ -90,6 +91,10 @@ public abstract class AbstractWebServiceOutboundGateway extends AbstractReplyPro
this.webServiceTemplate.setMessageSenders(messageSenders);
}
+ public void setInterceptors(ClientInterceptor[] interceptors) {
+ this.webServiceTemplate.setInterceptors(interceptors);
+ }
+
protected WebServiceTemplate getWebServiceTemplate() {
return this.webServiceTemplate;
}
diff --git a/org.springframework.integration.ws/src/main/java/org/springframework/integration/ws/config/WebServiceOutboundGatewayParser.java b/org.springframework.integration.ws/src/main/java/org/springframework/integration/ws/config/WebServiceOutboundGatewayParser.java
index e99751ed28..f3b873e2c1 100644
--- a/org.springframework.integration.ws/src/main/java/org/springframework/integration/ws/config/WebServiceOutboundGatewayParser.java
+++ b/org.springframework.integration.ws/src/main/java/org/springframework/integration/ws/config/WebServiceOutboundGatewayParser.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2009 the original author or authors.
+ * Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,9 @@ package org.springframework.integration.ws.config;
import org.w3c.dom.Element;
import org.springframework.beans.factory.config.ConstructorArgumentValues;
+import org.springframework.beans.factory.config.RuntimeBeanReference;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.support.ManagedList;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.integration.adapter.config.AbstractRemotingOutboundGatewayParser;
@@ -73,6 +75,7 @@ public class WebServiceOutboundGatewayParser extends AbstractRemotingOutboundGat
}
@Override
+ @SuppressWarnings("unchecked")
protected void postProcessGateway(BeanDefinitionBuilder builder, Element element, ParserContext parserContext) {
String marshallerRef = element.getAttribute("marshaller");
if (StringUtils.hasText(marshallerRef)) {
@@ -115,6 +118,20 @@ public class WebServiceOutboundGatewayParser extends AbstractRemotingOutboundGat
if (StringUtils.hasText(messageSenderListRef)) {
builder.addPropertyReference("messageSenders", messageSenderListRef);
}
+ String interceptorRef = element.getAttribute("interceptor");
+ String interceptorListRef = element.getAttribute("interceptors");
+ if (StringUtils.hasText(interceptorRef) && StringUtils.hasText(interceptorListRef)) {
+ parserContext.getReaderContext().error(
+ "Only one of interceptor or interceptors should be specified.", element);
+ }
+ if (StringUtils.hasText(interceptorRef)) {
+ ManagedList interceptors = new ManagedList();
+ interceptors.add(new RuntimeBeanReference(interceptorRef));
+ builder.addPropertyValue("interceptors", interceptors);
+ }
+ if (StringUtils.hasText(interceptorListRef)) {
+ builder.addPropertyReference("interceptors", interceptorListRef);
+ }
}
}
diff --git a/org.springframework.integration.ws/src/main/resources/org/springframework/integration/ws/config/spring-integration-ws-1.0.xsd b/org.springframework.integration.ws/src/main/resources/org/springframework/integration/ws/config/spring-integration-ws-1.0.xsd
index 7a0469f903..fe50202862 100644
--- a/org.springframework.integration.ws/src/main/resources/org/springframework/integration/ws/config/spring-integration-ws-1.0.xsd
+++ b/org.springframework.integration.ws/src/main/resources/org/springframework/integration/ws/config/spring-integration-ws-1.0.xsd
@@ -162,6 +162,9 @@
+
+ Reference to the bean definition of a WebServiceMessageSender.
+
@@ -169,7 +172,32 @@
-
+
+
+
+ Reference to the bean definition for a list or array of WebServiceMessageSenders.
+
+
+
+
+
+
+ Reference to the bean definition of a ClientInterceptor.
+
+
+
+
+
+
+
+
+
+
+
+ Reference to the bean definition for a list or array of ClientInterceptors.
+
+
+
diff --git a/org.springframework.integration.ws/src/test/java/org/springframework/integration/ws/config/StubClientInterceptor.java b/org.springframework.integration.ws/src/test/java/org/springframework/integration/ws/config/StubClientInterceptor.java
new file mode 100644
index 0000000000..a7cee6f230
--- /dev/null
+++ b/org.springframework.integration.ws/src/test/java/org/springframework/integration/ws/config/StubClientInterceptor.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2002-2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.integration.ws.config;
+
+import org.springframework.ws.client.WebServiceClientException;
+import org.springframework.ws.client.support.interceptor.ClientInterceptor;
+import org.springframework.ws.context.MessageContext;
+
+/**
+ * @author Mark Fisher
+ */
+public class StubClientInterceptor implements ClientInterceptor {
+
+ public boolean handleRequest(MessageContext context) throws WebServiceClientException {
+ return true;
+ }
+
+ public boolean handleResponse(MessageContext context) throws WebServiceClientException {
+ return true;
+ }
+
+ public boolean handleFault(MessageContext context) throws WebServiceClientException {
+ return false;
+ }
+
+}
diff --git a/org.springframework.integration.ws/src/test/java/org/springframework/integration/ws/config/WebServiceOutboundGatewayParserTests.java b/org.springframework.integration.ws/src/test/java/org/springframework/integration/ws/config/WebServiceOutboundGatewayParserTests.java
index e62ded0e28..dd1afe474e 100644
--- a/org.springframework.integration.ws/src/test/java/org/springframework/integration/ws/config/WebServiceOutboundGatewayParserTests.java
+++ b/org.springframework.integration.ws/src/test/java/org/springframework/integration/ws/config/WebServiceOutboundGatewayParserTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2009 the original author or authors.
+ * Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,6 +36,7 @@ import org.springframework.ws.WebServiceMessageFactory;
import org.springframework.ws.client.core.FaultMessageResolver;
import org.springframework.ws.client.core.SourceExtractor;
import org.springframework.ws.client.core.WebServiceMessageCallback;
+import org.springframework.ws.client.support.interceptor.ClientInterceptor;
import org.springframework.ws.transport.WebServiceMessageSender;
/**
@@ -192,6 +193,35 @@ public class WebServiceOutboundGatewayParserTests {
2 , ((WebServiceMessageSender[])accessor.getPropertyValue("messageSenders")).length);
}
+ @Test
+ public void simpleGatewayWithCustomInterceptor() {
+ ApplicationContext context = new ClassPathXmlApplicationContext(
+ "simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
+ AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithCustomInterceptor");
+ assertEquals(EventDrivenConsumer.class, endpoint.getClass());
+ Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("handler");
+ assertEquals(SimpleWebServiceOutboundGateway.class, gateway.getClass());
+ DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
+ accessor = new DirectFieldAccessor(accessor.getPropertyValue("webServiceTemplate"));
+ ClientInterceptor interceptor = (ClientInterceptor) context.getBean("interceptor");
+ assertEquals(interceptor, ((ClientInterceptor[]) accessor.getPropertyValue("interceptors"))[0]);
+ }
+ @Test
+ public void simpleGatewayWithCustomInterceptorList() {
+ ApplicationContext context = new ClassPathXmlApplicationContext(
+ "simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
+ AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithCustomInterceptorList");
+ assertEquals(EventDrivenConsumer.class, endpoint.getClass());
+ Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("handler");
+ assertEquals(SimpleWebServiceOutboundGateway.class, gateway.getClass());
+ DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
+ accessor = new DirectFieldAccessor(accessor.getPropertyValue("webServiceTemplate"));
+ ClientInterceptor interceptor = (ClientInterceptor) context.getBean("interceptor");
+ assertEquals(interceptor, ((ClientInterceptor[]) accessor.getPropertyValue("interceptors"))[0]);
+ assertEquals("Wrong number of interceptors ",
+ 2 , ((ClientInterceptor[]) accessor.getPropertyValue("interceptors")).length);
+ }
+
@Test
public void simpleGatewayWithPoller() {
ApplicationContext context = new ClassPathXmlApplicationContext(
diff --git a/org.springframework.integration.ws/src/test/java/org/springframework/integration/ws/config/simpleWebServiceOutboundGatewayParserTests.xml b/org.springframework.integration.ws/src/test/java/org/springframework/integration/ws/config/simpleWebServiceOutboundGatewayParserTests.xml
index 5dbb8877a5..bcd1957c37 100644
--- a/org.springframework.integration.ws/src/test/java/org/springframework/integration/ws/config/simpleWebServiceOutboundGatewayParserTests.xml
+++ b/org.springframework.integration.ws/src/test/java/org/springframework/integration/ws/config/simpleWebServiceOutboundGatewayParserTests.xml
@@ -72,6 +72,16 @@
request-channel="inputChannel"
uri="http://example.org"
message-senders="messageSenders"/>
+
+
+
+
+
+
+
+
+
+