| <?xml version="1.0" encoding="ISO-8859-1"?> |
| <document> |
| |
| <properties> |
| <title>Quick Start Guide</title> |
| </properties> |
| |
| <body> |
| <section name="Apache Synapse ESB - Quick Start Guide"> |
| <p> |
| This guide will demonstrate two sample applications covering the basic and |
| the most common usage scenarios of Synapse; which is Message mediation and |
| Service mediation (i.e. using Proxy services). You will be guided through |
| a step by step approach to get a feeling about Synapse from the absolute |
| beginning. |
| </p> |
| </section> |
| |
| <section name="Pre-requisites"> |
| <p> |
| You should have following pre-requisites installed on your system to |
| follow through this guide |
| </p> |
| <ul> |
| <li> |
| A Java 2 SE - JDK or JRE of version 1.5.x or higher (JDK 1.6.0_21 recommended) |
| </li> |
| <li> |
| Apache Ant <a href="http://ant.apache.org">http://ant.apache.org</a> |
| </li> |
| </ul> |
| </section> |
| |
| <section name="Message Mediation"> |
| <p> |
| In this example Synapse will be used to simply log all the messages |
| passing through it. Although this simple scenario only performs logging, |
| it demonstrates the basics of message mediation, where the logging |
| functionality could be replaced with any combination of advanced |
| mediations such as transformations, content based routing as well as |
| bridging between different communication protocols etc. So, let's start |
| with the basics. |
| </p> |
| <h3> |
| Download |
| </h3> |
| <p> |
| Our first task is to download Synapse. Open a web browser and access the |
| following URL: |
| <a href="http://synapse.apache.org/download.html">http://synapse.apache.org/download.html</a>. |
| You will then see the list of available releases. Click on the latest version, and you |
| will be directed to the Synapse release download page. Now download the |
| 'Standard binary distribution' ZIP or tar.gz archive compatible with your |
| operating system. |
| </p> |
| <h3> |
| Installation |
| </h3> |
| <p> |
| Synapse can be installed just by extracting the downloaded binary |
| archive.. A directory named synapse with the release number will be |
| created in the selected parent directory, containing all the files |
| required for Synapse. We will refer to this directory as <synapse-home> |
| from now on. |
| </p> |
| <h3> |
| Running the Sample |
| </h3> |
| <p> |
| Synapse ships with a set of sample clients and services to demonstrate |
| some of its core capabilities. Hence, you will need to run three programs |
| to get an idea of message mediation. The destination server that hosts the |
| ultimate service to be invoked to service the client, the client itself, |
| and Synapse, which acts as the intermediary to bridge between the client |
| and the server. |
| </p> |
| <p/> |
| <h4> |
| Starting the Sample Axis2 Server |
| </h4> |
| <p> |
| In this case we are using a standalone Axis2 web services engine as the |
| server. You don't have to get it now, it is already bundled with your |
| Synapse distribution. But we have to deploy a sample service for which |
| client can send requests. Go to <synapse-home>/samples/axis2Server/src/SimpleStockQuoteService |
| directory. Run "ant" to build and deploy this service to the sample Axis2 |
| server. |
| </p> |
| <div class="consoleOutput">user@domain:/opt/synapse-2.0.0/samples/axis2Server/src/SimpleStockQuoteService$ ant |
| Buildfile: build.xml |
| |
| clean: |
| |
| init: |
| [mkdir] Created dir: /opt/synapse-2.0.0/samples/axis2Server/src/SimpleStockQuoteService/temp |
| [mkdir] Created dir: /opt/synapse-2.0.0/samples/axis2Server/src/SimpleStockQuoteService/temp/classes |
| [mkdir] Created dir: /opt/synapse-2.0.0/samples/axis2Server/repository/services |
| |
| compile-all: |
| [javac] Compiling 9 source files to /opt/synapse-2.0.0/samples/axis2Server/src/SimpleStockQuoteService/temp/classes |
| |
| build-service: |
| [mkdir] Created dir: /opt/synapse-2.0.0/samples/axis2Server/src/SimpleStockQuoteService/temp/SimpleStockQuote |
| [mkdir] Created dir: /opt/synapse-2.0.0/samples/axis2Server/src/SimpleStockQuoteService/temp/SimpleStockQuote/META-INF |
| [copy] Copying 1 file to /opt/synapse-2.0.0/samples/axis2Server/src/SimpleStockQuoteService/temp/SimpleStockQuote/META-INF |
| [copy] Copying 9 files to /opt/synapse-2.0.0/samples/axis2Server/src/SimpleStockQuoteService/temp/SimpleStockQuote |
| [jar] Building jar: /opt/synapse-2.0.0/samples/axis2Server/repository/services/SimpleStockQuoteService.aar |
| |
| BUILD SUCCESSFUL |
| Total time: 1 second</div> |
| <p> |
| Now go to <synapse-home>/samples/axis2Server directory and start the |
| server using the following command. This will start Axis2 server on port |
| 9000 (http). |
| </p> |
| <div class="command"> |
| <p> |
| Linux / Unix: . axis2server.sh |
| </p> |
| <p> |
| Windows: axis2server.bat |
| </p> |
| </div> |
| <p> |
| You will see the following messages on the console. |
| </p> |
| <div class="consoleOutput">Using JAVA_HOME: /opt/jdk1.6.0_16 |
| Using AXIS2 Repository : /opt/synapse-2.0.0/samples/axis2Server/repository |
| Using AXIS2 Configuration : /opt/synapse-2.0.0/samples/axis2Server/repository/conf/axis2.xml |
| 2010-11-26 01:20:55,419 [-] [main] INFO SampleAxis2ServerManager [SimpleAxisServer] Starting |
| [SimpleAxisServer] Using the Axis2 Repository : /opt/synapse-2.0.0/samples/axis2Server/repository |
| [SimpleAxisServer] Using the Axis2 Configuration File : /opt/synapse-2.0.0/samples/axis2Server/repository/conf/axis2.xml |
| 2010-11-26 01:20:56,023 [-] [main] ERROR SandeshaModule Could not load module policies. Using default values. |
| 2010-11-26 01:20:56,046 [-] [main] INFO HttpCoreNIOSSLSender Loading Identity Keystore from : ../../lib/identity.jks |
| 2010-11-26 01:20:56,063 [-] [main] INFO HttpCoreNIOSSLSender Loading Trust Keystore from : ../../lib/trust.jks |
| 2010-11-26 01:20:56,169 [-] [main] INFO HttpCoreNIOSender HTTPS Sender starting |
| 2010-11-26 01:20:56,190 [-] [main] INFO HttpCoreNIOSender HTTP Sender starting |
| 2010-11-26 01:20:56,191 [-] [main] INFO JMSSender JMS Sender started |
| 2010-11-26 01:20:56,192 [-] [main] INFO JMSSender JMS Transport Sender initialized... |
| 2010-11-26 01:20:56,295 [-] [main] INFO HttpCoreNIOSSLListener Loading Identity Keystore from : ../../lib/identity.jks |
| 2010-11-26 01:20:56,296 [-] [main] INFO HttpCoreNIOSSLListener Loading Trust Keystore from : ../../lib/trust.jks |
| 2010-11-26 01:20:56,299 [-] [main] INFO MailTransportListener MAILTO Listener started |
| 2010-11-26 01:20:56,301 [-] [main] WARN MailTransportListener Unable to configure the service SimpleStockQuoteService for the MAILTO transport: Service doesn't have configuration information for transport mailto. This service is being marked as faulty and will not be available over the MAILTO transport. |
| 2010-11-26 01:20:56,301 [-] [main] WARN MailTransportListener Disabling the mailto transport for the service SimpleStockQuoteService, because it is not configured properly for the service |
| 2010-11-26 01:20:56,373 [-] [main] INFO HttpCoreNIOListener HTTPS Listener started on port : 9002 |
| 2010-11-26 01:20:56,396 [-] [main] INFO HttpCoreNIOListener HTTP Listener started on port : 9000 |
| 2010-11-26 01:20:56,397 [-] [main] INFO SampleAxis2ServerManager [SimpleAxisServer] Started</div> |
| <h4> |
| Starting Synapse |
| </h4> |
| <p> |
| Now it's time to start Synapse. In this scenario we are starting Synapse |
| using the sample configuration found in synapse_sample_0.xml (i.e. in |
| repository/conf/sample) and listed below. It is configured to log and pass |
| through, all the messages. |
| </p> |
| <pre xml:space="preserve"><definitions xmlns="http://ws.apache.org/ns/synapse"> |
| <sequence name="main"> |
| <log level="full"/> |
| <send/> |
| </sequence> |
| </definitions></pre> |
| <p> |
| Go to <synapse-home>/bin directory and type the command given below. |
| Synapse will be started on port 8280 (http) and 8243 (https - under JDK |
| 1.5) |
| </p> |
| <div class="command"> |
| <p> |
| Linux / Unix: . synapse.sh -sample 0 |
| </p> |
| <p> |
| Windows: synapse.bat -sample 0 |
| </p> |
| </div> |
| <p> |
| Following messages will be displayed on the console to indicate the |
| successfull startup of Synapse. |
| </p> |
| <div class="consoleOutput">Starting Synapse/Java ... |
| Using SYNAPSE_HOME: /opt/synapse-2.0.0 |
| Using JAVA_HOME: /opt/jdk1.6.0_16 |
| Using SYNAPSE_XML: /opt/synapse-2.0.0/repository/conf/sample/synapse_sample_0.xml |
| 2010-11-26 01:33:03,651 [-] [main] INFO SynapseServer Starting Apache Synapse... |
| 2010-11-26 01:33:03,683 [-] [main] INFO SynapseControllerFactory Using Synapse home : /opt/synapse-2.0.0 |
| 2010-11-26 01:33:03,683 [-] [main] INFO SynapseControllerFactory Using Axis2 repository : /opt/synapse-2.0.0/repository |
| 2010-11-26 01:33:03,683 [-] [main] INFO SynapseControllerFactory Using axis2.xml location : /opt/synapse-2.0.0/repository/conf/axis2.xml |
| 2010-11-26 01:33:03,683 [-] [main] INFO SynapseControllerFactory Using synapse.xml location : /opt/synapse-2.0.0/repository/conf/sample/synapse_sample_0.xml |
| 2010-11-26 01:33:03,683 [-] [main] INFO SynapseControllerFactory Using server name : localhost |
| 2010-11-26 01:33:03,698 [-] [main] INFO SynapseControllerFactory The timeout handler will run every : 15s |
| 2010-11-26 01:33:03,808 [-] [main] INFO Axis2SynapseController Initializing Synapse at : Fri Nov 26 01:33:03 IST 2010 |
| 2010-11-26 01:33:04,536 [-] [main] ERROR SandeshaModule Could not load module policies. Using default values. |
| 2010-11-26 01:33:04,560 [-] [main] INFO HttpCoreNIOSSLSender Loading Identity Keystore from : lib/identity.jks |
| 2010-11-26 01:33:04,576 [-] [main] INFO HttpCoreNIOSSLSender Loading Trust Keystore from : lib/trust.jks |
| 2010-11-26 01:33:04,668 [-] [main] INFO HttpCoreNIOSender HTTPS Sender starting |
| 2010-11-26 01:33:04,674 [-] [main] INFO HttpCoreNIOSender HTTP Sender starting |
| 2010-11-26 01:33:04,675 [-] [main] INFO JMSSender JMS Sender started |
| 2010-11-26 01:33:04,677 [-] [main] INFO JMSSender JMS Transport Sender initialized... |
| 2010-11-26 01:33:04,681 [-] [main] INFO VFSTransportSender VFS Sender started |
| 2010-11-26 01:33:04,828 [-] [main] WARN JmxAdapter Using unsecured JMX remote access! |
| 2010-11-26 01:33:04,959 [-] [main] INFO HttpCoreNIOSSLListener Loading Identity Keystore from : lib/identity.jks |
| 2010-11-26 01:33:04,961 [-] [main] INFO HttpCoreNIOSSLListener Loading Trust Keystore from : lib/trust.jks |
| 2010-11-26 01:33:04,976 [-] [main] INFO Axis2SynapseController Loading mediator extensions... |
| 2010-11-26 01:33:05,013 [-] [main] INFO XMLConfigurationBuilder Generating the Synapse configuration model by parsing the XML configuration |
| 2010-11-26 01:33:05,114 [-] [main] INFO SynapseConfigurationBuilder Loaded Synapse configuration from : /opt/synapse-2.0.0/repository/conf/sample/synapse_sample_0.xml |
| 2010-11-26 01:33:05,158 [-] [main] INFO Axis2SynapseController Deploying the Synapse service... |
| 2010-11-26 01:33:05,175 [-] [main] INFO Axis2SynapseController Deploying Proxy services... |
| 2010-11-26 01:33:05,175 [-] [main] INFO Axis2SynapseController Deploying EventSources... |
| 2010-11-26 01:33:05,190 [-] [main] INFO MailTransportListener MAILTO Listener started |
| 2010-11-26 01:33:05,212 [-] [main] INFO HttpCoreNIOListener HTTPS Listener started on port : 8243 |
| 2010-11-26 01:33:05,215 [-] [main] INFO HttpCoreNIOListener HTTP Listener started on port : 8280 |
| 2010-11-26 01:33:05,215 [-] [main] INFO VFSTransportListener VFS Listener started |
| 2010-11-26 01:33:05,215 [-] [main] INFO Axis2SynapseController Management using JMX available via: service:jmx:rmi:///jndi/rmi://hiranya.wso2.com:1099/synapse |
| 2010-11-26 01:33:05,215 [-] [main] INFO ServerManager Server ready for processing... |
| 2010-11-26 01:33:05,216 [-] [main] INFO SynapseServer Apache Synapse started successfully</div> |
| <h4> |
| Run the Client |
| </h4> |
| <p> |
| Now the final step, running the client. Go to <synapse-home>/samples/axis2Client |
| directory and type the following command |
| </p> |
| <div class="command"> |
| ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService |
| -Dtrpurl=http://localhost:8280 -Dmode=quote -Dsymbol=IBM |
| </div> |
| <p> |
| You will see the following output on the console |
| </p> |
| <div class="consoleOutput">Buildfile: build.xml |
| |
| init: |
| [mkdir] Created dir: /opt/synapse-2.0.0/samples/axis2Client/target/classes |
| |
| compile: |
| [javac] Compiling 22 source files to /opt/synapse-2.0.0/samples/axis2Client/target/classes |
| [javac] Note: /opt/synapse-2.0.0/samples/axis2Client/src/samples/userguide/PWCallback.java uses or overrides a deprecated API. |
| [javac] Note: Recompile with -Xlint:deprecation for details. |
| [javac] Note: /opt/synapse-2.0.0/samples/axis2Client/src/samples/userguide/LoadbalanceFailoverClient.java uses unchecked or unsafe operations. |
| [javac] Note: Recompile with -Xlint:unchecked for details. |
| |
| stockquote: |
| [java] 2010-11-26 01:35:16,414 [-] [main] ERROR SandeshaModule Could not load module policies. Using default values. |
| [java] 2010-11-26 01:35:16,485 [-] [main] INFO MailTransportSender MAILTO Sender started |
| [java] 2010-11-26 01:35:16,496 [-] [main] INFO JMSSender JMS Sender started |
| [java] 2010-11-26 01:35:16,497 [-] [main] INFO JMSSender JMS Transport Sender initialized... |
| [java] Standard :: Stock price = $99.14593325984416 |
| |
| BUILD SUCCESSFUL |
| Total time: 5 seconds</div> |
| <p> |
| This sends a request for a stock quote for the symbol IBM and sets the |
| transport URL to Synapse (http://localhost:8280) and the WS-Addressing EPR |
| set that to the actual server |
| (http://localhost:9000/services/SimpleStockQuoteService). The actual wire |
| level http message sent by the client is as follows, and is sent to port |
| 8280 to the Synapse instance on localhost. |
| </p> |
| <div class="consoleOutput">POST / HTTP/1.1 |
| Content-Type: text/xml; charset=UTF-8 |
| SOAPAction: "urn:getQuote" |
| User-Agent: Axis2 |
| Host: 127.0.0.1 |
| Transfer-Encoding: chunked |
| |
| 218 |
| <?xml version='1.0' encoding='UTF-8'?> |
| <soapenv:Envelope xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> |
| <soapenv:Header> |
| <wsa:To>http://localhost:9000/services/SimpleStockQuoteService</wsa:To> |
| <wsa:MessageID>urn:uuid:D538B21E30B32BB8291177589283717</wsa:MessageID> |
| <wsa:Action>urn:getQuote</wsa:Action> |
| </soapenv:Header> |
| <soapenv:Body> |
| <m0:getQuote xmlns:m0="http://services.samples/xsd"> |
| <m0:request> |
| <m0:symbol>IBM</m0:symbol> |
| </m0:request> |
| </m0:getQuote> |
| </soapenv:Body> |
| </soapenv:Envelope>0</div> |
| <p> |
| Now take a look at the console running Synapse. You will see that all the |
| details of the mediation are logged along with all the SOAP messages |
| passed through Synapse. If you execute Synapse in debug mode by editing |
| the lib/log4j.properties "log4j.category.org.apache.synapse" as "DEBUG" |
| instead of INFO, you will see more information as follows after a restart |
| and replay of the above scenario again. |
| </p> |
| <div class="consoleOutput">2010-11-26 01:39:42,958 [-] [HttpServerWorker-1] DEBUG SynapseMessageReceiver Synapse received a new message for message mediation... |
| 2010-11-26 01:39:42,959 [-] [HttpServerWorker-1] DEBUG SynapseMessageReceiver Received To: http://localhost:9000/services/SimpleStockQuoteService |
| 2010-11-26 01:39:42,959 [-] [HttpServerWorker-1] DEBUG SynapseMessageReceiver SOAPAction: urn:getQuote |
| 2010-11-26 01:39:42,959 [-] [HttpServerWorker-1] DEBUG SynapseMessageReceiver WSA-Action: urn:getQuote |
| 2010-11-26 01:39:42,960 [-] [HttpServerWorker-1] DEBUG Axis2SynapseEnvironment Injecting MessageContext |
| 2010-11-26 01:39:42,960 [-] [HttpServerWorker-1] DEBUG Axis2SynapseEnvironment Using Main Sequence for injected message |
| 2010-11-26 01:39:42,961 [-] [HttpServerWorker-1] DEBUG SequenceMediator Start : Sequence <main> |
| 2010-11-26 01:39:42,961 [-] [HttpServerWorker-1] DEBUG SequenceMediator Sequence <SequenceMediator> :: mediate() |
| 2010-11-26 01:39:42,961 [-] [HttpServerWorker-1] DEBUG LogMediator Start : Log mediator |
| 2010-11-26 01:39:42,989 [-] [HttpServerWorker-1] INFO LogMediator To: http://localhost:9000/services/SimpleStockQuoteService, WSAction: urn:getQuote, SOAPAction: urn:getQuote, ReplyTo: http://www.w3.org/2005/08/addressing/anonymous, MessageID: urn:uuid:881AF81981B97048961290715782743, Direction: request, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"><wsa:To>http://localhost:9000/services/SimpleStockQuoteService</wsa:To><wsa:MessageID>urn:uuid:881AF81981B97048961290715782743</wsa:MessageID><wsa:Action>urn:getQuote</wsa:Action></soapenv:Header><soapenv:Body><m0:getQuote xmlns:m0="http://services.samples"><m0:request><m0:symbol>IBM</m0:symbol></m0:request></m0:getQuote></soapenv:Body></soapenv:Envelope> |
| 2010-11-26 01:39:42,990 [-] [HttpServerWorker-1] DEBUG LogMediator End : Log mediator |
| 2010-11-26 01:39:42,990 [-] [HttpServerWorker-1] DEBUG SendMediator Start : Send mediator |
| 2010-11-26 01:39:42,990 [-] [HttpServerWorker-1] DEBUG SendMediator Sending request message using implicit message properties.. |
| Sending To: http://localhost:9000/services/SimpleStockQuoteService |
| SOAPAction: urn:getQuote |
| 2010-11-26 01:39:42,993 [-] [HttpServerWorker-1] DEBUG Axis2FlexibleMEPClient Sending [add = false] [sec = false] [rm = false] [to=Address: http://localhost:9000/services/SimpleStockQuoteService] |
| 2010-11-26 01:39:42,997 [-] [HttpServerWorker-1] DEBUG Axis2FlexibleMEPClient Message [Original Request Message ID : urn:uuid:881AF81981B97048961290715782743] [New Cloned Request Message ID : urn:uuid:5e919190-98a9-4441-8bb0-d09271c2758a] |
| 2010-11-26 01:39:43,003 [-] [HttpServerWorker-1] DEBUG SynapsePropertiesLoader Retrieving synapse properties from the cache |
| 2010-11-26 01:39:43,003 [-] [HttpServerWorker-1] DEBUG MiscellaneousUtil The name with 'synapse.global_timeout_interval' cannot be found. Using default value : 86400000 |
| 2010-11-26 01:39:43,004 [-] [HttpServerWorker-1] INFO TimeoutHandler This engine will expire all callbacks after : 86400 seconds, irrespective of the timeout action, after the specified or optional timeout |
| 2010-11-26 01:39:43,004 [-] [HttpServerWorker-1] DEBUG SynapsePropertiesLoader Retrieving synapse properties from the cache |
| 2010-11-26 01:39:43,004 [-] [HttpServerWorker-1] DEBUG MiscellaneousUtil The name with 'synapse.timeout_handler_interval' cannot be found. Using default value : 15000 |
| 2010-11-26 01:39:43,039 [-] [HttpServerWorker-1] DEBUG SynapseCallbackReceiver Callback added. Total callbacks waiting for : 1 |
| 2010-11-26 01:39:43,144 [-] [HttpServerWorker-1] DEBUG SendMediator End : Send mediator |
| 2010-11-26 01:39:43,145 [-] [HttpServerWorker-1] DEBUG SequenceMediator End : Sequence <main> |
| 2010-11-26 01:39:43,271 [-] [HttpClientWorker-1] DEBUG SynapseCallbackReceiver Callback removed for request message id : urn:uuid:5e919190-98a9-4441-8bb0-d09271c2758a. Pending callbacks count : 0 |
| 2010-11-26 01:39:43,271 [-] [HttpClientWorker-1] DEBUG SynapseCallbackReceiver Synapse received an asynchronous response message |
| 2010-11-26 01:39:43,271 [-] [HttpClientWorker-1] DEBUG SynapseCallbackReceiver Received To: null |
| 2010-11-26 01:39:43,271 [-] [HttpClientWorker-1] DEBUG SynapseCallbackReceiver SOAPAction: |
| 2010-11-26 01:39:43,271 [-] [HttpClientWorker-1] DEBUG SynapseCallbackReceiver WSA-Action: |
| 2010-11-26 01:39:43,272 [-] [HttpClientWorker-1] DEBUG SynapseCallbackReceiver Body : |
| <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns:getQuoteResponse xmlns:ns="http://services.samples"><ns:return xmlns:ax21="http://services.samples/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ax21:GetQuoteResponse"><ax21:change>-2.533440547346707</ax21:change><ax21:earnings>12.865664096815566</ax21:earnings><ax21:high>-62.37116432061533</ax21:high><ax21:last>63.140427676860845</ax21:last><ax21:lastTradeTimestamp>Fri Nov 26 01:39:43 IST 2010</ax21:lastTradeTimestamp><ax21:low>65.32586424659065</ax21:low><ax21:marketCap>3.6215661345786005E7</ax21:marketCap><ax21:name>IBM Company</ax21:name><ax21:open>64.94029146457328</ax21:open><ax21:peRatio>23.84144924463005</ax21:peRatio><ax21:percentageChange>-3.6037604984655096</ax21:percentageChange><ax21:prevClose>70.29991444840613</ax21:prevClose><ax21:symbol>IBM</ax21:symbol><ax21:volume>9723</ax21:volume></ns:return></ns:getQuoteResponse></soapenv:Body></soapenv:Envelope> |
| 2010-11-26 01:39:43,274 [-] [HttpClientWorker-1] DEBUG Axis2SynapseEnvironment Injecting MessageContext |
| 2010-11-26 01:39:43,274 [-] [HttpClientWorker-1] DEBUG Axis2SynapseEnvironment Using Main Sequence for injected message |
| 2010-11-26 01:39:43,274 [-] [HttpClientWorker-1] DEBUG SequenceMediator Start : Sequence <main> |
| 2010-11-26 01:39:43,275 [-] [HttpClientWorker-1] DEBUG SequenceMediator Sequence <SequenceMediator> :: mediate() |
| 2010-11-26 01:39:43,275 [-] [HttpClientWorker-1] DEBUG LogMediator Start : Log mediator |
| 2010-11-26 01:39:43,275 [-] [HttpClientWorker-1] INFO LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , ReplyTo: http://www.w3.org/2005/08/addressing/anonymous, MessageID: urn:uuid:5e919190-98a9-4441-8bb0-d09271c2758a, Direction: response, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns:getQuoteResponse xmlns:ns="http://services.samples"><ns:return xmlns:ax21="http://services.samples/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ax21:GetQuoteResponse"><ax21:change>-2.533440547346707</ax21:change><ax21:earnings>12.865664096815566</ax21:earnings><ax21:high>-62.37116432061533</ax21:high><ax21:last>63.140427676860845</ax21:last><ax21:lastTradeTimestamp>Fri Nov 26 01:39:43 IST 2010</ax21:lastTradeTimestamp><ax21:low>65.32586424659065</ax21:low><ax21:marketCap>3.6215661345786005E7</ax21:marketCap><ax21:name>IBM Company</ax21:name><ax21:open>64.94029146457328</ax21:open><ax21:peRatio>23.84144924463005</ax21:peRatio><ax21:percentageChange>-3.6037604984655096</ax21:percentageChange><ax21:prevClose>70.29991444840613</ax21:prevClose><ax21:symbol>IBM</ax21:symbol><ax21:volume>9723</ax21:volume></ns:return></ns:getQuoteResponse></soapenv:Body></soapenv:Envelope> |
| 2010-11-26 01:39:43,275 [-] [HttpClientWorker-1] DEBUG LogMediator End : Log mediator |
| 2010-11-26 01:39:43,275 [-] [HttpClientWorker-1] DEBUG SendMediator Start : Send mediator |
| 2010-11-26 01:39:43,275 [-] [HttpClientWorker-1] DEBUG SendMediator Sending response message using implicit message properties.. |
| Sending To: http://www.w3.org/2005/08/addressing/anonymous |
| SOAPAction: |
| 2010-11-26 01:39:43,282 [-] [HttpClientWorker-1] DEBUG SendMediator End : Send mediator |
| 2010-11-26 01:39:43,282 [-] [HttpClientWorker-1] DEBUG SequenceMediator End : Sequence <main></div> |
| <p> |
| And with that you have successfully completed the first part of this guide. Now let's |
| look at the next scenario, proxy services. |
| </p> |
| </section> |
| <section name="Proxy Services"> |
| <p> |
| As the name implies, a proxy service acts as a service hosted in Synapse, |
| and typically fronts an existing service endpoint. A proxy service can be |
| created and exposed on a different transport, schema, WSDL, or QoS (such |
| as WS-Security, WS-Reliable Messaging) aspect than the real service and |
| could mediate the messages before being delivered to the actual endpoint, |
| and the responses before they reach the client. |
| </p> |
| <p> |
| Clients can send requests for proxy services directly to Synapse, as the |
| client sees as if they are hosted on it, and for example can perform ?wsdl |
| and view the WSDL of the virtual proxy service. But in the Synapse |
| configuration, such requests can be handled in anyway you like. Most |
| obvious thing would be to do some processing to the message and send it to |
| the actual service, probably running on a different computer. But it is |
| not necessary to always send the message to the actual service. You may |
| list any combination of tasks to be performed on the messages received for |
| the proxy service and terminate the flow or send some java back to the |
| client even without sending it to an actual service. Let's explore a |
| simple proxy services scenario step by step to get a better feeling. As |
| you have downloaded and installed Synapse in the previous section, now you |
| can start directly on the sample. |
| </p> |
| <h3> |
| Running the Sample |
| </h3> |
| <p> |
| As in the previous section, there should be three entities running to |
| demonstrate proxy services, the server, client and Synapse. Let's start |
| with the server. |
| </p> |
| <p/> |
| <h4> |
| Starting the Sample Axis2 Server |
| </h4> |
| <p> |
| As you have built and deployed the SimpleStockQuote service in the |
| previous section, you can simply start the server by switching to the <synapse-home>/samples/axis2Server |
| directory and running the following command. |
| </p> |
| <div class="command"> |
| <p> |
| Linux / Unix: . axis2server.sh |
| </p> |
| <p> |
| Windows: axis2server.bat |
| </p> |
| </div> |
| <p> |
| You can see the console messages as in the previous section. |
| </p> |
| <h4> |
| Starting Synapse |
| </h4> |
| <p> |
| We have to start Synapse with a configuration containing a proxy service |
| definition. In this case we are using the synapse_sample_150.xml, so that |
| you don't have to write the configuration your self. |
| </p> |
| <pre xml:space="preserve"><definitions xmlns="http://synapse.apache.org/ns/2010/04/configuraiton"> |
| <proxy name="StockQuoteProxy"> |
| <target> |
| <endpoint> |
| <address uri="http://localhost:9000/services/SimpleStockQuoteService"/> |
| </endpoint> |
| <outSequence> |
| <send/> |
| </outSequence> |
| </target> |
| <publishWSDL uri="file:repository/conf/sample/resources/proxy/sample_proxy_1.wsdl"/> |
| </proxy> |
| </definitions></pre> |
| <p> |
| The above configuration will expose a proxy service named StockQuoteProxy |
| and specifies an endpoint |
| (http://localhost:9000/services/SimpleStockQuoteService) as the target for the |
| proxy service. Therefore, messages coming to the proxy service will be |
| directed to the address http://localhost:9000/services/SimpleStockQuoteService |
| specified in the endpoint. There is also an out sequence for the proxy |
| service, which is applicable for response messages. In the out sequence, |
| we just send the messages back to the client. The publishWSDL tag |
| specifies an WSDL to be published for this proxy service. Let's start |
| Synapse with this sample configuration by running the below command from |
| the <synapse-home>/bin directory. It is possible to specify a |
| sequence of mediation for incoming messages instead of a target endpoint, |
| and many other possibilities and options are available to configure proxy |
| services. These are explained in the samples and configuration guides. |
| </p> |
| <div class="command"> |
| <p> |
| Linux / Unix: . synapse.sh -sample 150 |
| </p> |
| <p> |
| Windows: synapse.bat -sample 150 |
| </p> |
| </div> |
| <p> |
| Synapse will display a set of messages as in the previous section |
| describing the steps of starting procedure. Before running the client, it |
| is time to observe another feature of proxy services. That is displaying |
| the published WSDL. Just open a web browser and point it to the address |
| http://localhost:8280/services/StockQuoteProxy?wsdl. You will see the |
| sample_proxy_1.wsdl specified in the configuration but containing the |
| correct EPR for the service over HTTP/S. |
| </p> |
| <h4> |
| Run the Client |
| </h4> |
| <p> |
| Now it is time to see it in action. Go to the <synapse-home>/samples/axis2Clients |
| directory and type the following command: |
| </p> |
| <div class="command"> |
| ant stockquote -Dtrpurl=http://localhost:8280/services/StockQuoteProxy |
| -Dmode=quote -Dsymbol=IBM |
| </div> |
| <p> |
| The above command sends a stockquote request directly to the provided |
| transport endpoint at: http://localhost:8280/services/StockQuoteProxy. You |
| will see the response from the server displayed on the console as follows: |
| </p> |
| <div class="consoleOutput">Standard :: Stock price = $165.32687331383468</div> |
| <p> |
| This quick guide illustrates the simple use case of proxy services. Please |
| refer to samples #150 and above in the Samples guide, for in depth |
| coverage of more advanced use cases. |
| </p> |
| <p> |
| Yes, you are done with a quick look at Synapse. Now it is time to go |
| deeper and reveal the advanced features of Synapse. You can browse through |
| the samples for your interested areas. If you have any issue regarding |
| Synapse as a user, feel free ask it in the Synapse user mailing list |
| (<a href="http://synapse.apache.org/mail-lists.html">http://synapse.apache.org/mail-lists.html</a>). |
| </p> |
| </section> |
| |
| </body> |
| |
| </document> |