1

In wso2 ESB, I am able to send data to WebSocket but I am not able to receive data. I tried this with rest api of wso2 esb.

<?xml version="1.0" encoding="UTF-8"?>
<api context="/test" name="test" xmlns="http://ws.apache.org/ns/synapse">
    <resource methods="POST">
        <inSequence>
            <property name="OUT_ONLY" scope="default" type="STRING" value="true"/>
            <property name="FORCE_SC_ACCEPTED" scope="axis2" type="STRING" value="true"/>
            <log level="full">
                <property name="message" value="********************************************input**********************"/>
            </log>
            <send>
                <endpoint>
                    <http method="post" uri-template="ws://localhost:8080/websocket/server"/>
                </endpoint>
            </send>
        </inSequence>
        <outSequence>

            <send/>
        </outSequence>
        <faultSequence/>
    </resource>
</api>

outsequence:

<?xml version="1.0" encoding="UTF-8"?>
<sequence name="outflowDispatchSeq" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
    <log level="full">
        <property name="message" value="************************************************"/>
    </log>
</sequence>

with the above API, I am able to send data to the server as shown in below image. enter image description here

Http request from postman. enter image description here

But as shown in below image of the console, the response which i am getting is empty as no body present. enter image description here

If I use proxy service with content-type mentioned as in esb documentation(link) in websocket server i am getting exception

<?xml version="1.0" encoding="UTF-8"?>
<sequence name="dispatchSeq" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
 <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="text/plain"/>
        <send>
            <endpoint>
                <address uri="ws://localhost:8080/websocket/server"/>
            </endpoint>
        </send>
</sequence>

enter image description here axis2.xml websocket configuration is:

<transportSender name="ws" class="org.wso2.carbon.websocket.transport.WebsocketTransportSender">
        <parameter name="ws.outflow.dispatch.sequence" locked="false">outflowDispatchSeq</parameter>
        <parameter name="ws.outflow.dispatch.fault.sequence" locked="false">outflowFaultSeq</parameter>       
    </transportSender>

So how to send and receive the data from websocket

Community
  • 1
  • 1
ashok
  • 1,078
  • 3
  • 20
  • 63

0 Answers0