[Carbon-dev] svn commit r30493 - branches/carbon/1.5/trunk/esb/java/docs/xdoc/samples

ruwan at wso2.com ruwan at wso2.com
Thu Feb 5 07:36:23 PST 2009


Author: ruwan
Date: Thu Feb  5 07:36:23 2009
New Revision: 30493
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=30493

Log:
transport samples content added

Modified:
   branches/carbon/1.5/trunk/esb/java/docs/xdoc/samples/transport_samples.xml

Modified: branches/carbon/1.5/trunk/esb/java/docs/xdoc/samples/transport_samples.xml
URL: http://wso2.org/svn/browse/wso2/branches/carbon/1.5/trunk/esb/java/docs/xdoc/samples/transport_samples.xml?rev=30493&r1=30492&r2=30493&view=diff
==============================================================================
--- branches/carbon/1.5/trunk/esb/java/docs/xdoc/samples/transport_samples.xml	(original)
+++ branches/carbon/1.5/trunk/esb/java/docs/xdoc/samples/transport_samples.xml	Thu Feb  5 07:36:23 2009
@@ -23,15 +23,731 @@
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
-  <meta http-equiv="content-type" content="" />
-  <title>WSO2 ESB - Samples Guide </title>
-  <link href="css/esb-docs.css" rel="stylesheet"/>
-  <link href="styles/dist-docs.css" rel="stylesheet" type="text/css"
-  media="all" />
-  <link href="samples_setup_guide.xml" />
+  <meta content="text/html; charset=iso-8859-1" http-equiv="content-type"/>
+  <title>WSO2 ESB - Transport Switching Samples </title>
 </head>
 
 <body>
-<h1>Running the WSO2 Enterprise Service Bus (ESB) Samples </h1>
+<h1>Running the Transport samples with WSO2 Enterprise Service Bus (ESB)</h1>
+<h2><a name="Sample250">Sample 250: Introduction to switching transports - JMS
+to http/s</a> </h2>
+<pre xml:space="preserve">&lt;definitions xmlns="http://ws.apache.org/ns/synapse"&gt;
+
+    &lt;proxy name="StockQuoteProxy" transports="jms"&gt;
+        &lt;target&gt;
+            &lt;inSequence&gt;
+                &lt;property action="set" name="OUT_ONLY" value="true"/&gt;
+            &lt;/inSequence&gt;
+            &lt;endpoint&gt;
+                &lt;address uri="http://localhost:9000/services/SimpleStockQuoteService"/&gt;
+            &lt;/endpoint&gt;
+            &lt;outSequence&gt;
+                &lt;send/&gt;
+            &lt;/outSequence&gt;
+        &lt;/target&gt;
+        &lt;publishWSDL uri="file:repository/samples/resources/proxy/sample_proxy_1.wsdl"/&gt;
+    &lt;/proxy&gt;
+
+&lt;/definitions&gt;</pre>
+
+<p><strong>Objective: Introduction to switching transports with proxy
+services</strong> </p>
+
+<p><strong>Prerequisites:</strong><br />
+Start the Axis2 server and deploy the SimpleStockQuoteService (Refer steps
+above)<br />
+Download, install and start a JMS server, and configure ESB to listen on JMS
+(refer notes below)<br />
+Start the Synapse configuration numbered 250: i.e. wso2server -Desb.sample=250<br />
+For this example we would use ActiveMQ as the JMS provider. Once ActiveMQ is
+installed and started you should get a message as follows: </p>
+<pre xml:space="preserve">INFO BrokerService - ActiveMQ JMS Message Broker (localhost) started</pre>
+
+<p>You will now need to configure the Axis2 instance used by ESB (not the
+sample Axis2 server) to enable JMS support using the above provider. Refer to
+the Axis2 documentation on setting up JMS for more details
+(http://ws.apache.org/axis2/1_1/jms-transport.html). You will also need to
+copy the ActiveMQ client jar files activeio-core-3.0-beta1.jar,
+activemq-core-4.0-RC2.jar and geronimo-j2ee-management_1.0_spec-1.0.jar into
+the lib directory to allow ESB to connect to the JMS provider. </p>
+
+<p>For a default ActiveMQ v4.0 installation, you may uncomment the Axis2
+transport listener configuration found at repository/conf/axis2.xml as </p>
+<pre xml:space="preserve">&lt;transportReceiver name="jms" class="org.apache.axis2.transport.jms.JMSListener"&gt; ...</pre>
+
+<p>Once you start the Synapse configuration and request for the WSDL of the
+proxy service (http://localhost:8280/services/StockQuoteProxy?wsdl) you will
+notice that its exposed only on the JMS transport. This is because the
+configuration specified this requirement in the proxy service definition. </p>
+
+<p>Now lets send a stock quote request on JMS, using the dumb stock quote
+client as follows: </p>
+<pre xml:space="preserve">ant jmsclient -Djms_type=pox -Djms_dest=dynamicQueues/StockQuoteProxy -Djms_payload=MSFT</pre>
+
+<p>On the ESB debug log you will notice that the JMS listener received the
+request message as: </p>
+<pre xml:space="preserve">[JMSWorker-1] DEBUG ProxyServiceMessageReceiver -Proxy Service StockQuoteProxy received a new message...</pre>
+
+<p>Now if you examine the console running the sample Axis2 server, you will
+see a message indicating that the server has accepted an order as follows:
+</p>
+<pre xml:space="preserve">Accepted order for : 16517 stocks of MSFT at $ 169.14622538721846</pre>
+
+<p>In this sample, client sends the request message to the proxy service
+exposed in JMS in Synsape. ESB forwards this message to the HTTP EPR of the
+simple stock quote service hosted on the sample Axis2 server, and returns the
+reply back to the client through a JMS temporary queue. </p>
+
+<p>Note: It is possible to instruct a JMS proxy service to listen to an
+already existing destination without creating a new one. To do this, use the
+property elements on the proxy service definition to specify the destination
+and connection factory etc. </p>
+
+<p>e.g. </p>
+<pre xml:space="preserve">&lt;property name="transport.jms.Destination" value="dynamicTopics/something.TestTopic"/&gt;</pre>
+
+<h2><a name="Sample251">Sample 251: Switching from http/s to JMS</a> </h2>
+<pre xml:space="preserve">&lt;definitions xmlns="http://ws.apache.org/ns/synapse"&gt;
+
+    &lt;proxy name="StockQuoteProxy" transports="http"&gt;
+        &lt;target&gt;
+            &lt;endpoint&gt;
+                &lt;address uri="jms:/SimpleStockQuoteService?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&amp;amp;
+                   java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&amp;amp;java.naming.provider.url=tcp://localhost:61616"/&gt;
+            &lt;/endpoint&gt;
+            &lt;inSequence&gt;
+                &lt;property action="set" name="OUT_ONLY" value="true"/&gt;
+            &lt;/inSequence&gt;
+            &lt;outSequence&gt;
+                &lt;send/&gt;
+            &lt;/outSequence&gt;
+        &lt;/target&gt;
+        &lt;publishWSDL uri="file:repository/samples/resources/proxy/sample_proxy_1.wsdl"/&gt;
+    &lt;/proxy&gt;
+
+&lt;/definitions&gt;</pre>
+
+<p><strong>Objective: Demonstrate switching from HTTP to JMS</strong> </p>
+
+<p><strong>Prerequisites:</strong><br />
+Download, install and start a JMS server </p>
+
+<p>Configure sample Axis2 server for JMS (refer notes above)<br />
+Start the Axis2 server and deploy the SimpleStockQuoteService (see below)<br
+/>
+Configure the Synase JMS transport (refer notes above - sample 250)<br />
+Start the Synapse configuration numbered 251: i.e. wso2server -Desb.sample=251 </p>
+
+<p>To switch from HTTP to JMS, edit the
+samples/axis2Server/repository/conf/axis2.xml for the sample Axis2 server and
+enable JMS (refer notes above), and restart the server. Now you can see that
+the simple stock quote service is available in both JMS and HTTP in the
+sample Axis2 server. To see this, point your browser to the WSDL of the
+service at http://localhost:9000/services/SimpleStockQuoteService?wsdl. JMS URL
+for the service is mentioned as below: </p>
+<pre xml:space="preserve">jms:/SimpleStockQuoteService?transport.jms.ConnectionFactoryJNDIName=
+QueueConnectionFactory&amp;java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&amp;
+java.naming.provider.url=tcp://localhost:61616</pre>
+
+<p>You may also notice that the simple stock quote proxy service exposed in
+ESB is now available only in HTTP as we have specified transport for that
+service as HTTP. To observe this, access the WSDL of stock quote proxy
+service at http://localhost:8280/services/StockQuoteProxy?wsdl. </p>
+
+<p>This ESB configuration creates a proxy service over HTTP and forwards
+received messages to the above EPR using JMS, and sends back the response to
+the client over HTTP once the simple stock quote service responds with the
+stock quote reply over JMS to the ESB server. To test this, send a place
+order request to ESB using HTTP as follows: </p>
+<pre xml:space="preserve">ant stockquote -Daddurl=http://localhost:8280/services/StockQuoteProxy -Dmode=placeorder -Dsymbol=MSFT</pre>
+
+<p>The sample Axis2 server console will print a message indicating that it
+has accepted the order as follows: </p>
+<pre xml:space="preserve">Accepted order for : 18406 stocks of MSFT at $ 83.58806051152119</pre>
+
+<h2><a name="Sample252">Sample 252: Pure text/binary and POX message support
+with JMS</a> </h2>
+<pre xml:space="preserve">&lt;definitions xmlns="http://ws.apache.org/ns/synapse"&gt;
+
+    &lt;sequence name="text_proxy"&gt;
+        &lt;header name="Action" value="urn:placeOrder"/&gt;
+        &lt;script language="js"&gt;&lt;![CDATA[
+            var args = mc.getPayloadXML().toString().split(" ");
+            mc.setPayloadXML(
+            &lt;m:placeOrder xmlns:m="http://services.samples/xsd"&gt;
+                &lt;m:order&gt;
+                    &lt;m:price&gt;{args[0]}&lt;/m:price&gt;
+                    &lt;m:quantity&gt;{args[1]}&lt;/m:quantity&gt;
+                    &lt;m:symbol&gt;{args[2]}&lt;/m:symbol&gt;
+                &lt;/m:order&gt;
+            &lt;/m:placeOrder&gt;);
+        ]]&gt;&lt;/script&gt;
+        &lt;property action="set" name="OUT_ONLY" value="true"/&gt;
+        &lt;send&gt;
+            &lt;endpoint&gt;
+                &lt;address uri="http://localhost:9000/services/SimpleStockQuoteService"/&gt;
+            &lt;/endpoint&gt;
+        &lt;/send&gt;
+    &lt;/sequence&gt;
+
+    &lt;sequence name="mtom_proxy"&gt;
+        &lt;property action="set" name="OUT_ONLY" value="true"/&gt;
+        &lt;header name="Action" value="urn:oneWayUploadUsingMTOM"/&gt;
+        &lt;send&gt;
+            &lt;endpoint&gt;
+                &lt;address uri="http://localhost:9000/services/MTOMSwASampleService" optimize="mtom"/&gt;
+            &lt;/endpoint&gt;
+        &lt;/send&gt;
+    &lt;/sequence&gt;
+
+    &lt;sequence name="pox_proxy"&gt;
+        &lt;property action="set" name="OUT_ONLY" value="true"/&gt;
+        &lt;header name="Action" value="urn:placeOrder"/&gt;
+        &lt;send&gt;
+            &lt;endpoint&gt;
+                &lt;address uri="http://localhost:9000/services/SimpleStockQuoteService" format="soap11"/&gt;
+            &lt;/endpoint&gt;
+        &lt;/send&gt;
+    &lt;/sequence&gt;
+
+    &lt;sequence name="out"&gt;
+        &lt;send/&gt;
+    &lt;/sequence&gt;
+
+    &lt;proxy name="JMSFileUploadProxy" transports="jms"&gt;
+        &lt;target inSequence="mtom_proxy" outSequence="out"/&gt;
+        &lt;parameter name="transport.jms.Wrapper"&gt;{http://services.samples/xsd}element&lt;/parameter&gt;
+    &lt;/proxy&gt;
+    &lt;proxy name="JMSTextProxy" transports="jms"&gt;
+        &lt;target inSequence="text_proxy" outSequence="out"/&gt;
+        &lt;parameter name="transport.jms.Wrapper"&gt;{http://services.samples/xsd}text&lt;/parameter&gt;
+    &lt;/proxy&gt;
+    &lt;proxy name="JMSPoxProxy" transports="jms"&gt;
+        &lt;target inSequence="pox_proxy" outSequence="out"/&gt;
+    &lt;/proxy&gt;
+&lt;/definitions&gt;</pre>
+
+<p><strong>Objective: Pure POX/Text and Binary JMS Proxy services - including
+MTOM</strong> </p>
+
+<p><strong>Prerequisites:</strong><br />
+Configure JMS for ESB (Refer notes)<br />
+Start the Synapse configuration numbered 252: i.e. wso2server -Desb.sample=252<br />
+Start the Axis2 server and deploy the SimpleStockQuoteService and the
+MTOMSwASampleService if not already done </p>
+
+<p>This configuration creates three JMS proxy services named
+JMSFileUploadProxy, JMSTextProxy and JMSPoxProxy exposed over JMS queues with
+the same names as the services. The first part of this example demonstrates
+the pure text message support with JMS, where a user sends a space separated
+text JMS message of the form "&lt;price&gt; &lt;qty&gt; &lt;symbol&gt;". ESB
+converts this message into a SOAP message and sends this to the
+SimpleStockQuoteServices' placeOrder operation. ESB uses the script mediator
+to transform the text message into a XML payload using the Javascript support
+available to tokenize the string. The proxy service property named
+"transport.jms.Wrapper" defines a custom wrapper element QName, to be used
+when wrapping text/binary content into a SOAP envelope. </p>
+
+<p>Execute JMS client as follows. This will post a pure text JMS message with
+the content defined (e.g. "12.33 1000 ACP") to the specified JMS destination
+- dynamicQueues/JMSTextProxy </p>
+<pre xml:space="preserve">ant jmsclient -Djms_type=text -Djms_payload="12.33 1000 ACP" -Djms_dest=dynamicQueues/JMSTextProxy</pre>
+
+<p>Following the debug logs, you could notice that ESB received the JMS text
+message and transformed it into a SOAP payload as follows. Notice that the
+wrapper element "{http://services.samples/xsd}text" has been used to hold the
+text message content. </p>
+<pre xml:space="preserve">[JMSWorker-1] DEBUG ProxyServiceMessageReceiver - Body :
+&lt;?xml version='1.0' encoding='utf-8'?&gt;&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"&gt;
+  &lt;soapenv:Body&gt;&lt;axis2ns1:text xmlns:axis2ns1="http://services.samples/xsd"&gt;12.33 1000 ACP&lt;/axis2ns1:text&gt;&lt;/soapenv:Body&gt;
+&lt;/soapenv:Envelope&gt;</pre>
+
+<p>Now, you could see how the script mediator created a stock quote request
+by tokenizing the text as follows, and sent the message to the placeOrder
+operation of the SimpleStockQuoteService. </p>
+<pre xml:space="preserve">[JMSWorker-1] DEBUG AddressEndpoint - Sending message to endpoint :: name = AnonymousEndpoints resolved address = http://localhost:9000/services/SimpleStockQuoteService
+[JMSWorker-1] DEBUG AddressEndpoint - SOAPAction: urn:placeOrder
+[JMSWorker-1] DEBUG AddressEndpoint - WSA-Action: urn:placeOrder
+[JMSWorker-1] DEBUG AddressEndpoint - Body :
+&lt;?xml version='1.0' encoding='utf-8'?&gt;&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"&gt;&lt;soapenv:Body&gt;
+  &lt;m:placeOrder xmlns:m="http://services.samples/xsd"&gt;&lt;m:order&gt;&lt;m:price&gt;12.33&lt;/m:price&gt;&lt;m:quantity&gt;1000&lt;/m:quantity&gt;&lt;m:symbol&gt;ACP&lt;/m:symbol&gt;&lt;/m:order&gt;
+&lt;/m:placeOrder&gt;&lt;/soapenv:Body&gt;&lt;/soapenv:Envelope&gt;</pre>
+
+<p>The sample Axis2 server would now accept the one way message and issue the
+following message: </p>
+<pre xml:space="preserve">Wed Apr 25 19:50:56 LKT 2007 samples.services.SimpleStockQuoteService :: Accepted order for : 1000 stocks of ACP at $ 12.33</pre>
+
+<p>The next section of this example demonstrates how a pure binary JMS
+message could be received and processed through ESB. The configuration
+creates a proxy service named 'JMSFileUploadProxy' that accepts binary
+messages and wraps them into a custom element
+'{http://services.samples/xsd}element'. The received message is then
+forwarded to the MTOMSwASampleService using the SOAP action
+'urn:oneWayUploadUsingMTOM' and optimizing binary conent using MTOM. To
+execute this sample, use the JMS client to publish a pure binary JMS message
+containing the file
+'./../../repository/samples/resources/mtom/asf-logo.gif' to the JMS
+destination 'dynamicQueues/JMSFileUploadProxy' as follows: </p>
+<pre xml:space="preserve">ant jmsclient -Djms_type=binary -Djms_dest=dynamicQueues/JMSFileUploadProxy -Djms_payload=./../../repository/samples/resources/mtom/asf-logo.gif</pre>
+
+<p>Examining the ESB debug logs reveals that the binary content was received
+over JMS and wrapped with the specified element into a SOAP infoset as
+follows: </p>
+<pre xml:space="preserve">[JMSWorker-1] DEBUG ProxyServiceMessageReceiver - Proxy Service JMSFileUploadProxy received a new message...
+...
+[JMSWorker-1] DEBUG ProxyServiceMessageReceiver - Body :
+&lt;?xml version='1.0' encoding='utf-8'?&gt;&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"&gt;
+&lt;soapenv:Body&gt;&lt;axis2ns1:element xmlns:axis2ns1="http://services.samples/xsd"&gt;R0lGODlhgw...AAOw==&lt;/axis2ns1:element&gt;&lt;/soapenv:Body&gt;
+&lt;/soapenv:Envelope&gt;</pre>
+
+<p>Thereafter the message was sent as a MTOM optimized message as specified
+by the 'format=mtom' attribute of the endpoint, to the MTOMSwASampleService
+using the SOAP action 'urn:oneWayUploadUsingMTOM'. Once received by the
+sample service, it is saved into a temporary file and could be verified for
+correctness. </p>
+<pre xml:space="preserve">Wrote to file : ./../../work/temp/sampleServer/mtom-29208.gif</pre>
+
+<p>The final section of this example shows how a POX JMS message received by
+ESB is sent to the SimpleStockQuoteService as a SOAP message. Use the JMS
+client as follows to create a POX (Plain Old XML) message with a stock quote
+request payload (without a SOAP envelope), and send it to the JMS destination
+'dynamicQueues/JMSPoxProxy' as follows: </p>
+<pre xml:space="preserve">ant jmsclient -Djms_type=pox -Djms_dest=dynamicQueues/JMSPoxProxy -Djms_payload=MSFT</pre>
+
+<p>You can see that ESB received the POX message and displays it as follows
+in the debug logs, and then converts it into a SOAP payload and sends to the
+SimpleStockQuoteService after setting the SOAP action as 'urn:placeOrder'.
+</p>
+
+<pre xml:space="preserve">[JMSWorker-1] DEBUG ProxyServiceMessageReceiver - Proxy Service JMSPoxProxy received a new message...
+...
+[JMSWorker-1] DEBUG ProxyServiceMessageReceiver - Body :
+&lt;?xml version='1.0' encoding='utf-8'?&gt;&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"&gt;&lt;soapenv:Body&gt;&lt;m:placeOrder xmlns:m="http://services.samples/xsd"&gt;
+    &lt;m:order&gt;
+        &lt;m:price&gt;172.39703010684752&lt;/m:price&gt;
+        &lt;m:quantity&gt;19211&lt;/m:quantity&gt;
+        &lt;m:symbol&gt;MSFT&lt;/m:symbol&gt;
+    &lt;/m:order&gt;
+&lt;/m:placeOrder&gt;&lt;/soapenv:Body&gt;&lt;/soapenv:Envelope&gt;
+[JMSWorker-1] DEBUG ProxyServiceMessageReceiver - Using the sequence named pox_proxy for message mediation
+...
+[JMSWorker-1] DEBUG HeaderMediator - Setting header : Action to : urn:placeOrder
+...
+[JMSWorker-1] DEBUG AddressEndpoint - Sending message to endpoint :: name = AnonymousEndpoints resolved address = http://localhost:9000/services/SimpleStockQuoteService
+[JMSWorker-1] DEBUG AddressEndpoint - SOAPAction: urn:placeOrder
+[JMSWorker-1] DEBUG AddressEndpoint - Body :
+&lt;?xml version='1.0' encoding='utf-8'?&gt;&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"&gt;&lt;soapenv:Body&gt;&lt;m:placeOrder xmlns:m="http://services.samples/xsd"&gt;
+    &lt;m:order&gt;
+        &lt;m:price&gt;172.39703010684752&lt;/m:price&gt;
+        &lt;m:quantity&gt;19211&lt;/m:quantity&gt;
+        &lt;m:symbol&gt;MSFT&lt;/m:symbol&gt;
+    &lt;/m:order&gt;
+&lt;/m:placeOrder&gt;&lt;/soapenv:Body&gt;&lt;/soapenv:Envelope&gt;
+[JMSWorker-1] DEBUG Axis2FlexibleMEPClient - sending [add = false] [sec = false] [rm = false] [ mtom = false] [ swa = false] [ force soap=true; pox=false] [ to null] </pre>
+
+<p>The sample Axis2 server displays a successful message on the receipt of
+the message as: </p>
+<pre xml:space="preserve">Wed Apr 25 20:24:50 LKT 2007 samples.services.SimpleStockQuoteService :: Accepted order for : 19211 stocks of MSFT at $ 172.39703010684752</pre>
+
+<h2><a name="Sample253">Sample 253: One way bridging from JMS to http and
+replying with a 202 Accepted response</a> </h2>
+<pre xml:space="preserve">&lt;definitions xmlns="http://ws.apache.org/ns/synapse"&gt;
+
+    &lt;proxy name="JMStoHTTPStockQuoteProxy" transports="jms"&gt;
+        &lt;target&gt;
+            &lt;inSequence&gt;
+                &lt;property action="set" name="OUT_ONLY" value="true"/&gt;
+            &lt;/inSequence&gt;
+            &lt;endpoint&gt;
+                &lt;address uri="http://localhost:9000/services/SimpleStockQuoteService"/&gt;
+            &lt;/endpoint&gt;
+            &lt;outSequence&gt;
+                &lt;send/&gt;
+            &lt;/outSequence&gt;
+        &lt;/target&gt;
+        &lt;publishWSDL uri="file:repository/samples/resources/proxy/sample_proxy_1.wsdl"/&gt;
+    &lt;/proxy&gt;
+
+    &lt;proxy name="OneWayProxy" transports="http"&gt;
+        &lt;target&gt;
+            &lt;inSequence&gt;
+                &lt;log level="full"/&gt;
+            &lt;/inSequence&gt;
+            &lt;endpoint&gt;
+                &lt;address uri="http://localhost:9000/services/SimpleStockQuoteService"/&gt;
+            &lt;/endpoint&gt;
+            &lt;outSequence&gt;
+                &lt;send/&gt;
+            &lt;/outSequence&gt;
+        &lt;/target&gt;
+        &lt;publishWSDL uri="file:repository/samples/resources/proxy/sample_proxy_1.wsdl"/&gt;
+    &lt;/proxy&gt;
+
+&lt;/definitions&gt;</pre>
+
+<p><strong>Objective: Demonstrate one way message bridging from JMS to http
+and replying with a http 202 Accepted response</strong> </p>
+
+<p><strong>Prerequisites:</strong><br />
+Start the Axis2 server and deploy the SimpleStockQuoteService if not already
+done </p>
+
+<p>Start the Synapse configuration numbered 253: i.e. wso2server -Desb.sample=253
+</p>
+
+<p>This example invokes the one-way 'placeOrder' operation on the
+SimpleStockQuoteService using the Axis2 ServiceClient.fireAndForget() API at
+the client. To test this, use 'ant -Dmode=placeorder...' and you will notice
+the one way JMS message flowing through ESB into the sample Axis2 server
+instance over http, and Axis2 acknowledging it with a http 202 Accepted
+response. </p>
+<pre xml:space="preserve">ant stockquote -Dmode=placeorder -Dtrpurl="jms:/JMStoHTTPStockQuoteProxy?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&amp;java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&amp;java.naming.provider.url=tcp://localhost:61616"</pre>
+<pre xml:space="preserve">SimpleStockQuoteService :: Accepted order for : 7482 stocks of IBM at $ 169.27205579038733</pre>
+
+<p>The second example shows how ESB could be made to respond with a http 202
+Accepted response to a request received. The proxy service simply logs the
+message received and acknowledges it. On the ESB console you could see the
+logged message, and if TCPMon was used at the client, you would see the 202
+Accepted response sent back to the client from ESB </p>
+<pre xml:space="preserve">ant stockquote -Dmode=placeorder -Dtrpurl=http://localhost:8280/services/OneWayProxy</pre>
+<pre xml:space="preserve">HTTP/1.1 202 Accepted
+Content-Type: text/xml; charset=UTF-8
+Host: 127.0.0.1
+SOAPAction: "urn:placeOrder"
+Date: Sun, 06 May 2007 17:20:19 GMT
+Server: Synapse-HttpComponents-NIO
+Transfer-Encoding: chunked
+
+0</pre>
+
+<h2><a name="Sample254">Sample 254: Using the file system as transport medium
+using VFS transport listener and sender</a> </h2>
+<pre xml:space="preserve">&lt;definitions xmlns="http://ws.apache.org/ns/synapse"&gt;
+        &lt;proxy name="StockQuoteProxy" transports="vfs"&gt;
+                &lt;parameter name="transport.vfs.FileURI"&gt;file:///home/user/test/in&lt;/parameter&gt; &lt;!--CHANGE--&gt;
+                &lt;parameter name="transport.vfs.ContentType"&gt;text/xml&lt;/parameter&gt;
+                &lt;parameter name="transport.vfs.FileNamePattern"&gt;.*\.xml&lt;/parameter&gt;
+                &lt;parameter name="transport.PollInterval"&gt;15&lt;/parameter&gt;
+                &lt;parameter name="transport.vfs.MoveAfterProcess"&gt;file:///home/user/test/original&lt;/parameter&gt; &lt;!--CHANGE--&gt;
+                &lt;parameter name="transport.vfs.MoveAfterFailure"&gt;file:///home/user/test/original&lt;/parameter&gt; &lt;!--CHANGE--&gt;
+                &lt;parameter name="transport.vfs.ActionAfterProcess"&gt;MOVE&lt;/parameter&gt;
+                &lt;parameter name="transport.vfs.ActionAfterFailure"&gt;MOVE&lt;/parameter&gt;
+
+                &lt;target&gt;
+                        &lt;endpoint&gt;
+                                &lt;address format="soap12" uri="http://localhost:9000/services/SimpleStockQuoteService"/&gt;
+                        &lt;/endpoint&gt;
+                        &lt;outSequence&gt;
+                                &lt;property name="transport.vfs.ReplyFileName"
+                                          expression="fn:concat(fn:substring-after(get-property('MessageID'), 'urn:uuid:'), '.xml')" scope="transport"/&gt;
+                                &lt;send&gt;
+                                        &lt;endpoint&gt;
+                                                &lt;address uri="vfs:file:///home/user/test/out"/&gt; &lt;!--CHANGE--&gt;
+                                        &lt;/endpoint&gt;
+                                &lt;/send&gt;
+                        &lt;/outSequence&gt;
+                &lt;/target&gt;
+                &lt;publishWSDL uri="file:repository/samples/resources/proxy/sample_proxy_1.wsdl"/&gt;
+        &lt;/proxy&gt;
+&lt;/definitions&gt; </pre>
+
+<p><strong>Objective: Using the file system as transport medium using VFS
+transport listener and sender</strong> </p>
+
+<p>Start the Axis2 server and deploy the SimpleStockQuoteService if not
+already done </p>
+
+<p>Create three new directories in a test directory. e.g. in, out, original
+in /home/user/test. Open
+ESB_HOME/repository/samples/synapse_sample_254.xml and edit the following
+values. Change transport.vfs.FileURI, transport.vfs.MoveAfterProcess,
+transport.vfs.MoveAfterFailure parameter values to the above in, original,
+original directories respectively. Change outSequence endpoint address uri to
+out directory with the prefix <em>vfs:</em>. Values you have to change are
+marked with &lt;!--CHANGE--&gt;. </p>
+
+<p>Start the Synapse configuration numbered 254: i.e. wso2server -Desb.sample=254
+</p>
+
+<p>Copy ESB_HOME/repository/samples/resources/vfs/test.xml to the
+directory given in transport.vfs.FileURI above. </p>
+
+<p>test.xml file content is as follows </p>
+<pre xml:space="preserve">&lt;?xml version='1.0' encoding='UTF-8'?&gt;
+        &lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing"&gt;
+        &lt;soapenv:Body&gt;
+                &lt;m0:getQuote xmlns:m0="http://services.samples/xsd"&gt;
+                        &lt;m0:request&gt;
+                                &lt;m0:symbol&gt;IBM&lt;/m0:symbol&gt;
+                        &lt;/m0:request&gt;
+                &lt;/m0:getQuote&gt;
+        &lt;/soapenv:Body&gt;
+&lt;/soapenv:Envelope&gt;</pre>
+
+<p>VFS transport listener will pick the file from <em>in</em> directory and
+send it to the Axis2 service. The request XML file will be moved to
+<em>original</em> directory. The response from the Axis2 server will be saved
+to <em>out</em> directory. </p>
+
+<h2><a name="Sample255">Sample 255: Switching from ftp transport listener to
+mail transport sender</a> </h2>
+<pre xml:space="preserve">&lt;definitions xmlns="http://ws.apache.org/ns/synapse"&gt;
+        &lt;proxy name="StockQuoteProxy" transports="vfs"&gt;
+                &lt;parameter name="transport.vfs.FileURI"&gt;vfs:ftp://guest:guest@localhost/test?vfs.passive=true&lt;/parameter&gt; &lt;!--CHANGE--&gt;
+                &lt;parameter name="transport.vfs.ContentType"&gt;text/xml&lt;/parameter&gt;
+                &lt;parameter name="transport.vfs.FileNamePattern"&gt;.*\.xml&lt;/parameter&gt;
+                &lt;parameter name="transport.PollInterval"&gt;15&lt;/parameter&gt;
+
+                &lt;target&gt;
+                        &lt;inSequence&gt;
+                                &lt;header name="Action" value="urn:getQuote"/&gt;
+                        &lt;/inSequence&gt;
+                        &lt;endpoint&gt;
+                                &lt;address uri="http://localhost:9000/services/SimpleStockQuoteService"/&gt;
+                        &lt;/endpoint&gt;
+                        &lt;outSequence&gt;
+                                &lt;property action="set" name="OUT_ONLY" value="true"/&gt;
+                                &lt;send&gt;
+                                        &lt;endpoint&gt;
+                                                &lt;address uri="mailto:user at host"/&gt; &lt;!--CHANGE--&gt;
+                                        &lt;/endpoint&gt;
+                                &lt;/send&gt;
+                        &lt;/outSequence&gt;
+                &lt;/target&gt;
+                &lt;publishWSDL uri="file:repository/samples/resources/proxy/sample_proxy_1.wsdl"/&gt;
+        &lt;/proxy&gt;
+&lt;/definitions&gt; </pre>
+
+<p><strong>Objective: Switching from ftp transport listener to mail transport
+sender</strong> </p>
+
+<p><strong>Prerequisites:</strong><br />
+You will need access to an FTP server and an SMTP server to try this sample.
+</p>
+
+<p>Start the Axis2 server and deploy the SimpleStockQuoteService if not
+already done </p>
+
+<p>Enable mail transport sender in the ESB axis2.xml. See <a
+href="samples_setup_guide.html#mailsender">Setting up mail transport sender</a>
+</p>
+
+<p>Create a new test directory in the FTP server. Open
+ESB_HOME/repository/samples/synapse_sample_255.xml and edit the following
+values. Change transport.vfs.FileURI parameter value point to the test
+directory at the FTP server. Change outSequence endpoint address uri email
+address to a working email address. Values you have to change are marked with
+&lt;!--CHANGE--&gt;. </p>
+
+<p>Start the Synapse configuration numbered 255: i.e. wso2server -Desb.sample=255
+</p>
+
+<p>Copy ESB_HOME/repository/samples/resources/vfs/test.xml to the ftp
+directory given in transport.vfs.FileURI above. </p>
+
+<p>VFS transport listener will pick the file from the directory in the ftp
+server and send it to the Axis2 service. The file in the ftp directory will
+be deleted. The response will be sent to the given email address. </p>
+
+<h2><a name="Sample256">Sample 256: Proxy services with the mail transport </a>
+</h2>
+<pre xml:space="preserve">&lt;!-- Using the mail transport --&gt;
+&lt;definitions xmlns="http://ws.apache.org/ns/synapse"&gt;
+    &lt;proxy name="StockQuoteProxy" transports="mailto"&gt;
+
+        &lt;parameter name="transport.mail.Address"&gt;synapse.demo.1 at gmail.com&lt;/parameter&gt;
+        &lt;parameter name="transport.mail.Protocol"&gt;pop3&lt;/parameter&gt;
+        &lt;parameter name="transport.PollInterval"&gt;5&lt;/parameter&gt;
+        &lt;parameter name="mail.pop3.host"&gt;pop.gmail.com&lt;/parameter&gt;
+        &lt;parameter name="mail.pop3.port"&gt;995&lt;/parameter&gt;
+        &lt;parameter name="mail.pop3.user"&gt;synapse.demo.1&lt;/parameter&gt;
+        &lt;parameter name="mail.pop3.password"&gt;mailpassword&lt;/parameter&gt;
+        &lt;parameter name="mail.pop3.socketFactory.class"&gt;javax.net.ssl.SSLSocketFactory&lt;/parameter&gt;
+        &lt;parameter name="mail.pop3.socketFactory.fallback"&gt;false&lt;/parameter&gt;
+        &lt;parameter name="mail.pop3.socketFactory.port"&gt;995&lt;/parameter&gt;
+
+        &lt;target&gt;
+            &lt;inSequence&gt;
+                &lt;property name="senderAddress" expression="get-property('transport', 'From')"/&gt;
+                &lt;log level="full"&gt;
+                    &lt;property name="Sender Address" expression="get-property('senderAddress')"/&gt;
+                &lt;/log&gt;
+                &lt;send&gt;
+                    &lt;endpoint&gt;
+                        &lt;address uri="http://localhost:9000/services/SimpleStockQuoteService"/&gt;
+                    &lt;/endpoint&gt;
+                &lt;/send&gt;
+            &lt;/inSequence&gt;
+            &lt;outSequence&gt;
+                &lt;property name="Subject" value="Custom Subject for Response" scope="transport"/&gt;
+                &lt;header name="To" expression="fn:concat('mailto:', get-property('senderAddress'))"/&gt;
+                &lt;log level="full"&gt;
+                    &lt;property name="message" value="Response message"/&gt;
+                    &lt;property name="Sender Address" expression="get-property('senderAddress')"/&gt;
+                &lt;/log&gt;
+                &lt;send/&gt;
+            &lt;/outSequence&gt;
+        &lt;/target&gt;
+        &lt;publishWSDL uri="file:repository/samples/resources/proxy/sample_proxy_1.wsdl"/&gt;
+    &lt;/proxy&gt;
+&lt;/definitions&gt; </pre>
+
+<p><strong>Objective: Using the mail transport with Proxy services</strong>
+</p>
+
+<p><strong>Prerequisites:</strong><br />
+You will need access to an email account </p>
+
+<p>Start the Axis2 server and deploy the SimpleStockQuoteService if not
+already done </p>
+
+<p>Enable mail transport sender in the Synapse axis2.xml. See <a
+href="samples_setup_guide.html#mailsender">Setting up mail transport sender</a>
+</p>
+
+<p>Start the Synapse configuration numbered 256: i.e. wso2server -Desb.sample=256
+</p>
+
+<p>Send a plain/text email with the following body and any custom Subject
+from your mail account. </p>
+<pre xml:space="preserve">&lt;m0:getQuote xmlns:m0="http://services.samples/xsd"&gt;&lt;m0:request&gt;&lt;m0:symbol&gt;IBM&lt;/m0:symbol&gt;&lt;/m0:request&gt;&lt;/m0:getQuote&gt; </pre>
+
+<p>After a few seconds (e.g. 30s), you should receive a POX response in your
+email account with the stock quote reply. </p>
+
+    <h2>
+      <a name="Sample257">Sample 257: Proxy services with the
+      FIX transport </a>
+    </h2>
+<pre xml:space="preserve">&lt;!-- Using the FIX transport --&gt;
+&lt;definitions xmlns="http://ws.apache.org/ns/synapse"&gt;
+    &lt;proxy name="FIXProxy" transports="fix"&gt;
+
+        &lt;parameter name="transport.fix.AcceptorConfigURL"&gt;file:/home/synapse_user/fix-config/fix-synapse.cfg&lt;/parameter&gt;
+        &lt;parameter name="transport.fix.InitiatorConfigURL"&gt;file:/home/synapse_user/fix-config/synapse-sender.cfg&lt;/parameter&gt;
+        &lt;parameter name="transport.fix.AcceptorMessageStore"&gt;file&lt;/parameter&gt;
+        &lt;parameter name="transport.fix.InitiatorMessageStore"&gt;file&lt;/parameter&gt;
+
+        &lt;target&gt;
+            &lt;endpoint&gt;
+                &lt;address uri="fix://localhost:19876?BeginString=FIX.4.0&amp;amp;SenderCompID=SYNAPSE&amp;amp;TargetCompID=EXEC"/&gt;
+            &lt;/endpoint&gt;
+	    &lt;inSequence&gt;
+		&lt;log level="full"/&gt;
+	    &lt;/inSequence&gt;
+            &lt;outSequence&gt;
+                &lt;log level="full"/&gt;
+		&lt;send/&gt;
+            &lt;/outSequence&gt;
+        &lt;/target&gt;
+    &lt;/proxy&gt;
+&lt;/definitions&gt; </pre>
+    <p>
+      <strong>Objective: Demonstrate the usage of the FIX (Financial Information eXchange) transport with proxy services</strong>
+    </p>
+    <p>
+      <strong>Prerequisites:</strong><br/>
+       You will need the two sample FIX applications that come with Quickfix/J
+       (Banzai and Executor). Configure the two applications to establish
+       sessions with Synapse. See <a href="samples_setup_guide.html#fixsamplesconfig">
+       Configuring Sample FIX Applications</a>
+    </p>
+    <p>
+      Start Banzai and Executor
+    </p>
+    <p>
+      Enable FIX transport in the Synapse axis2.xml. See <a
+      href="samples_setup_guide.html#fixtransport">Setting up FIX transport
+      </a>
+    </p>
+    <p>
+      Configure Synapse for FIX samples. See <a href="samples_setup_guide.html#fixsamples">
+      Configuring Synapse for FIX Samples</a>
+    </p>
+    <p>
+      Open up the SYNAPSE_HOME/repository/samples/synapse_sample_257.xml file
+      and make sure that transport.fix.AcceptorConfigURL property points to the
+      fix-synapse.cfg file you created. Also make sure that transport.fix.
+      InitiatorConfigURL property points to the synapse-sender.cfg file you
+      created. Once done you can start the Synapse configuration numbered 257:
+      i.e. synapse -sample 257. Note that Synapse creates a new FIX session with
+      Banzai at this point.
+    </p>
+    <p>
+      Send an order request from Banzai to Synapse.
+    </p>
+    <p>
+      Synapse will create a session with Executor and forward the order request. The
+      responses coming from the Executor will be sent back to Banzai. It will take a
+      couple of seconds for the responses to arrive for the first request since Synapse
+      has to establish a session with the Executor. But all the subsequent messages
+      will pass through almost instantaneously.
+    </p>
+    <h2>
+      <a name="Sample258">Sample 258: Switching from HTTP to FIX </a>
+    </h2>
+<pre xml:space="preserve">
+&lt;definitions xmlns="http://ws.apache.org/ns/synapse"&gt;
+    &lt;proxy name="FIXProxy"&gt;
+
+        &lt;parameter name="transport.fix.InitiatorConfigURL"&gt;file:/home/synapse_user/fix-config/synapse-sender.cfg&lt;/parameter&gt;
+        &lt;parameter name="transport.fix.InitiatorMessageStore"&gt;file&lt;/parameter&gt;
+        &lt;parameter name="transport.fix.SendAllToInSequence"&gt;false&lt;/parameter&gt;
+
+        &lt;target&gt;
+            &lt;endpoint&gt;
+                &lt;address uri="fix://localhost:19876?BeginString=FIX.4.0&amp;amp;SenderCompID=SYNAPSE&amp;amp;TargetCompID=EXEC"/&gt;
+            &lt;/endpoint&gt;
+	    &lt;inSequence&gt;
+	    	&lt;property name="transport.fix.ServiceName" value="FIXProxy" scope="axis2-client"/&gt;
+			&lt;log level="full"/&gt;
+	    &lt;/inSequence&gt;
+        &lt;outSequence&gt;
+            &lt;log level="full"/&gt;
+			&lt;send/&gt;
+        &lt;/outSequence&gt;
+        &lt;/target&gt;
+    &lt;/proxy&gt;
+&lt;/definitions&gt; </pre>
+    <p>
+      <strong>Objective: Demonstrate switching from HTTP to FIX</strong>
+    </p>
+    <p>
+      <strong>Prerequisites:</strong><br/>
+       You will need the Executor sample application that comes with Quickfix/J.
+       Configure Executor to establish a session with Synapse. See <a href=
+       "samples_setup_guide.html#fixsamplesconfig">Configuring Sample FIX
+       Applications</a>
+    </p>
+    <p>
+      Start Executor.
+    </p>
+    <p>
+      Enable FIX transport sender in the Synapse axis2.xml. See <a
+      href="samples_setup_guide.html#fixtransport">Setting up FIX transport
+      </a>
+    </p>
+    <p>
+      Configure Synapse for FIX samples. See <a href="samples_setup_guide.html#fixsamples">
+      Configuring Synapse for FIX Samples</a>. There is no need to create the fix-synapse.cfg
+      file for this sample. Having only the synapse-sender.cfg file is sufficient.
+    </p>
+    <p>
+      Go to the SYNAPSE_HOME/repository/samples/synapse_sample_258.xml
+      file and make sure that transport.fix.InitiatorConfigURL property
+      points to the synapse-sender.cfg file you created. Once done you can
+      start the Synapse configuration numbered 258: i.e. synapse -sample 258
+    </p>
+    <p>
+      Invoke the FIX Client as follows. This command sends a FIX message
+      embedded in a SOAP message over HTTP.
+    </p>
+    <pre>ant fixclient -Dsymbol=IBM -Dqty=5 -Dmode=buy -Daddurl=http://localhost:8280/services/FIXProxy</pre>
+    <p>
+      Synapse will create a session with Executor and forward the order request. The
+      first response coming from the Executor will be sent back over HTTP. Executor
+      generally sends two responses for each incoming order request. But since the
+      response has to be forwarded over HTTP only one can be sent back to the client.
+    </p>
 </body>
 </html>
\ No newline at end of file



More information about the Carbon-dev mailing list