SimpleWebServiceTargetAdapter is now SimpleWebServiceHandler, and MarshallingWebServiceTargetAdapter is now MarshallingWebServiceHandler. The "ws-target" element is now "ws-handler", and the WebServiceHandlerParser (formerly WebServiceTargetAdapterParser) now creates a MessageHandler instance only - rather than creating the HandlerEndpoint itself. Therefore, the "ws-handler" should be referenced from the "handler" attribute of a <handler-endpoint/> element. See the modified WebServiceDemo (and its configuration file: "temperatureConversion.xml") in the "org.springframework.integration.samples" module for an example.

This commit is contained in:
Mark Fisher
2008-05-28 15:37:13 +00:00
parent ccc3e06928
commit f242075a73
12 changed files with 170 additions and 195 deletions

View File

@@ -20,34 +20,33 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.channel.MessageChannel;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.message.Message;
import org.springframework.integration.ws.adapter.AbstractWebServiceTargetAdapter;
import org.springframework.integration.ws.handler.AbstractWebServiceHandler;
/**
* Demonstrating a web service invocation through a Web Service Target.
* Demonstrating a web service invocation through a Web Service MessageHandler.
*
* @author Marius Bogoevici
*/
public class WebServiceDemo {
public static void main(String[] args) {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("temperatureConversion.xml",
WebServiceDemo.class);
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("temperatureConversion.xml", WebServiceDemo.class);
context.start();
// Compose the XML message according to the server's schema
String requestMessage = "<FahrenheitToCelsius xmlns=\"http://tempuri.org/\">" +
" <Fahrenheit>90.0</Fahrenheit>" +
" </FahrenheitToCelsius>";
// Prepare the Message object
Message<String> message = new GenericMessage<String>(requestMessage);
// In this case the service expects a SoapAction header
message.getHeader().setProperty(AbstractWebServiceTargetAdapter.SOAP_ACTION_PROPERTY_KEY, "http://tempuri.org/FahrenheitToCelsius");
// Set the return address for the message - the response message will be returned on this channel
message.getHeader().setReturnAddress("celsiusChannel");
((MessageChannel)context.getBean("fahrenheitChannel")).send(message);
}
}
// Compose the XML message according to the server's schema
String requestMessage =
"<FahrenheitToCelsius xmlns=\"http://tempuri.org/\">" +
" <Fahrenheit>90.0</Fahrenheit>" +
"</FahrenheitToCelsius>";
// Create the Message object
Message<String> message = new GenericMessage<String>(requestMessage);
// In this case the service expects a SoapAction header
message.getHeader().setProperty(AbstractWebServiceHandler.SOAP_ACTION_PROPERTY_KEY, "http://tempuri.org/FahrenheitToCelsius");
// Send the Message to the handler's input channel
((MessageChannel) context.getBean("fahrenheitChannel")).send(message);
}
}

View File

@@ -1,27 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
<beans:beans xmlns="http://www.springframework.org/schema/integration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:si="http://www.springframework.org/schema/integration"
xmlns:beans="http://www.springframework.org/schema/beans"
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-ws-1.0.xsd">
<si:message-bus/>
<message-bus/>
<!-- A Web Service target reads messages from the configurd channel, invokes the service and sends
the response on the replyAddress configured on the message header -->
<si:channel id="fahrenheitChannel"/>
<si:ws-target id="temperatureConverter"
uri="http://www.w3schools.com/webservices/tempconvert.asmx"
channel="fahrenheitChannel" />
<channel id="fahrenheitChannel"/>
<channel id="celsiusChannel"/>
<si:channel id="celsiusChannel"/>
<!-- The handler endpoint receives from the 'fahrenheitChannel',
invokes the handler, and sends the reply Message to the 'celsiusChannel'. -->
<handler-endpoint input-channel="fahrenheitChannel"
handler="temperatureConverter"
output-channel="celsiusChannel"/>
<!-- The response from the service is logged on the console -->
<si:target-endpoint target="console" input-channel="celsiusChannel"/>
<si:console-target id="console"/>
</beans>
<!-- The handler invokes the WebService for the given URI and returns a reply Message. -->
<ws-handler id="temperatureConverter"
uri="http://www.w3schools.com/webservices/tempconvert.asmx"/>
<!-- The response from the service is logged to the console. -->
<target-endpoint input-channel="celsiusChannel" target="console"/>
<console-target id="console"/>
</beans:beans>