diff --git a/spring-integration-ws/src/main/java/org/springframework/integration/ws/config/WebServiceInboundGatewayParser.java b/spring-integration-ws/src/main/java/org/springframework/integration/ws/config/WebServiceInboundGatewayParser.java
index 3bad423846..475a1be4a8 100644
--- a/spring-integration-ws/src/main/java/org/springframework/integration/ws/config/WebServiceInboundGatewayParser.java
+++ b/spring-integration-ws/src/main/java/org/springframework/integration/ws/config/WebServiceInboundGatewayParser.java
@@ -13,16 +13,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.springframework.integration.ws.config;
import org.w3c.dom.Element;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.integration.config.xml.AbstractInboundGatewayParser;
+import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
/**
* @author Iwein Fuld
+ * @author Mark Fisher
*/
public class WebServiceInboundGatewayParser extends AbstractInboundGatewayParser {
@@ -48,6 +51,12 @@ public class WebServiceInboundGatewayParser extends AbstractInboundGatewayParser
builder.addConstructorArgReference(unmarshallerRef);
}
}
+ String headerMapperRef = element.getAttribute("header-mapper");
+ if (StringUtils.hasText(headerMapperRef)) {
+ Assert.isTrue(!StringUtils.hasText(marshallerRef),
+ "The 'header-mapper' attribute cannot be used when a 'marshaller' is provided.");
+ builder.addPropertyReference("headerMapper", headerMapperRef);
+ }
}
}
diff --git a/spring-integration-ws/src/main/resources/org/springframework/integration/ws/config/spring-integration-ws-2.0.xsd b/spring-integration-ws/src/main/resources/org/springframework/integration/ws/config/spring-integration-ws-2.0.xsd
index 7567e4ea64..51338510df 100644
--- a/spring-integration-ws/src/main/resources/org/springframework/integration/ws/config/spring-integration-ws-2.0.xsd
+++ b/spring-integration-ws/src/main/resources/org/springframework/integration/ws/config/spring-integration-ws-2.0.xsd
@@ -248,6 +248,21 @@
+
+
+
+ Reference to a HeaderMapper<SoapHeader> implementation
+ that this gateway will use to map between Spring Integration
+ MessageHeaders and the SoapHeader. This strategy can only be
+ applied when a 'marshaller' is not being configured.
+
+
+
+
+
+
+
+
diff --git a/spring-integration-ws/src/test/java/org/springframework/integration/ws/config/WebServiceInboundGatewayParserTests-context.xml b/spring-integration-ws/src/test/java/org/springframework/integration/ws/config/WebServiceInboundGatewayParserTests-context.xml
index b1e0a9bec0..a8f01e2a78 100644
--- a/spring-integration-ws/src/test/java/org/springframework/integration/ws/config/WebServiceInboundGatewayParserTests-context.xml
+++ b/spring-integration-ws/src/test/java/org/springframework/integration/ws/config/WebServiceInboundGatewayParserTests-context.xml
@@ -31,7 +31,17 @@
+
+
+
+
+
+
+
diff --git a/spring-integration-ws/src/test/java/org/springframework/integration/ws/config/WebServiceInboundGatewayParserTests.java b/spring-integration-ws/src/test/java/org/springframework/integration/ws/config/WebServiceInboundGatewayParserTests.java
index 1adddcf60d..5756a00a70 100644
--- a/spring-integration-ws/src/test/java/org/springframework/integration/ws/config/WebServiceInboundGatewayParserTests.java
+++ b/spring-integration-ws/src/test/java/org/springframework/integration/ws/config/WebServiceInboundGatewayParserTests.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.
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.springframework.integration.ws.config;
import static junit.framework.Assert.assertEquals;
@@ -23,6 +24,8 @@ import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+import java.util.Collections;
+import java.util.Map;
import java.util.Properties;
import javax.xml.transform.Source;
@@ -30,13 +33,16 @@ import javax.xml.transform.Source;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
+
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
+import org.springframework.integration.MessageHeaders;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.history.MessageHistory;
+import org.springframework.integration.mapping.HeaderMapper;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.integration.ws.MarshallingWebServiceInboundGateway;
import org.springframework.integration.ws.SimpleWebServiceInboundGateway;
@@ -46,12 +52,12 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.ws.context.DefaultMessageContext;
import org.springframework.ws.context.MessageContext;
+import org.springframework.ws.soap.SoapHeader;
/**
- *
* @author Iwein Fuld
* @author Oleg Zhurakousky
- *
+ * @author Mark Fisher
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
@@ -116,6 +122,7 @@ public class WebServiceInboundGatewayParserTests {
is(marshaller));
assertTrue("messaging gateway is not running", marshallingGateway.isRunning());
}
+
@Test
public void testMessageHistoryWithMarshallingGateway() throws Exception {
MessageContext context = new DefaultMessageContext(new StubMessageFactory());
@@ -130,6 +137,7 @@ public class WebServiceInboundGatewayParserTests {
assertNotNull(componentHistoryRecord);
assertEquals("ws:outbound-gateway", componentHistoryRecord.get("type"));
}
+
@Test
public void testMessageHistoryWithSimpleGateway() throws Exception {
MessageContext context = new DefaultMessageContext(new StubMessageFactory());
@@ -142,4 +150,30 @@ public class WebServiceInboundGatewayParserTests {
assertNotNull(componentHistoryRecord);
assertEquals("ws:outbound-gateway", componentHistoryRecord.get("type"));
}
+
+ @Autowired
+ private SimpleWebServiceInboundGateway headerMappingGateway;
+
+ @Autowired
+ private HeaderMapper testHeaderMapper;
+
+ @Test
+ public void testHeaderMapperReference() throws Exception {
+ DirectFieldAccessor accessor = new DirectFieldAccessor(headerMappingGateway);
+ Object headerMapper = accessor.getPropertyValue("headerMapper");
+ assertEquals(testHeaderMapper, headerMapper);
+ }
+
+
+ @SuppressWarnings("unused")
+ private static class TestHeaderMapper implements HeaderMapper {
+
+ public void fromHeaders(MessageHeaders headers, SoapHeader target) {
+ }
+
+ public Map toHeaders(SoapHeader source) {
+ return Collections.emptyMap();
+ }
+ }
+
}