## Apache Synapse

## Sample 266: Switching from UDP to HTTP/S

<definitions xmlns="http://ws.apache.org/ns/synapse"> <proxy name="StockQuoteProxy" transports="udp"> <target> <endpoint> <address uri="http://localhost:9000/services/SimpleStockQuoteService"/> </endpoint> <inSequence> <log level="full"/> <property name="OUT_ONLY" value="true"/> </inSequence> </target> <parameter name="transport.udp.port">9999</parameter> <parameter name="transport.udp.contentType">text/xml</parameter> <publishWSDL uri="file:repository/conf/sample/resources/proxy/sample_proxy_1.wsdl"/> </proxy> </definitions>

### Objective

Showcase the ability of Synapse to receive and process raw UDP messages

### Pre-requisites

- Deploy the SimpleStockQuoteService in the sample Axis2 server and start Axis2
- Enable the UDP transport receiver for Synapse (refer UDP transport setup guide).
- Start Synapse using the configuration numbered 266 (repository/conf/sample/synapse_sample_266.xml)
  Unix/Linux: sh synapse.sh -sample 266
  Windows: synapse.bat -sample 266
- Enable the UDP transport sender for the sample Axis2 client (refer UDP transport setup guide for details).

### Executing the Client

This sample is similar to Sample 265. 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 UDP URL in the command.

ant stockquote -Daddurl=udp://localhost:9999?contentType=text/xml -Dmode=placeorder

Since we have configured the content type as text/xml for the proxy service, incoming messages will be processed as SOAP 1.1 messages.

When the proxy service forwards the message to the sample Axis2 server over HTTP, sample server will print the following entry to confirm that the request has been received.

Thu May 20 12:25:01 IST 2010 samples.services.SimpleStockQuoteService :: Accepted order #1 for : 17621 stocks of IBM at $ 73.48068475255796

Back to Catalog