<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
  ~  Copyright (c) 2009, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
  ~
  ~  WSO2 Inc. licenses this file to you 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.
  -->

<!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta content="text/html; charset=iso-8859-1" http-equiv="content-type"/>
  <title>WSO2 ESB - Transport Switching Samples </title>
</head>

<body>
<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;parameter name="transport.jms.ContentType"&gt;
            &lt;rules&gt;
                &lt;jmsProperty&gt;contentType&lt;/jmsProperty&gt;
                &lt;default&gt;application/xml&lt;/default&gt;
            &lt;/rules&gt;
        &lt;/parameter&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. wso2esb-samples -sn 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
(<a href="http://ws.apache.org/axis2/1_1/jms-transport.html">http://ws.apache.org/axis2/1_1/jms-transport.html</a>). You will also need to
copy the ActiveMQ client jar files 
activemq-core-5.2.0.jar and geronimo-j2ee-management_1.0_spec-1.0.jar into
the repository/components/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>You need to enable the JMS transport sender for the ESB to be able to send
messages over the JMS transport. To enable the JMS transport sender uncomment
the Axis2 transport sender configuration found at repository/conf/axis2.xml as </p>
<pre xml:space="preserve">&lt;transportSender name="jms" class="org.apache.axis2.transport.jms.JMSSender" /&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 place order 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 over JMS in Synapse. ESB forwards this message to the HTTP EPR of the
simple stock quote service hosted on the sample Axis2 server, which sends a
202 Accepted response back to the ESB. Since the placeOrder operation is an
in-only service operation the JMS client does not receive any response in this
sample.</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 Synapse JMS transport (refer notes above - sample 250)<br />
Start the Synapse configuration numbered 251: i.e. wso2esb-samples -sn 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. 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;parameter name="transport.jms.ContentType"&gt;application/xml&lt;/parameter&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. wso2esb-samples -sn 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. wso2esb-samples -sn 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&amp;transport.jms.ContentTypeProperty=Content-Type&amp;transport.jms.DestinationType=queue"</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;property action="set" name="OUT_ONLY" value="true"/&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>In the axis2.xml uncomment the VFS transport listener and sender.</p>

<p>Start the Synapse configuration numbered 254: i.e. wso2esb-samples -sn 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"&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>
<p> Note: Please make sure to uncomment  "VFSTransportListener" and "VFSTransportSender" in the axis2 configuration.(axis2.xml)</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@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. wso2esb-samples -sn 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@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;parameter name="transport.mail.ContentType"&gt;application/xml&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 listener in the ESB axis2.xml. Simply uncomment the relevant
transport receiver entry in the file.</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>Enable mail transport receiver in the ESB axis2.xml. See <a
href="../samples_setup_guide.html#mailreceiver">Setting up mail transport listener</a>
</p>

<p>Start the Synapse configuration numbered 256: i.e. wso2esb-samples -sn 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"&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>
<p>Note that in this sample we used the <tt>transport.mail.ContentType</tt> property to make sure
that the transport parses the request message as POX. If you remove this property, you may still
be able to send requests using a standard mail client if instead of writing the XML in the body of
the message, you add it as an attachment. In that case, you should use <tt>.xml</tt> as a suffix
for the attachment and format the request as a SOAP 1.1 message. Indeed, for a file with suffix
<tt>.xml</tt> the mail client will most likely use <tt>text/xml</tt> as the content type, exactly
as required for SOAP 1.1. Sending a POX message using this approach will be a lot trickier,
because most standard mail clients don't allow the user to explicitly set the content type.</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 the ESB. 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 WSO2 ESB for FIX Samples</a>
    </p>
    <p>
      Open up the ESB_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. wso2esb-samples -sn 257. Note that the ESB creates a new FIX session with
      Banzai at this point.
    </p>
    <p>
      Send an order request from Banzai to the ESB.
    </p>
    <p>
      WSO2 ESB will create a session with Executor and forward the order request. The
      responses coming from the Executor will be sent back to Banzai.
    </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;parameter name="transport.fix.DropExtraResponses"&gt;true&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 ESB_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. wso2esb-samples -sn 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>
    <h2>
<a name="Sample259" >Sample 259: Switch from FIX to HTTP </a></h2>
<pre xml:space="preserve">&lt;definitions xmlns=&quot;http://ws.apache.org/ns/synapse&quot;&gt;
    &lt;localEntry key=&quot;xslt-key-req&quot; src=&quot;file:repository/conf/sample/resources/transform/transform_fix_to_http.xslt&quot; /&gt;
    &lt;proxy name=&quot;FIXProxy&quot; transports=&quot;fix&quot;&gt;
        &lt;target&gt;
            &lt;endpoint&gt;
                &lt;address
                    uri=&quot;http://localhost:9000/services/SimpleStockQuoteService&quot; /&gt;
            &lt;/endpoint&gt;
            &lt;inSequence&gt;
                &lt;log level=&quot;full&quot; /&gt;
                &lt;xslt key=&quot;xslt-key-req&quot; /&gt;
                &lt;log level=&quot;full&quot; /&gt;
            &lt;/inSequence&gt;
            &lt;outSequence&gt;
                &lt;log level=&quot;full&quot; /&gt;
            &lt;/outSequence&gt;
        &lt;/target&gt;
    &lt;parameter name=&quot;transport.fix.AcceptorConfigURL&quot;&gt;
        file:repository/conf/sample/resources/fix/fix-synapse.cfg
    &lt;/parameter&gt;
    &lt;parameter name=&quot;transport.fix.AcceptorMessageStore&quot;&gt;
        file
    &lt;/parameter&gt;
   &lt;/proxy&gt;
&lt;/definitions&gt;
      </pre>
<p>
<strong>Objective: Demonstrate the capability of switching between FIX to HTTP</strong> </p>
<p>
<strong>Prerequisites:</strong>
<br></br> You will need the sample FIX blotter that come with Quickfix/J (Banzai). Configure the blotter to establish sessions with Synapse. See
<a href="../samples_setup_guide.html#fixsamplesconfig">Configuring Sample FIX Applications</a> </p>
<p>Start the Axis2 server and deploy the SimpleStockQuoteService if not already deployed </p>
<p>Start Banzai </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 ESB for FIX samples. See
<a href="../samples_setup_guide.html#fixsamples">Configuring the ESB for FIX Samples</a> </p>
<p>Open up the ESB_HOME/repository/samples/synapse_sample_259.xml file and make sure that transport.fix.AcceptorConfigURL property points to the fix-synapse.cfg file you created. Once done you can start the Synapse configuration numbered 259: i.e. wso2esb-samples -sn 259. Note that Synapse creates a new FIX session with Banzai at this point. </p>
<p>Send an order request from Banzai to Synapse. e.g. Buy DELL 1000 @ 100. User has to send a 'Limit' Order because price is a mandatory field for 'placeOrder' operation. </p>
<p>ESB will forward the order request to one-way 'placeOrder' operation on the SimpleStockQuoteService. ESB uses a simple XSLT mediator to transform the incoming FIX to a SOAP message. </p>
<pre xml:space="preserve">&lt;xsl:stylesheet version=&quot;2.0&quot;
    xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;
    xmlns:fn=&quot;http://www.w3.org/2005/02/xpath-functions&quot;&gt;
    &lt;xsl:output method=&quot;xml&quot; omit-xml-declaration=&quot;yes&quot; indent=&quot;yes&quot; /&gt;
  &lt;xsl:template match=&quot;/&quot;&gt;
    &lt;m0:placeOrder xmlns:m0=&quot;http://services.samples&quot;&gt;
        &lt;m0:order&gt;
            &lt;m0:price&gt;&lt;xsl:value-of select=&quot;//message/body/field[@id='44']&quot;/&gt;&lt;/m0:price&gt;
            &lt;m0:quantity&gt;&lt;xsl:value-of select=&quot;//message/body/field[@id='38']&quot;/&gt;&lt;/m0:quantity&gt;
            &lt;m0:symbol&gt;&lt;xsl:value-of select=&quot;//message/body/field[@id='55']&quot;/&gt;&lt;/m0:symbol&gt;
        &lt;/m0:order&gt;
    &lt;/m0:placeOrder&gt;
   &lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;
      </pre>
<p>To get an idea about the various transport parameters being used in this sample see
<a href="../transports/transports-catalog.html#FixTrp">FIX Transport Parameters</a>. </p>

<h2>
<a name="Sample260">Sample 260: Switch from FIX to AMQP </a></h2>
<pre xml:space="preserve">&lt;definitions xmlns=&quot;http://ws.apache.org/ns/synapse&quot;&gt;
    &lt;proxy name=&quot;FIXProxy&quot; transports=&quot;fix&quot;&gt;
        &lt;target&gt;
            &lt;endpoint&gt;
                &lt;address uri=&quot;jms:/QpidStockQuoteService?transport.jms.ConnectionFactoryJNDIName=qpidConnectionfactory&amp;amp;java.naming.factory.initial=org.apache.qpid.jndi.PropertiesFileInitialContextFactory&amp;amp;java.naming.provider.url=repository/conf/sample/resources/fix/con.properties&amp;amp;transport.jms.ReplyDestination=replyQueue&quot;/&gt;
            &lt;/endpoint&gt;
            &lt;inSequence&gt;
                &lt;log level=&quot;full&quot; /&gt;
            &lt;/inSequence&gt;
            &lt;outSequence&gt;
                &lt;property name=&quot;transport.fix.ServiceName&quot;
                    value=&quot;FIXProxy&quot; scope=&quot;axis2-client&quot; /&gt;
                &lt;log level=&quot;full&quot; /&gt;
                        &lt;send /&gt;
            &lt;/outSequence&gt;
        &lt;/target&gt;
        &lt;parameter name=&quot;transport.fix.AcceptorConfigURL&quot;&gt;
            file:repository/conf/sample/resources/fix/fix-synapse.cfg
        &lt;/parameter&gt;
        &lt;parameter name=&quot;transport.fix.AcceptorMessageStore&quot;&gt;
            file
        &lt;/parameter&gt;
    &lt;/proxy&gt;
&lt;/definitions&gt;</pre>
<p>
<strong>Objective: Demonstrate the capability of switching between FIX and AMQP protocols</strong> </p>
<p>
<strong>Prerequisites:</strong>
<br></br> You will need the sample FIX blotter that comes with Quickfix/J (Banzai). Configure the blotter to establish sessions with Synapse. See
<a href="../samples_setup_guide.html#fixsamplesconfig">Configuring Sample FIX Applications</a> </p>
<p>Configure the AMQP transport for WSO2 ESB. See
<a href="../samples_setup_guide.html#setupamqpjms">Configure ESB for AMQP Transport</a> </p>
<p>Start the AMQP consumer, by switching to samples/axis2Client directory and running the consumer using the following command. Consumer will listen to the queue 'QpidStockQuoteService', accept the orders and reply to the queue 'replyQueue'. </p>
<pre xml:space="preserve">ant amqpconsumer -Dpropfile=$ESB_HOME/repository/samples/resources/fix/direct.properties</pre>
<p>Start Banzai </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 ESB_HOME/repository/samples/synapse_sample_260.xml file and make sure that the transport.fix.AcceptorConfigURL property points to the fix-synapse.cfg file you created. Once done you can start the Synapse configuration numbered 260: i.e. wso2esb-samples -sn 260. Note that Synapse creates a new FIX session with Banzai at this point. </p>
<p>Send an order request from Banzai to Synapse. e.g. Buy DELL 1000 @ MKT. </p>
<p>Synapse will forward the order request by binding it to a JMS message payload and sending it to the AMQP consumer. AMQP consumer will send a execution back to Banzai. </p>

<h2>
<a name="Sample261">Sample 261: Switch between FIX versions </a></h2>
<pre xml:space="preserve">&lt;definitions xmlns=&quot;http://ws.apache.org/ns/synapse&quot;&gt;
     &lt;proxy name=&quot;OrderProcesserProxy41&quot; transports=&quot;fix&quot;&gt;
        &lt;target&gt;
           &lt;endpoint&gt;
              &lt;address uri=&quot;fix://localhost:19877?BeginString=FIX.4.1&amp;amp;SenderCompID=SYNAPSE&amp;amp;TargetCompID=EXEC&quot;/&gt;
           &lt;/endpoint&gt;
           &lt;inSequence&gt;&lt;log level=&quot;full&quot;/&gt;&lt;/inSequence&gt;
           &lt;outSequence&gt;&lt;log level=&quot;full&quot;/&gt;&lt;send/&gt;&lt;/outSequence&gt;
        &lt;/target&gt;
        &lt;parameter name=&quot;transport.fix.AcceptorConfigURL&quot;&gt;file:repository/conf/sample/resources/fix/fix-synapse-m40.cfg&lt;/parameter&gt;
        &lt;parameter name=&quot;transport.fix.AcceptorMessageStore&quot;&gt;file&lt;/parameter&gt;
        &lt;parameter name=&quot;transport.fix.InitiatorConfigURL&quot;&gt;file:repository/conf/sample/resources/fix/synapse-sender-m.cfg&lt;/parameter&gt;
        &lt;parameter name=&quot;transport.fix.InitiatorMessageStore&quot;&gt;file&lt;/parameter&gt;
     &lt;/proxy&gt;
&lt;/definitions&gt;</pre>
<p>
<strong>Objective: Demonstrate the capability of switching between FIX versions e.g. FIX4.0 to FIX4.1</strong> </p>
<p>
<strong>Prerequisites:</strong>
<br></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>Add the following lines to the Banzai configuration file (banzai.cfg). </p>
<pre xml:space="preserve">DataDictionary=~/etc/spec/FIX40-synapse.xml</pre>
<p>Note: FIX40-synapse.xml can be found at $ESB_HOME/repository/sampless/resources/fix. This is a custom FIX data dictionary file that has added tag 150,151 to the execution messages (35=8) of FIX4.0. Make sure the DataDictionary property of the banzai.cfg points to this data dictionary file. </p>
<p>Add the following lines to the Executor configuration file (executor.cfg). </p>
<pre xml:space="preserve">[session]
BeginString=FIX.4.1
SocketAcceptPort=19877</pre>
<p>Start Banzai and Executor using the custom configuration files. </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. We will be using two custom configuration files for Synapse in this sample. These two custom configuration files can be found at ESB_HOME/repository/conf/sample/resources/fix directory. The two files are called fix-synapse-m40.cfg and synapse-sender-m.cfg. You can point your Synapse configuration to these two files (this is already done in the supplied synapse_sample_261.xml file) or you may create copies of them and point the Synapse configuration to the copies. In either case make sure that the properties like FileStorePath and FileLogPath in the two files point to valid locations in your local file system. </p>
<p>Open up the $ESB_HOME/repository/samples/synapse_sample_261.xml file and make sure that transport.fix.AcceptorConfigURL property points to the fix-synapse-m40.cfg file described above and transport.fix.InitiatorConfigURL points to the synapse-sender-m.cfg file described above. Once done you can start the Synapse configuration numbered 261: i.e. wso2esb-samples -sn 261. Note that Synapse creates a new FIX session with Banzai at this point. </p>
<p>Send an order request from Banzai to Synapse. e.g. Buy DELL 1000 @ MKT. </p>
<p>Synapse will forward the order request from FIX4.0 to the Executor that accepts FIX4.1 messages. Executor will send an ack and an execution back to Banzai. </p>

<h2>
<a name="Sample262">Sample 262: CBR of FIX messages</a></h2>
<pre xml:space="preserve">&lt;definitions xmlns=&quot;http://ws.apache.org/ns/synapse&quot;&gt;
    &lt;sequence name=&quot;CBR_SEQ&quot;&gt;
        &lt;in&gt;
            &lt;switch source=&quot;//message/body/field[@id='55']&quot;&gt;
                &lt;case regex=&quot;GOOG&quot;&gt;
                    &lt;send&gt;
                        &lt;endpoint&gt;
                            &lt;address
                                uri=&quot;fix://localhost:19876?BeginString=FIX.4.0&amp;amp;SenderCompID=SYNAPSE&amp;amp;TargetCompID=EXEC&quot; /&gt;
                        &lt;/endpoint&gt;
                    &lt;/send&gt;
                &lt;/case&gt;
                &lt;case regex=&quot;MSFT&quot;&gt;
                    &lt;send&gt;
                        &lt;endpoint&gt;
                            &lt;address
                                uri=&quot;fix://localhost:19877?BeginString=FIX.4.1&amp;amp;SenderCompID=SYNAPSE&amp;amp;TargetCompID=EXEC&quot; /&gt;
                        &lt;/endpoint&gt;
                    &lt;/send&gt;
                &lt;/case&gt;
                &lt;default&gt;&lt;/default&gt;
            &lt;/switch&gt;
        &lt;/in&gt;
        &lt;out&gt;
            &lt;send /&gt;
        &lt;/out&gt;
    &lt;/sequence&gt;
    &lt;proxy name=&quot;FIXProxy&quot; transports=&quot;fix&quot;&gt;
        &lt;target inSequence=&quot;CBR_SEQ&quot; /&gt;
        &lt;parameter name=&quot;transport.fix.AcceptorConfigURL&quot;&gt;
            file:repository/conf/sample/resources/fix/fix-synapse.cfg
        &lt;/parameter&gt;
        &lt;parameter name=&quot;transport.fix.AcceptorMessageStore&quot;&gt;
            file
        &lt;/parameter&gt;
        &lt;parameter name=&quot;transport.fix.InitiatorConfigURL&quot;&gt;
            file:repository/conf/sample/resources/fix/synapse-sender.cfg
        &lt;/parameter&gt;
        &lt;parameter name=&quot;transport.fix.InitiatorMessageStore&quot;&gt;
            file
        &lt;/parameter&gt;
    &lt;/proxy&gt;
&lt;/definitions&gt;</pre>
<p>
<strong>Objective: Demonstrate the capability of CBR FIX messages</strong> </p>
<p>
<strong>Prerequisites:</strong>
<br></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>Add the following lines to banzai.cfg. </p>
<pre xml:space="preserve">DataDictionary=~/etc/spec/FIX40-synapse.xml</pre>
<p>Note: FIX40-synapse.xml can be found at $ESB_HOME/repository/samples/resources/fix. This is a custom FIX data dictionary file that has added tag 150,151 to the execution messages (35=8) of FIX4.0. Make sure the DataDictionary property of the banzai.cfg points to this data dictionary file. </p>
<p>Add the following lines to executor.cfg </p>
<pre xml:space="preserve">[session]
BeginString=FIX.4.1
SocketAcceptPort=19877</pre>
<p>Start Banzai and Executor using the custom config files. </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 ESB_HOME/repository/samples/synapse_sample_262.xml file and make sure that transport.fix.AcceptorConfigURL property points to the fix-synapse.cfg file you created and transport.fix.InitiatorConfigURL points to the synapse-sender.cfg file you created. Once done you can start the Synapse configuration numbered 262: i.e. wso2esb-samples -sn 262. Note that Synapse creates a new FIX session with Banzai at this point. </p>
<p>Send an order request from Banzai to Synapse. e.g. Buy GOOG 1000 @ MKT, Buy MSFT 3000 @ MKT, Buy SUNW 500 @ 100.20 </p>
<p>Synapse will forward the order requests with symbol 'GOOG' to FIX endpoint FIX-4.0 @ localhost:19876.</p>
<p>Synapse will forward the order requests with symbol 'MSFT' to FIX endpoint FIX-4.1 @ localhost:19877.</p>
<p>Synapse will not forward the orders with other symbols to any endpoint. (default case has kept blank in the configuration)</p>

    
<h2>
<a name="Sample263">Sample 263: Transport switching - JMS to http/s using JBoss Messaging(JBM) </a></h2>
<pre xml:space="preserve">&lt;definitions xmlns=&quot;http://ws.apache.org/ns/synapse&quot;&gt;
    &lt;proxy name=&quot;StockQuoteProxy&quot; transports=&quot;jms&quot;&gt;
        &lt;target&gt;
            &lt;inSequence&gt;
                &lt;property action=&quot;set&quot; name=&quot;OUT_ONLY&quot; value=&quot;true&quot;/&gt;
            &lt;/inSequence&gt;
            &lt;endpoint&gt;
                &lt;address uri=&quot;http://localhost:9000/services/SimpleStockQuoteService&quot;/&gt;
            &lt;/endpoint&gt;
            &lt;outSequence&gt;
                &lt;send/&gt;
            &lt;/outSequence&gt;
        &lt;/target&gt;
        &lt;publishWSDL uri=&quot;file:repository/conf/sample/resources/proxy/sample_proxy_1.wsdl&quot;/&gt;
        &lt;parameter name=&quot;transport.jms.ContentType&quot;&gt;
            &lt;rules&gt;
                &lt;jmsProperty&gt;contentType&lt;/jmsProperty&gt;
                &lt;default&gt;application/xml&lt;/default&gt;
            &lt;/rules&gt;
        &lt;/parameter&gt;
    &lt;/proxy&gt;
&lt;/definitions&gt;</pre>
<p>
<strong>Objective: Introduction to switching transports with proxy services. The JMS provider will be <a href="http://jboss.org/jbossmessaging/">JBoss Messaging(JBM).</a></strong> </p>
<p>
<strong>Prerequisites:</strong>
<br></br> Start the Axis2 server and deploy the SimpleStockQuoteService (Refer steps above)
<br></br> <a href="http://jboss.org/jbossmessaging/">Download</a>, install and start JBM server, and configure Synapse to listen on JBM (refer notes below)
<br></br> Start the ESB configuration numbered 263: i.e. wso2esb-samples -sn 263
<br></br> We need to configure the required queues in JBM. Add the following entry to JBM jms configuration inside file-config/stand-alone/non-clustered/jbm-jms.xml.
    </p>
<pre xml:space="preserve">
&lt;queue name=&quot;StockQuoteProxy&quot;&gt;
    &lt;entry name=&quot;StockQuoteProxy&quot;/&gt;
&lt;/queue&gt;
</pre>
<p>Once you started the JBM server with the above changes you'll be able to see the following on STDOUT.</p>
<pre xml:space="preserve">10:18:02,673 INFO [org.jboss.messaging.core.server.impl.MessagingServerImpl]  JBoss Messaging Server version 2.0.0.BETA3 (maggot, 104) started </pre>
<p>You also need to copy the jbm-core-client.jar, jbm-jms-client.jar, jnp-client.jar(these jars are inside $JBOSS_MESSAGING/client folder) and
    jbm-transports.jar, netty.jar(these jars are from $JBOSS_MESSAGING/lib folder) jars from JBM into the $ESB_HOME/repository/components/lib directory. This was tested with JBM 2.0.0.BETA3 </p>

<p>You need to add the following configuration for Axis2 JMS transport listener in axis2.xml found at repository/conf/axis2.xml.</p>
<pre xml:space="preserve">
&lt;transportReceiver name=&quot;jms&quot; class=&quot;org.apache.axis2.transport.jms.JMSListener&quot;&gt;
    &lt;parameter name="default" locked="false"&gt;
        &lt;parameter name=&quot;java.naming.factory.initial&quot;&gt;org.jnp.interfaces.NamingContextFactory&lt;/parameter&gt;
        &lt;parameter name=&quot;java.naming.provider.url&quot;&gt;jnp://localhost:1099&lt;/parameter&gt;
        &lt;parameter name=&quot;java.naming.factory.url.pkgs&quot;&gt;org.jboss.naming:org.jnp.interfaces&lt;/parameter&gt;
        &lt;parameter name=&quot;transport.jms.ConnectionFactoryJNDIName&quot;&gt;ConnectionFactory&lt;/parameter&gt;
    &lt;/parameter&gt;
&lt;/transportReceiver&gt;
</pre>
<p>Once you start ESB configuration 263 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>Before running the JMS client you need to open the build.xml ant script and uncomment the following block under the
jmsclient target.</p>
&lt;!--&lt;sysproperty key="java.naming.provider.url" value="${java.naming.provider.url}"/&gt;
&lt;sysproperty key="java.naming.factory.initial" value="${java.naming.factory.initial}"/&gt;
&lt;sysproperty key="java.naming.factory.url.pkg" value="${java.naming.factory.url.pkg}"/&gt;--&gt;
<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=StockQuoteProxy -Djms_payload=MSFT -Djava.naming.provider.url=jnp://localhost:1099 -Djava.naming.factory.initial=org.jnp.interfaces.NamingContextFactory -Djava.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces</pre>
<p>On the ESB debug(you'll need to enable debug log in ESB) 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, the client sends the request message to the proxy service exposed over JMS in Synsape. Synapse forwards this message to the HTTP EPR of the simple stock quote service hosted on the sample Axis2 server.
Note that the operation is out-only and no response is sent back to the client. The transport.jms.ContentType property
is necessary to allow the JMS transport to determine the content type of incoming messages. With the given configuration
it will first try to read the content type from the 'contentType' message property and fall back to 'application/xml'
(i.e. POX) if this property is not set. Note that the JMS client used in this example doesn't send any content type information.</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 parameter elements on the proxy service definition to specify the destination and connection factory etc. </p>
<p>e.g. </p>
<pre xml:space="preserve">&lt;parameter name=&quot;transport.jms.Destination&quot;&gt;dynamicTopics/something.TestTopic&lt;/parameter&gt;</pre>

<h2>
   <a name="Sample264">Sample 264: Sending Two-Way Messages Using JMS transport</a>
 </h2>
 <pre xml:space="preserve">&lt;definitions xmlns=&quot;http://ws.apache.org/ns/synapse&quot;&gt;
   &lt;proxy name=&quot;StockQuoteProxy&quot; transports=&quot;http&quot;&gt;
       &lt;target&gt;
           &lt;endpoint&gt;
                   &lt;address uri=&quot;jms:/SimpleStockQuoteService?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&amp;
                 java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&amp;java.naming.provider.url=tcp://localhost:61616&amp;transport.jms.DestinationType=queue&quot;/&gt;
           &lt;/endpoint&gt;
           &lt;inSequence&gt;
               &lt;property action=&quot;set&quot; name=&quot;transport.jms.ContentTypeProperty&quot; value=&quot;Content-Type&quot; scope=&quot;axis2&quot;/&gt;
           &lt;/inSequence&gt;
           &lt;outSequence&gt;
               &lt;property action=&quot;remove&quot; name=&quot;TRANSPORT_HEADERS&quot; scope=&quot;axis2&quot;/&gt;
               &lt;send/&gt;
           &lt;/outSequence&gt;
       &lt;target&gt;
       &lt;publishWSDL uri=&quot;file:repository/conf/sample/resources/proxy/sample_proxy_1.wsdl&quot;/&gt;
   &lt;/proxy&gt;
&lt;/definitions&gt;</pre>
 <p>
   <strong>Objective: Demonstrate sending request response scenario with JMS transport</strong>
 </p>
 <p>
   <strong>Prerequisites:</strong>
   <br></br>You need to set up ESB and axis2 server to use the JMS transport. See
   <a href="#Sample251">Sample 251</a> for more details.
 </p>
 <p>
   This sample is similar to the <a href="#Sample251">Sample 251</a>. Only difference is we are expecting a response from the server. JMS transport uses <strong>transport.jms.ContentTypeProperty</strong> to
   determine the content type of the response message. If this property is not set JMS transport treats the incoming message as plain text.
 </p>
 <p>
   In the out path we remove the message context property <strong>TRANSPORT_HEADERS</strong>. If these property is not removed JMS headers will be passed to the client.
 </p>
 <p>Start ESB using sample 264.</p>
 <pre xml:space="preserve">wso2esb-samples -sn 264</pre>
 <p>Start Axis2 server with SimpleStockService deployed</p>
 <p>Invoke the stockquote client using the following command.</p>
 <pre xml:space="preserve">ant stockquote -Daddurl=http://localhost:8280/services/StockQuoteProxy -Dsymbol=MSFT</pre>
 <p>The sample Axis2 server console will print a message indicating that it has received the request: </p>
 <pre xml:space="preserve">Generating quote for : MSFT</pre>
 <p>In the client side it shoud print a message indicating it has received the price.</p>
 <pre xml:space="preserve"> Standard :: Stock price = $154.31851804993238</pre>

<h2><a name="Sample265">Sample 265: Using vfs transport to access a windows share</a>
</h2>
<pre xml:space="preserve">&lt;!-- Using the vfs transport to access a windows share --&gt;
&lt;definitions xmlns="http://ws.apache.org/ns/synapse"&gt;
    &lt;proxy name="StockQuoteProxy" transports="vfs"&gt;
		&lt;parameter name="transport.vfs.FileURI"&gt;smb://host/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;smb://host/test/original&lt;/parameter&gt; &lt;!--CHANGE--&gt;
		&lt;parameter name="transport.vfs.MoveAfterFailure"&gt;smb://host/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;property action="set" name="OUT_ONLY" value="true"/&gt;
                &lt;send&gt;
                    &lt;endpoint&gt;
						&lt;address uri="vfs:smb://host/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 vfs transport to access a windows share</strong>
</p>

<p><strong>Prerequisites:</strong><br />
You will need access a windows shared folder. Just create a folder(called 'test') on a windows machine
and create three sub folders in, out and original inside that folder.Then assign the permission
to the network users to read and write into the root 'test' folder and the folders inside that directory.</p>
<p>
Open ESB_HOME/repository/samples/synapse_sample_265.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 vfs:.
Values you have to change are marked with &lt;!--CHANGE--&gt;.     
</p>

<p>Copy ESB_HOME/repository/samples/resources/vfs/test.xml to the directory given in transport.vfs.FileURI above.</p>

<p>Start the Axis2 server and deploy the SimpleStockQuoteService if not
already done </p>

<p>Enable vfs transport receiver and the vfs transport sender in the ESB axis2.xml. Just uncomment the
    VFSTransportListener and the VFSTransportSender in axis2.xml</p>

<p>Start the Synapse configuration numbered 265: i.e. wso2esb-samples -sn 265
</p>

<p>VFS transport listener will pick the file from in directory and send it to the Axis2 service. The request XML
file will be moved to original directory. The response from the Axis2 server will be saved to out directory. </p>






<h2><a name="Sample266">Sample 266: Switching from TCP to HTTP/S</a>
</h2>
<pre xml:space="preserve">&lt;definitions xmlns=&quot;http://ws.apache.org/ns/synapse&quot;
             xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
             xsi:schemaLocation=&quot;http://ws.apache.org/ns/synapse http://synapse.apache.org/ns/2010/04/configuration/synapse_config.xsd&quot;&gt;

    &lt;proxy name=&quot;StockQuoteProxy&quot; transports=&quot;tcp&quot;&gt;
        &lt;target&gt;
            &lt;endpoint&gt;
                &lt;address uri=&quot;http://localhost:9000/services/SimpleStockQuoteService&quot;/&gt;
            &lt;/endpoint&gt;
            &lt;inSequence&gt;
                &lt;log level=&quot;full&quot;/&gt;
                &lt;property name=&quot;OUT_ONLY&quot; value=&quot;true&quot;/&gt;
            &lt;/inSequence&gt;
        &lt;/target&gt;
    &lt;/proxy&gt;

&lt;/definitions&gt;
</pre>

<p><strong>Objective: Demonstrate receiving SOAP messages over TCP and forwarding them over HTTP</strong>
</p>

<p><strong>Prerequisites:</strong><br />
You need to configure Synpase to use the TCP transport.The sample Axis2 client should also be setup to send TCP requests. Refer Setting Up the TCP Transport section in the sample setup guide for more details.
Start Synpase using sample 266: ie synapse -sample 266<br/>
Start Axis2 server with SimpleStockService deployed
</p>
<p>
 This sample is similar to Sample 250 . Only difference is instead of the JMS transport we will be using the TCP transport to receive messages. TCP is not an application layer protocol. Hence there are no application level headers available in the requests. Synapse has to simply read the XML content coming through the socket and dispatch it to the right proxy service based on the information available in the message payload itself. The TCP transport is capable of dispatching requests based on addressing headers or the first element in the SOAP body. In this sample, we will get the sample client to send WS-Addressing headers in the request. Therefore the dispatching will take place based on the addressing header values.

Invoke the stockquote client using the following command. Note the TCP URL in the command.
</p>
<pre xml:space="preserve">ant stockquote -Daddurl=tcp://localhost:6060/services/StockQuoteProxy -Dmode=placeorder</pre>
<p>
    The TCP transport will receive the message and hand it over to the mediation engine. Synapse will dispatch the request to the StockQuoteProxy service based on the addressing header values.
    <br/>The sample Axis2 server console will print a message indicating that it has received the request:
</p>
<pre xml:space="preserve">Thu May 20 12:25:01 IST 2010 samples.services.SimpleStockQuoteService  :: Accepted order #1 for : 17621 stocks of IBM at $ 73.48068475255796</pre>


<h2><a name="Sample267">Sample 267: Switching from UDP to HTTP/S</a>
</h2>
<pre xml:space="preserve">&lt;definitions xmlns=&quot;http://ws.apache.org/ns/synapse&quot;
             xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
             xsi:schemaLocation=&quot;http://ws.apache.org/ns/synapse http://synapse.apache.org/ns/2010/04/configuration/synapse_config.xsd&quot;&gt;

    &lt;proxy name=&quot;StockQuoteProxy&quot; transports=&quot;udp&quot;&gt;
        &lt;target&gt;
            &lt;endpoint&gt;
                &lt;address uri=&quot;http://localhost:9000/services/SimpleStockQuoteService&quot;/&gt;
            &lt;/endpoint&gt;
            &lt;inSequence&gt;
                &lt;log level=&quot;full&quot;/&gt;
                &lt;property name=&quot;OUT_ONLY&quot; value=&quot;true&quot;/&gt;
            &lt;/inSequence&gt;
        &lt;/target&gt;
        &lt;parameter name=&quot;transport.udp.port&quot;&gt;9999&lt;/parameter&gt;
        &lt;parameter name=&quot;transport.udp.contentType&quot;&gt;text/xml&lt;/parameter&gt;
        &lt;publishWSDL uri=&quot;file:repository/conf/sample/resources/proxy/sample_proxy_1.wsdl&quot;/&gt;
    &lt;/proxy&gt;
&lt;/definitions&gt;
</pre>

<p><strong>Objective: Demonstrate receiving SOAP messages over UDP and forwarding them over HTTP</strong>
</p>

<p><strong>Prerequisites:</strong><br />
You need to configure Synpase to use the TCP transport.The sample Axis2 client should also be setup to send TCP requests. Refer Setting Up the TCP Transport section in the sample setup guide for more details.
Start Synpase using sample 267: ie synapse -sample 267<br/>
Start Axis2 server with SimpleStockService deployed
</p>
<p>
 This sample is similar to Sample 266. Only difference is instead of the TCP transport we will be using the UDP transport to receive messages.

Invoke the stockquote client using the following command. Note the TCP URL in the command.
</p>
<pre xml:space="preserve">ant stockquote -Daddurl=udp://localhost:9999?contentType=text/xml -Dmode=placeorder</pre>
<p>
    Since we have configured the content type as text/xml for the proxy service, incoming messages will be processed as SOAP 1.1 messages.
    <br/>The sample Axis2 server console will print a message indicating that it has received the request:
</p>
<pre xml:space="preserve">Thu May 20 12:25:01 IST 2010 samples.services.SimpleStockQuoteService  :: Accepted order #1 for : 17621 stocks of IBM at $ 73.48068475255796
</pre>


<h2><a name="Sample268">Sample 268: Proxy services with the Local transport</a>
</h2>
<pre xml:space="preserve">&lt;definitions xmlns="http://ws.apache.org/ns/synapse"&gt;
    &lt;proxy xmlns="http://ws.apache.org/ns/synapse" name="LocalTransportProxy"
           transports="https http" startOnLoad="true" trace="disable"&gt;
        &lt;target&gt;
            &lt;endpoint name="ep1"&gt;
                &lt;address uri="local://localhost/services/SecondProxy"/&gt;
            &lt;/endpoint&gt;
            &lt;inSequence&gt;
                &lt;log level="full"/&gt;
                &lt;log level="custom"&gt;
                    &lt;property name="LocalTransportProxy" value="In sequence of LocalTransportProxy invoked!"/&gt;
                &lt;/log&gt;
            &lt;/inSequence&gt;
            &lt;outSequence&gt;
                &lt;log level="custom"&gt;
                    &lt;property name="LocalTransportProxy" value="Out sequence of LocalTransportProxy invoked!"/&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;proxy xmlns="http://ws.apache.org/ns/synapse" name="SecondProxy"
           transports="https http" startOnLoad="true" trace="disable"&gt;
        &lt;target&gt;
            &lt;endpoint name="ep2"&gt;
                &lt;address uri="local://localhost/services/StockQuoteProxy"/&gt;
            &lt;/endpoint&gt;
            &lt;inSequence&gt;
                &lt;log level="full"/&gt;
                &lt;log level="custom"&gt;
                    &lt;property name="SecondProxy" value="In sequence of Second proxy invoked!"/&gt;
                &lt;/log&gt;
            &lt;/inSequence&gt;
            &lt;outSequence&gt;
                &lt;log level="custom"&gt;
                    &lt;property name="SecondProxy" value="Out sequence of Second proxy invoked!"/&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;proxy xmlns="http://ws.apache.org/ns/synapse" name="StockQuoteProxy"
           startOnLoad="true"&gt;
        &lt;target&gt;
            &lt;endpoint name="ep3"&gt;
                &lt;address uri="http://localhost:9000/services/SimpleStockQuoteService"/&gt;
            &lt;/endpoint&gt;
            &lt;outSequence&gt;
                &lt;log level="custom"&gt;
                    &lt;property name="StockQuoteProxy"
                              value="Out sequence of StockQuote proxy invoked!"/&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: Proxy services with the Local transport</strong>
</p>

<p>This sample contains three proxy services. The stockquote client invokes the LocalTransportProxy.
    Then the message will be sent to the SecondProxy and then it will be sent to the StockQuoteProxy.
    The StockQuoteProxy will invoke the backend service and return the response to the client.
    In this sample, the communication between proxy services are done through the Local transport.
    Since Local transport calls are in-JVM calls, it will reduce the time taken for the communication
    between proxy services.</p>

<p><strong>Prerequisites:</strong><br />
Start the Synapse configuration numbered 268: i.e. wso2esb-samples -sn 268<br />
Start the Axis2 server and deploy the SimpleStockQuoteService if not already done</p>

<p>Execute the stock quote client by requesting for a stock quote on the
proxy service as follows: </p>
<pre xml:space="preserve">ant stockquote -Daddurl=http://localhost:8280/services/LocalTransportProxy</pre>

</body>
</html>
