WebServiceHandler classes are now WebServiceOutboundGateways. The "service-activator" element has also been replaced with <ws:outbound-gateway/> (INT-404).
This commit is contained in:
@@ -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;
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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.");
|
||||
}
|
||||
|
||||
|
||||
@@ -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 <ws-handler/> element.
|
||||
* Parser for the <outbound-gateway/> 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
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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"/>
|
||||
|
||||
Reference in New Issue
Block a user