The following sections walk you through a sample scenario that demonstrates how to send a message from a WebSocket client to an HTTP endpoint via WSO2 ESB:
If you need to send a message from a WebSocket client to an HTTP endpoint via WSO2 ESB, you need to establish a persistent Websocket connection from the WebSocket client to WSO2 ESB.
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. Finally you need to configure WSO2 ESB's WebSocket inbound endpoint to use the created sequences and listen on port 9091.
- Start the WSO2 ESB server. For information on how to start the ESB server. see Running the Product.
- Download the sample netty artifacts folder.
Configuring the sample scenario
Create the sequence for client to back-end mediation as follows:
This sequence calls an HTTP endpoint.
Create the sequence for back-end to client mediation as follows:
Configure WSO2 ESB's WebSocket inbound endpoint as follows to use the created sequences and listen on port 9091:
Executing the sample scenario
Execute the following command to start the WebSocket client:
Analyzing the output
If you analyze the log, you will see that a connection from the WebSocket client to WSO2 ESB is established. You will also see that the sequences are executed by the WebSocket inbound endpoint.