在wso2 esb中,我可以发送,但无法收听websocket

时间:2018-09-01 10:34:42

标签: wso2 wso2esb ei

在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>

使用上述API,我可以将数据发送到服务器,如下图所示。 enter image description here

邮递员发出的Http请求。 enter image description here

但是如控制台的下图所示,由于没有主体,我得到的响应为空。 enter image description here

如果我使用websocket服务器中esb文档(link)中提到的具有内容类型的代理服务,我会得到异常

<?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配置为:

<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发送和接收数据

0 个答案:

没有答案