From 936cc3aaac908eb98ca7ede9a60ed33db8ba18df Mon Sep 17 00:00:00 2001 From: Marius Bogoevici Date: Fri, 23 May 2008 06:28:25 +0000 Subject: [PATCH] INT-197 Adding a Web Service Sample --- .../.classpath | 1 + .../ivy.xml | 1 + .../samples/ws/WebServiceDemo.java | 53 +++++++++++++++++++ .../samples/ws/temperatureConversion.xml | 27 ++++++++++ 4 files changed, 82 insertions(+) create mode 100644 org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/ws/WebServiceDemo.java create mode 100644 org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/ws/temperatureConversion.xml diff --git a/org.springframework.integration.samples/.classpath b/org.springframework.integration.samples/.classpath index 4e5fa4176e..f3945baae4 100644 --- a/org.springframework.integration.samples/.classpath +++ b/org.springframework.integration.samples/.classpath @@ -17,5 +17,6 @@ + diff --git a/org.springframework.integration.samples/ivy.xml b/org.springframework.integration.samples/ivy.xml index 476a1541da..adc532aba4 100644 --- a/org.springframework.integration.samples/ivy.xml +++ b/org.springframework.integration.samples/ivy.xml @@ -23,6 +23,7 @@ + diff --git a/org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/ws/WebServiceDemo.java b/org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/ws/WebServiceDemo.java new file mode 100644 index 0000000000..5abfc8eb1f --- /dev/null +++ b/org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/ws/WebServiceDemo.java @@ -0,0 +1,53 @@ +/* + * Copyright 2002-2008 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.integration.samples.ws; + +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; + +/** + * Demonstrating a web service invocation through a Web Service Target. + * + * @author Marius Bogoevici + */ +public class WebServiceDemo { + + public static void main(String[] args) { + ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("temperatureConversion.xml", + WebServiceDemo.class); + context.start(); + + // Compose the XML message according to the server's schema + String requestMessage = "" + + " 90.0" + + " "; + + // Prepare the Message object + Message message = new GenericMessage(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); + } + +} + diff --git a/org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/ws/temperatureConversion.xml b/org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/ws/temperatureConversion.xml new file mode 100644 index 0000000000..1f5d21129a --- /dev/null +++ b/org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/ws/temperatureConversion.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + +