WebServiceHandler classes are now WebServiceOutboundGateways. The "service-activator" element has also been replaced with <ws:outbound-gateway/> (INT-404).

This commit is contained in:
Mark Fisher
2008-10-08 18:25:32 +00:00
parent 7f35402b37
commit 4ddfc680ae
13 changed files with 263 additions and 261 deletions

View File

@@ -14,11 +14,12 @@
* limitations under the License.
*/
package org.springframework.integration.ws.handler;
package org.springframework.integration.ws;
import java.io.IOException;
import java.net.URI;
import org.springframework.integration.channel.MessageChannel;
import org.springframework.integration.endpoint.AbstractReplyProducingMessageConsumer;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.message.Message;
@@ -33,13 +34,13 @@ import org.springframework.ws.soap.client.core.SoapActionCallback;
import org.springframework.ws.transport.WebServiceMessageSender;
/**
* Base class for outbound Web Service-invoking adapters.
* Base class for outbound Web Service-invoking Messaging Gateways.
*
* @author Mark Fisher
*/
public abstract class AbstractWebServiceHandler extends AbstractReplyProducingMessageConsumer {
public abstract class AbstractWebServiceOutboundGateway extends AbstractReplyProducingMessageConsumer {
public static final String SOAP_ACTION_PROPERTY_KEY = "_ws.soapAction";
public static final String SOAP_ACTION_PROPERTY_KEY = "spring.integration.ws.soapAction";
private final WebServiceTemplate webServiceTemplate;
@@ -47,7 +48,7 @@ public abstract class AbstractWebServiceHandler extends AbstractReplyProducingMe
private volatile WebServiceMessageCallback requestCallback;
public AbstractWebServiceHandler(URI uri, WebServiceMessageFactory messageFactory) {
public AbstractWebServiceOutboundGateway(URI uri, WebServiceMessageFactory messageFactory) {
Assert.notNull(uri, "URI must not be null");
this.webServiceTemplate = (messageFactory != null) ?
new WebServiceTemplate(messageFactory) : new WebServiceTemplate();
@@ -55,6 +56,10 @@ public abstract class AbstractWebServiceHandler extends AbstractReplyProducingMe
}
public void setReplyChannel(MessageChannel replyChannel) {
this.setOutputChannel(replyChannel);
}
public void setMessageFactory(WebServiceMessageFactory messageFactory) {
this.webServiceTemplate.setMessageFactory(messageFactory);
}
@@ -66,7 +71,7 @@ public abstract class AbstractWebServiceHandler extends AbstractReplyProducingMe
public void setFaultMessageResolver(FaultMessageResolver faultMessageResolver) {
this.webServiceTemplate.setFaultMessageResolver(faultMessageResolver);
}
public void setMessageSender(WebServiceMessageSender messageSender) {
this.webServiceTemplate.setMessageSender(messageSender);
}
@@ -74,7 +79,7 @@ public abstract class AbstractWebServiceHandler extends AbstractReplyProducingMe
public void setMessageSenders(WebServiceMessageSender[] messageSenders) {
this.webServiceTemplate.setMessageSenders(messageSenders);
}
protected WebServiceTemplate getWebServiceTemplate() {
return this.webServiceTemplate;
}

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.ws.handler;
package org.springframework.integration.ws;
import java.net.URI;
@@ -25,15 +25,16 @@ import org.springframework.ws.WebServiceMessageFactory;
import org.springframework.ws.client.core.WebServiceMessageCallback;
/**
* A marshalling Web Service MessageHandler adapter.
* An outbound Messaging Gateway for invoking Web Services that also supports
* marshalling and unmarshalling of the request and response messages.
*
* @author Mark Fisher
* @see Marshaller
* @see Unmarshaller
*/
public class MarshallingWebServiceHandler extends AbstractWebServiceHandler {
public class MarshallingWebServiceOutboundGateway extends AbstractWebServiceOutboundGateway {
public MarshallingWebServiceHandler(URI uri, Marshaller marshaller, Unmarshaller unmarshaller, WebServiceMessageFactory messageFactory) {
public MarshallingWebServiceOutboundGateway(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");
@@ -41,11 +42,11 @@ public class MarshallingWebServiceHandler extends AbstractWebServiceHandler {
this.getWebServiceTemplate().setUnmarshaller(unmarshaller);
}
public MarshallingWebServiceHandler(URI uri, Marshaller marshaller, Unmarshaller unmarshaller) {
public MarshallingWebServiceOutboundGateway(URI uri, Marshaller marshaller, Unmarshaller unmarshaller) {
this(uri, marshaller, unmarshaller, null);
}
public MarshallingWebServiceHandler(URI uri, Marshaller marshaller, WebServiceMessageFactory messageFactory) {
public MarshallingWebServiceOutboundGateway(URI uri, Marshaller marshaller, WebServiceMessageFactory messageFactory) {
super(uri, messageFactory);
Assert.notNull(marshaller, "marshaller must not be null");
Assert.isInstanceOf(Unmarshaller.class, marshaller,
@@ -56,7 +57,7 @@ public class MarshallingWebServiceHandler extends AbstractWebServiceHandler {
this.getWebServiceTemplate().setUnmarshaller((Unmarshaller) marshaller);
}
public MarshallingWebServiceHandler(URI uri, Marshaller marshaller) {
public MarshallingWebServiceOutboundGateway(URI uri, Marshaller marshaller) {
this(uri, marshaller, (WebServiceMessageFactory) null);
}

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.ws.handler;
package org.springframework.integration.ws;
import java.io.IOException;
import java.net.URI;
@@ -24,6 +24,8 @@ import javax.xml.transform.TransformerException;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
import org.w3c.dom.Document;
import org.springframework.integration.message.MessagingException;
import org.springframework.ws.WebServiceMessageFactory;
import org.springframework.ws.client.core.SourceExtractor;
@@ -31,27 +33,26 @@ import org.springframework.ws.client.core.WebServiceMessageCallback;
import org.springframework.xml.transform.StringResult;
import org.springframework.xml.transform.StringSource;
import org.springframework.xml.transform.TransformerObjectSupport;
import org.w3c.dom.Document;
/**
* A MessageHandler adapter for invoking a Web Service.
* An outbound Messaging Gateway for invoking a Web Service.
*
* @author Mark Fisher
*/
public class SimpleWebServiceHandler extends AbstractWebServiceHandler {
public class SimpleWebServiceOutboundGateway extends AbstractWebServiceOutboundGateway {
private final SourceExtractor sourceExtractor;
public SimpleWebServiceHandler(URI uri) {
public SimpleWebServiceOutboundGateway(URI uri) {
this(uri, null, null);
}
public SimpleWebServiceHandler(URI uri, SourceExtractor sourceExtractor) {
public SimpleWebServiceOutboundGateway(URI uri, SourceExtractor sourceExtractor) {
this(uri, sourceExtractor, (WebServiceMessageFactory) null);
}
public SimpleWebServiceHandler(URI uri, SourceExtractor sourceExtractor, WebServiceMessageFactory messageFactory) {
public SimpleWebServiceOutboundGateway(URI uri, SourceExtractor sourceExtractor, WebServiceMessageFactory messageFactory) {
super(uri, messageFactory);
this.sourceExtractor = (sourceExtractor != null) ? sourceExtractor : new DefaultSourceExtractor();
}
@@ -69,16 +70,16 @@ public class SimpleWebServiceHandler extends AbstractWebServiceHandler {
new StringSource((String) requestPayload), requestCallback, result);
return result.toString();
}
if(requestPayload instanceof Document){
if (requestPayload instanceof Document) {
DOMResult result = new DOMResult();
this.getWebServiceTemplate().sendSourceAndReceiveToResult(
new DOMSource((Document) requestPayload), requestCallback, result);
return (Document)result.getNode();
}
throw new MessagingException("Unsupported payload type '" + requestPayload.getClass() +
"'. " + this.getClass().getName() + " only supports 'java.lang.String' and '" + Source.class.getName() +
"'. Consider using the '" + MarshallingWebServiceHandler.class.getName() + "' instead.");
"'. " + this.getClass().getName() + " only supports 'java.lang.String', '" + Source.class.getName() +
"', and '" + Document.class.getName() + "'. Consider either using the '"
+ MarshallingWebServiceOutboundGateway.class.getName() + "' or a Message Transformer.");
}

View File

@@ -20,27 +20,22 @@ import org.w3c.dom.Element;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.integration.adapter.config.AbstractRemotingOutboundGatewayParser;
import org.springframework.integration.ws.handler.MarshallingWebServiceHandler;
import org.springframework.integration.ws.handler.SimpleWebServiceHandler;
import org.springframework.integration.ws.MarshallingWebServiceOutboundGateway;
import org.springframework.integration.ws.SimpleWebServiceOutboundGateway;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
/**
* Parser for the &lt;ws-handler/&gt; element.
* Parser for the &lt;outbound-gateway/&gt; element in the 'ws' namespace.
*
* @author Mark Fisher
*/
public class WebServiceHandlerParser extends AbstractRemotingOutboundGatewayParser {
public class WebServiceOutboundGatewayParser extends AbstractRemotingOutboundGatewayParser {
@Override
protected Class<?> getGatewayClass(Element element) {
return (StringUtils.hasText(element.getAttribute("marshaller"))) ?
MarshallingWebServiceHandler.class : SimpleWebServiceHandler.class;
}
@Override
protected String getInputChannelAttributeName() {
return "input-channel";
MarshallingWebServiceOutboundGateway.class : SimpleWebServiceOutboundGateway.class;
}
@Override

View File

@@ -24,7 +24,7 @@ import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
public class WsNamespaceHandler extends NamespaceHandlerSupport {
public void init() {
this.registerBeanDefinitionParser("service-activator", new WebServiceHandlerParser());
this.registerBeanDefinitionParser("outbound-gateway", new WebServiceOutboundGatewayParser());
}
}

View File

@@ -18,19 +18,19 @@
]]></xsd:documentation>
</xsd:annotation>
<xsd:element name="service-activator">
<xsd:element name="outbound-gateway">
<xsd:complexType>
<xsd:annotation>
<xsd:documentation>
Defines a Web Service based Service Activator endpoint.
Defines a Web Service based outbound Messaging Gateway.
</xsd:documentation>
</xsd:annotation>
<xsd:all>
<xsd:element ref="integration:poller" minOccurs="0" maxOccurs="1" />
<xsd:element ref="integration:poller" minOccurs="0" maxOccurs="1"/>
</xsd:all>
<xsd:attribute name="id" type="xsd:string"/>
<xsd:attribute name="input-channel" type="xsd:string" use="required"/>
<xsd:attribute name="output-channel" type="xsd:string"/>
<xsd:attribute name="request-channel" type="xsd:string" use="required"/>
<xsd:attribute name="reply-channel" type="xsd:string"/>
<xsd:attribute name="uri" type="xsd:string" use="required"/>
<xsd:attribute name="marshaller" type="xsd:string"/>
<xsd:attribute name="unmarshaller" type="xsd:string"/>

View File

@@ -27,8 +27,8 @@ import org.springframework.integration.endpoint.MessageEndpoint;
import org.springframework.integration.endpoint.PollingConsumerEndpoint;
import org.springframework.integration.endpoint.SubscribingConsumerEndpoint;
import org.springframework.integration.scheduling.IntervalTrigger;
import org.springframework.integration.ws.handler.MarshallingWebServiceHandler;
import org.springframework.integration.ws.handler.SimpleWebServiceHandler;
import org.springframework.integration.ws.MarshallingWebServiceOutboundGateway;
import org.springframework.integration.ws.SimpleWebServiceOutboundGateway;
import org.springframework.oxm.Marshaller;
import org.springframework.oxm.Unmarshaller;
import org.springframework.ws.WebServiceMessageFactory;
@@ -40,54 +40,54 @@ import org.springframework.ws.transport.WebServiceMessageSender;
/**
* @author Mark Fisher
*/
public class WebServiceHandlerParserTests {
public class WebServiceOutboundGatewayParserTests {
@Test
public void testSimpleWebServiceHandlerWithDefaultSourceExtractor() {
public void simpleGatewayWithDefaultSourceExtractor() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"simpleWebServiceHandlerParserTests.xml", this.getClass());
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("handlerWithDefaultSourceExtractor");
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("gatewayWithDefaultSourceExtractor");
assertEquals(SubscribingConsumerEndpoint.class, endpoint.getClass());
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("consumer");
assertEquals(SimpleWebServiceHandler.class, gateway.getClass());
assertEquals(SimpleWebServiceOutboundGateway.class, gateway.getClass());
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
assertEquals("DefaultSourceExtractor", accessor.getPropertyValue("sourceExtractor").getClass().getSimpleName());
}
@Test
public void testSimpleWebServiceHandlerWithCustomSourceExtractor() {
public void simpleGatewayWithCustomSourceExtractor() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"simpleWebServiceHandlerParserTests.xml", this.getClass());
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("handlerWithCustomSourceExtractor");
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("gatewayWithCustomSourceExtractor");
assertEquals(SubscribingConsumerEndpoint.class, endpoint.getClass());
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("consumer");
assertEquals(SimpleWebServiceHandler.class, gateway.getClass());
assertEquals(SimpleWebServiceOutboundGateway.class, gateway.getClass());
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
SourceExtractor sourceExtractor = (SourceExtractor) context.getBean("sourceExtractor");
assertEquals(sourceExtractor, accessor.getPropertyValue("sourceExtractor"));
}
@Test
public void testSimpleWebServiceHandlerWithCustomRequestCallback() {
public void simpleGatewayWithCustomRequestCallback() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"simpleWebServiceHandlerParserTests.xml", this.getClass());
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("handlerWithCustomRequestCallback");
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("gatewayWithCustomRequestCallback");
assertEquals(SubscribingConsumerEndpoint.class, endpoint.getClass());
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("consumer");
assertEquals(SimpleWebServiceHandler.class, gateway.getClass());
assertEquals(SimpleWebServiceOutboundGateway.class, gateway.getClass());
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
WebServiceMessageCallback callback = (WebServiceMessageCallback) context.getBean("requestCallback");
assertEquals(callback, accessor.getPropertyValue("requestCallback"));
}
@Test
public void testSimpleWebServiceHandlerWithCustomMessageFactory() {
public void simpleGatewayWithCustomMessageFactory() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"simpleWebServiceHandlerParserTests.xml", this.getClass());
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("handlerWithCustomMessageFactory");
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("gatewayWithCustomMessageFactory");
assertEquals(SubscribingConsumerEndpoint.class, endpoint.getClass());
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("consumer");
assertEquals(SimpleWebServiceHandler.class, gateway.getClass());
assertEquals(SimpleWebServiceOutboundGateway.class, gateway.getClass());
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
accessor = new DirectFieldAccessor(accessor.getPropertyValue("webServiceTemplate"));
WebServiceMessageFactory factory = (WebServiceMessageFactory) context.getBean("messageFactory");
@@ -95,14 +95,14 @@ public class WebServiceHandlerParserTests {
}
@Test
public void testSimpleWebServiceHandlerWithCustomSourceExtractorAndMessageFactory() {
public void simpleGatewayWithCustomSourceExtractorAndMessageFactory() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"simpleWebServiceHandlerParserTests.xml", this.getClass());
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("handlerWithCustomSourceExtractorAndMessageFactory");
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("gatewayWithCustomSourceExtractorAndMessageFactory");
SourceExtractor sourceExtractor = (SourceExtractor) context.getBean("sourceExtractor");
assertEquals(SubscribingConsumerEndpoint.class, endpoint.getClass());
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("consumer");
assertEquals(SimpleWebServiceHandler.class, gateway.getClass());
assertEquals(SimpleWebServiceOutboundGateway.class, gateway.getClass());
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
assertEquals(sourceExtractor, accessor.getPropertyValue("sourceExtractor"));
accessor = new DirectFieldAccessor(accessor.getPropertyValue("webServiceTemplate"));
@@ -111,13 +111,13 @@ public class WebServiceHandlerParserTests {
}
@Test
public void testSimpleWebServiceHandlerWithCustomFaultMessageResolver() {
public void simpleGatewayWithCustomFaultMessageResolver() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"simpleWebServiceHandlerParserTests.xml", this.getClass());
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("handlerWithCustomFaultMessageResolver");
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("gatewayWithCustomFaultMessageResolver");
assertEquals(SubscribingConsumerEndpoint.class, endpoint.getClass());
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("consumer");
assertEquals(SimpleWebServiceHandler.class, gateway.getClass());
assertEquals(SimpleWebServiceOutboundGateway.class, gateway.getClass());
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
accessor = new DirectFieldAccessor(accessor.getPropertyValue("webServiceTemplate"));
FaultMessageResolver resolver = (FaultMessageResolver) context.getBean("faultMessageResolver");
@@ -126,58 +126,57 @@ public class WebServiceHandlerParserTests {
@Test
public void testSimpleWebServiceHandlerWithCustomMessageSender() {
public void simpleGatewayWithCustomMessageSender() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"simpleWebServiceHandlerParserTests.xml", this.getClass());
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("handlerWithCustomMessageSender");
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("gatewayWithCustomMessageSender");
assertEquals(SubscribingConsumerEndpoint.class, endpoint.getClass());
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("consumer");
assertEquals(SimpleWebServiceHandler.class, gateway.getClass());
assertEquals(SimpleWebServiceOutboundGateway.class, gateway.getClass());
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
accessor = new DirectFieldAccessor(accessor.getPropertyValue("webServiceTemplate"));
WebServiceMessageSender messageSender = (WebServiceMessageSender) context.getBean("messageSender");
assertEquals(messageSender, ((WebServiceMessageSender[])accessor.getPropertyValue("messageSenders"))[0]);
}
@Test
public void testSimpleWebServiceHandlerWithCustomMessageSenderList() {
public void simpleGatewayWithCustomMessageSenderList() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"simpleWebServiceHandlerParserTests.xml", this.getClass());
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("handlerWithCustomMessageSenderList");
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("gatewayWithCustomMessageSenderList");
assertEquals(SubscribingConsumerEndpoint.class, endpoint.getClass());
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("consumer");
assertEquals(SimpleWebServiceHandler.class, gateway.getClass());
assertEquals(SimpleWebServiceOutboundGateway.class, gateway.getClass());
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
accessor = new DirectFieldAccessor(accessor.getPropertyValue("webServiceTemplate"));
WebServiceMessageSender messageSender = (WebServiceMessageSender) context.getBean("messageSender");
assertEquals(messageSender, ((WebServiceMessageSender[])accessor.getPropertyValue("messageSenders"))[0]);
assertEquals("Wrong number of message senders " ,2 , ((WebServiceMessageSender[])accessor.getPropertyValue("messageSenders")).length);
}
@Test
public void testSimpleWebServiceHandlerWithPoller() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"simpleWebServiceHandlerParserTests.xml", this.getClass());
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("handlerWithPoller");
assertEquals(PollingConsumerEndpoint.class, endpoint.getClass());
Object obj = new DirectFieldAccessor(endpoint).getPropertyValue("trigger");
assertEquals(IntervalTrigger.class, obj.getClass());
IntervalTrigger trigger = (IntervalTrigger)obj;
DirectFieldAccessor accessor = new DirectFieldAccessor(trigger);
accessor = new DirectFieldAccessor(trigger);
assertEquals("IntervalTrigger had wrong itnerval" , 5000, ((Long)accessor.getPropertyValue("interval")).longValue());
assertEquals("Wrong number of message senders ",
2 , ((WebServiceMessageSender[])accessor.getPropertyValue("messageSenders")).length);
}
@Test
public void testWebServiceHandlerWithAllInOneMarshaller() {
public void simpleGatewayWithPoller() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"marshallingWebServiceHandlerParserTests.xml", this.getClass());
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("handlerWithAllInOneMarshaller");
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("gatewayWithPoller");
assertEquals(PollingConsumerEndpoint.class, endpoint.getClass());
Object obj = new DirectFieldAccessor(endpoint).getPropertyValue("trigger");
assertEquals(IntervalTrigger.class, obj.getClass());
IntervalTrigger trigger = (IntervalTrigger) obj;
DirectFieldAccessor accessor = new DirectFieldAccessor(trigger);
accessor = new DirectFieldAccessor(trigger);
assertEquals("IntervalTrigger had wrong interval",
5000, ((Long)accessor.getPropertyValue("interval")).longValue());
}
@Test
public void marshallingGatewayWithAllInOneMarshaller() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"marshallingWebServiceOutboundGatewayParserTests.xml", this.getClass());
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("gatewayWithAllInOneMarshaller");
assertEquals(SubscribingConsumerEndpoint.class, endpoint.getClass());
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("consumer");
assertEquals(MarshallingWebServiceHandler.class, gateway.getClass());
assertEquals(MarshallingWebServiceOutboundGateway.class, gateway.getClass());
DirectFieldAccessor gatewayAccessor = new DirectFieldAccessor(gateway);
DirectFieldAccessor templateAccessor = new DirectFieldAccessor(
gatewayAccessor.getPropertyValue("webServiceTemplate"));
@@ -187,13 +186,13 @@ public class WebServiceHandlerParserTests {
}
@Test
public void testWebServiceHandlerWithSeparateMarshallerAndUnmarshaller() {
public void marshallingGatewayWithSeparateMarshallerAndUnmarshaller() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"marshallingWebServiceHandlerParserTests.xml", this.getClass());
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("handlerWithSeparateMarshallerAndUnmarshaller");
"marshallingWebServiceOutboundGatewayParserTests.xml", this.getClass());
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("gatewayWithSeparateMarshallerAndUnmarshaller");
assertEquals(SubscribingConsumerEndpoint.class, endpoint.getClass());
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("consumer");
assertEquals(MarshallingWebServiceHandler.class, gateway.getClass());
assertEquals(MarshallingWebServiceOutboundGateway.class, gateway.getClass());
DirectFieldAccessor gatewayAccessor = new DirectFieldAccessor(gateway);
DirectFieldAccessor templateAccessor = new DirectFieldAccessor(
gatewayAccessor.getPropertyValue("webServiceTemplate"));
@@ -204,26 +203,26 @@ public class WebServiceHandlerParserTests {
}
@Test
public void testMarshallingWebServiceHandlerWithCustomRequestCallback() {
public void marshallingGatewayWithCustomRequestCallback() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"marshallingWebServiceHandlerParserTests.xml", this.getClass());
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("handlerWithCustomRequestCallback");
"marshallingWebServiceOutboundGatewayParserTests.xml", this.getClass());
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("gatewayWithCustomRequestCallback");
assertEquals(SubscribingConsumerEndpoint.class, endpoint.getClass());
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("consumer");
assertEquals(MarshallingWebServiceHandler.class, gateway.getClass());
assertEquals(MarshallingWebServiceOutboundGateway.class, gateway.getClass());
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
WebServiceMessageCallback callback = (WebServiceMessageCallback) context.getBean("requestCallback");
assertEquals(callback, accessor.getPropertyValue("requestCallback"));
}
@Test
public void testWebServiceHandlerWithAllInOneMarshallerAndMessageFactory() {
public void marshallingGatewayWithAllInOneMarshallerAndMessageFactory() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"marshallingWebServiceHandlerParserTests.xml", this.getClass());
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("handlerWithAllInOneMarshallerAndMessageFactory");
"marshallingWebServiceOutboundGatewayParserTests.xml", this.getClass());
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("gatewayWithAllInOneMarshallerAndMessageFactory");
assertEquals(SubscribingConsumerEndpoint.class, endpoint.getClass());
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("consumer");
assertEquals(MarshallingWebServiceHandler.class, gateway.getClass());
assertEquals(MarshallingWebServiceOutboundGateway.class, gateway.getClass());
DirectFieldAccessor gatewayAccessor = new DirectFieldAccessor(gateway);
DirectFieldAccessor templateAccessor = new DirectFieldAccessor(
gatewayAccessor.getPropertyValue("webServiceTemplate"));
@@ -235,13 +234,13 @@ public class WebServiceHandlerParserTests {
}
@Test
public void testWebServiceHandlerWithSeparateMarshallerAndUnmarshallerAndMessageFactory() {
public void marshallingGatewayWithSeparateMarshallerAndUnmarshallerAndMessageFactory() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"marshallingWebServiceHandlerParserTests.xml", this.getClass());
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("handlerWithSeparateMarshallerAndUnmarshallerAndMessageFactory");
"marshallingWebServiceOutboundGatewayParserTests.xml", this.getClass());
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("gatewayWithSeparateMarshallerAndUnmarshallerAndMessageFactory");
assertEquals(SubscribingConsumerEndpoint.class, endpoint.getClass());
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("consumer");
assertEquals(MarshallingWebServiceHandler.class, gateway.getClass());
assertEquals(MarshallingWebServiceOutboundGateway.class, gateway.getClass());
DirectFieldAccessor gatewayAccessor = new DirectFieldAccessor(gateway);
DirectFieldAccessor templateAccessor = new DirectFieldAccessor(
gatewayAccessor.getPropertyValue("webServiceTemplate"));

View File

@@ -1,55 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:si="http://www.springframework.org/schema/integration"
xmlns:ws="http://www.springframework.org/schema/integration/ws"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/integration/ws
http://www.springframework.org/schema/integration/ws/spring-integration-ws-1.0.xsd">
<si:channel id="inputChannel"/>
<ws:service-activator id="handlerWithAllInOneMarshaller"
input-channel="inputChannel"
uri="http://example.org"
marshaller="marshallerAndUnmarshaller"/>
<ws:service-activator id="handlerWithSeparateMarshallerAndUnmarshaller"
input-channel="inputChannel"
uri="http://example.org"
marshaller="marshaller"
unmarshaller="unmarshaller"/>
<ws:service-activator id="handlerWithCustomRequestCallback"
input-channel="inputChannel"
uri="http://example.org"
marshaller="marshallerAndUnmarshaller"
request-callback="requestCallback"/>
<ws:service-activator id="handlerWithAllInOneMarshallerAndMessageFactory"
input-channel="inputChannel"
uri="http://example.org"
marshaller="marshallerAndUnmarshaller"
message-factory="messageFactory"/>
<ws:service-activator id="handlerWithSeparateMarshallerAndUnmarshallerAndMessageFactory"
input-channel="inputChannel"
uri="http://example.org"
marshaller="marshaller"
unmarshaller="unmarshaller"
message-factory="messageFactory"/>
<bean id="marshallerAndUnmarshaller" class="org.springframework.integration.ws.config.StubMarshallerAndUnmarshaller"/>
<bean id="marshaller" class="org.springframework.integration.ws.config.StubMarshaller"/>
<bean id="unmarshaller" class="org.springframework.integration.ws.config.StubUnmarshaller"/>
<bean id="requestCallback" class="org.springframework.integration.ws.config.StubWebServiceMessageCallback"/>
<bean id="messageFactory" class="org.springframework.integration.ws.config.StubMessageFactory"/>
</beans>

View File

@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:si="http://www.springframework.org/schema/integration"
xmlns:ws="http://www.springframework.org/schema/integration/ws"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/integration/ws
http://www.springframework.org/schema/integration/ws/spring-integration-ws-1.0.xsd">
<si:channel id="requestChannel"/>
<ws:outbound-gateway id="gatewayWithAllInOneMarshaller"
request-channel="requestChannel"
uri="http://example.org"
marshaller="marshallerAndUnmarshaller"/>
<ws:outbound-gateway id="gatewayWithSeparateMarshallerAndUnmarshaller"
request-channel="requestChannel"
uri="http://example.org"
marshaller="marshaller"
unmarshaller="unmarshaller"/>
<ws:outbound-gateway id="gatewayWithCustomRequestCallback"
request-channel="requestChannel"
uri="http://example.org"
marshaller="marshallerAndUnmarshaller"
request-callback="requestCallback"/>
<ws:outbound-gateway id="gatewayWithAllInOneMarshallerAndMessageFactory"
request-channel="requestChannel"
uri="http://example.org"
marshaller="marshallerAndUnmarshaller"
message-factory="messageFactory"/>
<ws:outbound-gateway id="gatewayWithSeparateMarshallerAndUnmarshallerAndMessageFactory"
request-channel="requestChannel"
uri="http://example.org"
marshaller="marshaller"
unmarshaller="unmarshaller"
message-factory="messageFactory"/>
<bean id="marshallerAndUnmarshaller" class="org.springframework.integration.ws.config.StubMarshallerAndUnmarshaller"/>
<bean id="marshaller" class="org.springframework.integration.ws.config.StubMarshaller"/>
<bean id="unmarshaller" class="org.springframework.integration.ws.config.StubUnmarshaller"/>
<bean id="requestCallback" class="org.springframework.integration.ws.config.StubWebServiceMessageCallback"/>
<bean id="messageFactory" class="org.springframework.integration.ws.config.StubMessageFactory"/>
</beans>

View File

@@ -1,84 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:si="http://www.springframework.org/schema/integration"
xmlns:ws="http://www.springframework.org/schema/integration/ws"
xmlns:util='http://www.springframework.org/schema/util'
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/integration/ws
http://www.springframework.org/schema/integration/ws/spring-integration-ws-1.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd">
<si:channel id="inputChannel"/>
<si:channel id="pollableInputChannel">
<si:queue capacity="10"/>
</si:channel>
<ws:service-activator id="handlerWithDefaultSourceExtractor"
input-channel="inputChannel"
uri="http://example.org"/>
<ws:service-activator id="handlerWithCustomSourceExtractor"
input-channel="inputChannel"
uri="http://example.org"
source-extractor="sourceExtractor"/>
<ws:service-activator id="handlerWithCustomRequestCallback"
input-channel="inputChannel"
uri="http://example.org"
request-callback="requestCallback"/>
<ws:service-activator id="handlerWithCustomMessageFactory"
input-channel="inputChannel"
uri="http://example.org"
message-factory="messageFactory"/>
<ws:service-activator id="handlerWithCustomSourceExtractorAndMessageFactory"
input-channel="inputChannel"
uri="http://example.org"
source-extractor="sourceExtractor"
message-factory="messageFactory"/>
<ws:service-activator id="handlerWithCustomFaultMessageResolver"
input-channel="inputChannel"
uri="http://example.org"
fault-message-resolver="faultMessageResolver"/>
<ws:service-activator id="handlerWithCustomMessageSender"
input-channel="inputChannel"
uri="http://example.org"
message-sender="messageSender"/>
<ws:service-activator id="handlerWithCustomMessageSenderList"
input-channel="inputChannel"
uri="http://example.org"
message-senders="messageSenders">
</ws:service-activator>
<ws:service-activator id="handlerWithPoller"
input-channel="pollableInputChannel"
uri="http://example.org">
<si:poller interval="5000"/>
</ws:service-activator>
<bean id="sourceExtractor" class="org.springframework.integration.ws.config.StubSourceExtractor"/>
<bean id="requestCallback" class="org.springframework.integration.ws.config.StubWebServiceMessageCallback"/>
<bean id="messageFactory" class="org.springframework.integration.ws.config.StubMessageFactory"/>
<bean id="faultMessageResolver" class="org.springframework.integration.ws.config.StubFaultMessageResolver"/>
<bean id="messageSender" class="org.springframework.integration.ws.config.StubMessageSender"/>
<util:list id="messageSenders">
<ref bean="messageSender"/>
<bean class="org.springframework.integration.ws.config.StubMessageSender" />
</util:list>
</beans>

View File

@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:si="http://www.springframework.org/schema/integration"
xmlns:ws="http://www.springframework.org/schema/integration/ws"
xmlns:util='http://www.springframework.org/schema/util'
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/integration/ws
http://www.springframework.org/schema/integration/ws/spring-integration-ws-1.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd">
<si:channel id="inputChannel"/>
<si:channel id="pollableInputChannel">
<si:queue capacity="10"/>
</si:channel>
<ws:outbound-gateway id="gatewayWithDefaultSourceExtractor"
request-channel="inputChannel"
uri="http://example.org"/>
<ws:outbound-gateway id="gatewayWithCustomSourceExtractor"
request-channel="inputChannel"
uri="http://example.org"
source-extractor="sourceExtractor"/>
<ws:outbound-gateway id="gatewayWithCustomRequestCallback"
request-channel="inputChannel"
uri="http://example.org"
request-callback="requestCallback"/>
<ws:outbound-gateway id="gatewayWithCustomMessageFactory"
request-channel="inputChannel"
uri="http://example.org"
message-factory="messageFactory"/>
<ws:outbound-gateway id="gatewayWithCustomSourceExtractorAndMessageFactory"
request-channel="inputChannel"
uri="http://example.org"
source-extractor="sourceExtractor"
message-factory="messageFactory"/>
<ws:outbound-gateway id="gatewayWithCustomFaultMessageResolver"
request-channel="inputChannel"
uri="http://example.org"
fault-message-resolver="faultMessageResolver"/>
<ws:outbound-gateway id="gatewayWithCustomMessageSender"
request-channel="inputChannel"
uri="http://example.org"
message-sender="messageSender"/>
<ws:outbound-gateway id="gatewayWithCustomMessageSenderList"
request-channel="inputChannel"
uri="http://example.org"
message-senders="messageSenders">
</ws:outbound-gateway>
<ws:outbound-gateway id="gatewayWithPoller"
request-channel="pollableInputChannel"
uri="http://example.org">
<si:poller interval="5000"/>
</ws:outbound-gateway>
<bean id="sourceExtractor" class="org.springframework.integration.ws.config.StubSourceExtractor"/>
<bean id="requestCallback" class="org.springframework.integration.ws.config.StubWebServiceMessageCallback"/>
<bean id="messageFactory" class="org.springframework.integration.ws.config.StubMessageFactory"/>
<bean id="faultMessageResolver" class="org.springframework.integration.ws.config.StubFaultMessageResolver"/>
<bean id="messageSender" class="org.springframework.integration.ws.config.StubMessageSender"/>
<util:list id="messageSenders">
<ref bean="messageSender"/>
<bean class="org.springframework.integration.ws.config.StubMessageSender"/>
</util:list>
</beans>