Switching from TCP to HTTP/S

This example demonstrates how WSO2 Micro Integrator receives SOAP messages over TCP and forwards them over HTTP.

TCP is not an application layer protocol. Hence there are no application-level headers available in the requests. The Micro Integrator 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. 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.

Synapse configuration

Following are the integration artifacts (proxy service) that we can used to implement this scenario. See the instructions on how to build and run this example.

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
         <log level="full"/>
         <property name="OUT_ONLY" value="true"/>
               <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>

Build and Run

Create the artifacts:

  1. Set up WSO2 Integration Studio.
  2. Create an integration project with an ESB Configs module and an Composite Exporter.
  3. Create the proxy service with the configurations given above.
  4. Deploy the artifacts in your Micro Integrator.

Set up the back-end service.

  • Download the back-end service
  • Extract the downloaded zip file.
  • Open a terminal, navigate to the axis2Server/bin/ directory inside the extracted folder.
  • Execute the following command to start the axis2server with the SimpleStockQuote back-end service:

    sh axis2server.sh

Enable the TCP transport and start the Micro-Integrator.

Send the following message via TCP to the TCP listener port.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
        <m0:placeOrder xmlns:m0="http://services.samples">
In Linux, we can save the above request in a request.xml file and use netcat to send the TCP request.
netcat localhost 6060 < request.xml

You will see the following response in the back-end service's console:

INFO  [wso2/stockquote_service] - Stock quote service invoked.
INFO  [wso2/stockquote_service] - Generating placeOrder response
INFO  [wso2/stockquote_service] - The order was placed.