在 wso2 ESB 中,我可以将数据发送到 WebSocket,但我无法接收数据。我用 wso2 esb 的 rest api 试过这个。
<?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>
外序:
<?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>
如果我在 websocket 服务器中使用 esb 文档(链接)中提到的内容类型的代理服务,我会遇到异常
<?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>
<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>
那么如何从 websocket 发送和接收数据