diff --git a/org.springframework.integration.ws/src/main/java/org/springframework/integration/ws/config/WebServiceHandlerParser.java b/org.springframework.integration.ws/src/main/java/org/springframework/integration/ws/config/WebServiceHandlerParser.java index 2206145b21..fa7c43d41a 100644 --- a/org.springframework.integration.ws/src/main/java/org/springframework/integration/ws/config/WebServiceHandlerParser.java +++ b/org.springframework.integration.ws/src/main/java/org/springframework/integration/ws/config/WebServiceHandlerParser.java @@ -18,6 +18,7 @@ package org.springframework.integration.ws.config; import org.w3c.dom.Element; +import org.springframework.beans.factory.config.RuntimeBeanReference; import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser; import org.springframework.beans.factory.xml.ParserContext; @@ -25,6 +26,8 @@ import org.springframework.integration.ConfigurationException; import org.springframework.integration.ws.handler.MarshallingWebServiceHandler; import org.springframework.integration.ws.handler.SimpleWebServiceHandler; import org.springframework.util.StringUtils; +import org.springframework.ws.WebServiceMessageFactory; +import org.springframework.ws.client.core.SourceExtractor; /** * Parser for the <ws-handler/> element. @@ -67,17 +70,22 @@ public class WebServiceHandlerParser extends AbstractSingleBeanDefinitionParser else { String sourceExtractorRef = element.getAttribute("source-extractor"); if (StringUtils.hasText(sourceExtractorRef)) { - builder.addConstructorArgReference(sourceExtractorRef); + builder.getBeanDefinition().getConstructorArgumentValues().addGenericArgumentValue( + new RuntimeBeanReference(sourceExtractorRef), SourceExtractor.class.getName()); } + else { + builder.addConstructorArgValue(null); + } + } + String messageFactoryRef = element.getAttribute("message-factory"); + if (StringUtils.hasText(messageFactoryRef)) { + builder.getBeanDefinition().getConstructorArgumentValues().addGenericArgumentValue( + new RuntimeBeanReference(messageFactoryRef), WebServiceMessageFactory.class.getName()); } String requestCallbackRef = element.getAttribute("request-callback"); if (StringUtils.hasText(requestCallbackRef)) { builder.addPropertyReference("requestCallback", requestCallbackRef); } - String messageFactoryRef = element.getAttribute("message-factory"); - if (StringUtils.hasText(messageFactoryRef)) { - builder.addPropertyReference("messageFactory", messageFactoryRef); - } String faultMessageResolverRef = element.getAttribute("fault-message-resolver"); if (StringUtils.hasText(faultMessageResolverRef)) { builder.addPropertyReference("faultMessageResolver", faultMessageResolverRef); diff --git a/org.springframework.integration.ws/src/main/java/org/springframework/integration/ws/handler/AbstractWebServiceHandler.java b/org.springframework.integration.ws/src/main/java/org/springframework/integration/ws/handler/AbstractWebServiceHandler.java index 3330833e82..eb208e00ab 100644 --- a/org.springframework.integration.ws/src/main/java/org/springframework/integration/ws/handler/AbstractWebServiceHandler.java +++ b/org.springframework.integration.ws/src/main/java/org/springframework/integration/ws/handler/AbstractWebServiceHandler.java @@ -41,13 +41,15 @@ public abstract class AbstractWebServiceHandler implements MessageHandler { public static final String SOAP_ACTION_PROPERTY_KEY = "_ws.soapAction"; - private final WebServiceTemplate webServiceTemplate = new WebServiceTemplate(); + private final WebServiceTemplate webServiceTemplate; private volatile WebServiceMessageCallback requestCallback; - public AbstractWebServiceHandler(URI uri) { + public AbstractWebServiceHandler(URI uri, WebServiceMessageFactory messageFactory) { Assert.notNull(uri, "URI must not be null"); + this.webServiceTemplate = (messageFactory != null) ? + new WebServiceTemplate(messageFactory) : new WebServiceTemplate(); this.webServiceTemplate.setDefaultUri(uri.toString()); } diff --git a/org.springframework.integration.ws/src/main/java/org/springframework/integration/ws/handler/MarshallingWebServiceHandler.java b/org.springframework.integration.ws/src/main/java/org/springframework/integration/ws/handler/MarshallingWebServiceHandler.java index 44b8b8c445..7190650655 100644 --- a/org.springframework.integration.ws/src/main/java/org/springframework/integration/ws/handler/MarshallingWebServiceHandler.java +++ b/org.springframework.integration.ws/src/main/java/org/springframework/integration/ws/handler/MarshallingWebServiceHandler.java @@ -21,6 +21,7 @@ import java.net.URI; import org.springframework.oxm.Marshaller; import org.springframework.oxm.Unmarshaller; import org.springframework.util.Assert; +import org.springframework.ws.WebServiceMessageFactory; import org.springframework.ws.client.core.WebServiceMessageCallback; /** @@ -32,23 +33,31 @@ import org.springframework.ws.client.core.WebServiceMessageCallback; */ public class MarshallingWebServiceHandler extends AbstractWebServiceHandler { - public MarshallingWebServiceHandler(URI uri, Marshaller marshaller, Unmarshaller unmarshaller) { - super(uri); + public MarshallingWebServiceHandler(URI uri, Marshaller marshaller, Unmarshaller unmarshaller, WebServiceMessageFactory messageFactory) { + super(uri, messageFactory); Assert.notNull(marshaller, "marshaller must not be null"); Assert.notNull(unmarshaller, "unmarshaller must not be null"); this.getWebServiceTemplate().setMarshaller(marshaller); this.getWebServiceTemplate().setUnmarshaller(unmarshaller); } - public MarshallingWebServiceHandler(URI uri, Marshaller marshaller) { - super(uri); + public MarshallingWebServiceHandler(URI uri, Marshaller marshaller, Unmarshaller unmarshaller) { + this(uri, marshaller, unmarshaller, null); + } + + public MarshallingWebServiceHandler(URI uri, Marshaller marshaller, WebServiceMessageFactory messageFactory) { + super(uri, messageFactory); Assert.notNull(marshaller, "marshaller must not be null"); Assert.isInstanceOf(Unmarshaller.class, marshaller, "Marshaller [" + marshaller + "] does not implement the Unmarshaller interface. " + "Please set an Unmarshaller explicitly by using the " + this.getClass().getName() + "(String uri, Marshaller marshaller, Unmarshaller unmarshaller) constructor."); this.getWebServiceTemplate().setMarshaller(marshaller); - this.getWebServiceTemplate().setUnmarshaller((Unmarshaller) marshaller); + this.getWebServiceTemplate().setUnmarshaller((Unmarshaller) marshaller); + } + + public MarshallingWebServiceHandler(URI uri, Marshaller marshaller) { + this(uri, marshaller, (WebServiceMessageFactory) null); } diff --git a/org.springframework.integration.ws/src/main/java/org/springframework/integration/ws/handler/SimpleWebServiceHandler.java b/org.springframework.integration.ws/src/main/java/org/springframework/integration/ws/handler/SimpleWebServiceHandler.java index 72da58be61..0d7305c156 100644 --- a/org.springframework.integration.ws/src/main/java/org/springframework/integration/ws/handler/SimpleWebServiceHandler.java +++ b/org.springframework.integration.ws/src/main/java/org/springframework/integration/ws/handler/SimpleWebServiceHandler.java @@ -25,6 +25,7 @@ import javax.xml.transform.dom.DOMResult; import javax.xml.transform.dom.DOMSource; import org.springframework.integration.message.MessagingException; +import org.springframework.ws.WebServiceMessageFactory; import org.springframework.ws.client.core.SourceExtractor; import org.springframework.ws.client.core.WebServiceMessageCallback; import org.springframework.xml.transform.StringResult; @@ -42,11 +43,15 @@ public class SimpleWebServiceHandler extends AbstractWebServiceHandler { public SimpleWebServiceHandler(URI uri) { - this(uri, null); + this(uri, null, null); } public SimpleWebServiceHandler(URI uri, SourceExtractor sourceExtractor) { - super(uri); + this(uri, sourceExtractor, (WebServiceMessageFactory) null); + } + + public SimpleWebServiceHandler(URI uri, SourceExtractor sourceExtractor, WebServiceMessageFactory messageFactory) { + super(uri, messageFactory); this.sourceExtractor = (sourceExtractor != null) ? sourceExtractor : new DefaultSourceExtractor(); }