This documentation is for WSO2 Enterprise Service Bus version 5.0.0. For the latest ESB, view the latest WSO2 Enterprise Integrator documentation.

All docs This doc
Skip to end of metadata
Go to start of metadata

The following sections walk you through a sample scenario that demonstrates how to send a message from a HTTP client to a WebSocket endpoint via WSO2 ESB:


If you need to send a message from a HTTP client to a WebSocket endpoint via WSO2 ESB, you need to establish a persistent Websocket connection from WSO2 ESB to the WebSocket back-end.

To demonstrate this scenario, you need to create two dispatching sequences. One for the client to back-end mediation, and another for the back-end to client mediation. Then you need to create a proxy service to call the created sequences.


  • Start WSO2 ESB. For information on how to start the ESB server. see Running the Product.
  • Download the sample netty artifacts folder.
  • Execute the following command to start the WebSocket server on port 8082:

    java -cp netty-example-4.0.30.Final.jar:lib/*:. io.netty.example.http.websocketx.server.WebSocketServer

Configuring the sample scenario

  • Create the sequence for client to back-end mediation as follows:

    <?xml version="1.0" encoding="UTF-8"?>
    <sequence name="dispatchSeq" xmlns="">
            <property name="OUT_ONLY" value="true"/>
            <property name="FORCE_SC_ACCEPTED" scope="axis2" type="STRING" value="true"/>
            <property name="websocket.accept.contenType" scope="axis2" value="application/json"/>
                    <address uri="ws://localhost:8082/websocket"/>
  • Create the sequence for the back-end to client mediation as follows:

    <sequence name="outDispatchSeq" xmlns="">
      <log level="full"/>
  • Create a proxy service as follows to call the above sequences:

    <?xml version="1.0" encoding="UTF-8"?>
    <proxy xmlns=""
       <target inSequence="dispatchSeq" faultSequence="outDispatchSeq"/>

Executing the sample scenario

Execute the following command to invoke the proxy service:

curl -v --request POST -d "<?xml version=\"1.0\" encoding=\"UTF-8\"?><soapenv:Envelope xmlns:soapenv=\"\"><soapenv:Body><test>Value</test></soapenv:Body></soapenv:Envelope>" -H Content-Type:"text/xml" http://localhost:8280/services/websocketProxy1

Analyzing the output

If you analyze the log, you will see that a HTTP request is sent to the WebSocket server, and that the WebSocket server injects the response to the out sequence.

  • No labels