Last active
June 25, 2018 06:00
-
-
Save garyrussell/6394999 to your computer and use it in GitHub Desktop.
Quick Start
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- Simple Service --> | |
| <int:gateway id="gw1" service-interface="foo.TempConverter" | |
| default-request-channel="simpleExpression" /> | |
| <int:service-activator input-channel="simpleExpression" | |
| expression="(payload - 32) / 9 * 5"/> | |
| <!-- Web Service --> | |
| <int:gateway id="gw2" service-interface="foo.TempConverter" | |
| default-request-channel="viaWebService" /> | |
| <int:chain input-channel="viaWebService"> | |
| <int:transformer | |
| expression="'<FahrenheitToCelsius xmlns=''http://tempuri.org/''><Fahrenheit>XXX</Fahrenheit></FahrenheitToCelsius>'.replace('XXX', payload.toString())" /> | |
| <int-ws:header-enricher> | |
| <int-ws:soap-action value="http://tempuri.org/FahrenheitToCelsius"/> | |
| </int-ws:header-enricher> | |
| <int-ws:outbound-gateway uri="http://www.w3schools.com/webservices/tempconvert.asmx"/> | |
| <int-xml:xpath-transformer | |
| xpath-expression="/*[local-name()='FahrenheitToCelsiusResponse']/*[local-name()='FahrenheitToCelsiusResult']"/> | |
| </int:chain> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Main { | |
| public static void main(String... args) throws Exception { | |
| ApplicationContext ctx = new ClassPathXmlApplicationContext("context.xml"); | |
| // simple service | |
| TempConverter converter = ctx.getBean("gw1", TempConverter.class); | |
| System.out.println(converter.fahrenheitToCelcius(68.0f)); | |
| // web service | |
| converter = ctx.getBean("gw2", TempConverter.class); | |
| System.out.println(converter.fahrenheitToCelcius(68.0f)); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 20.0 | |
| 20.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public interface TempConverter { | |
| float fahrenheitToCelcius(float fahren); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment