如何在wso2 esb代理服务中捕获tcp客户端请求消息

普里扬莎

我是 Wso2 esb 的新手。现在我正在使用 tcp 协议和代理服务。我有一些问题。我通过 tcp 协议向代理服务发送一些消息。我需要将此消息发送给代理服务中的属性中介。但是我的方法没有在财产调解人中抓住那个价值。
这是我的代理服务

<?xml version="1.0" encoding="UTF-8"?>
<proxy name="TCPProxyService" startOnLoad="true" transports="tcp" xmlns="http://ws.apache.org/ns/synapse">
    <target>
        <inSequence>
            <property description="" expression="get-property('message')" name="MessageValue" scope="default" type="STRING"/>
            <log description="" level="custom">
                <property name="property_name" value="============================="/>
                <property expression="get-property('MessageValue')" name="inputValue"/>
            </log>
            <sequence key="in-sequence"/>
            <log/>
            <respond/>
        </inSequence>
        <outSequence/>
        <faultSequence/>
    </target>
    <parameter name="transport.tcp.responseClient">true</parameter>
    <parameter name="transport.tcp.inputType">string</parameter>
    <parameter name="transport.tcp.recordDelimiter">|</parameter>
    <parameter name="transport.tcp.contentType">text/plain</parameter>
    <parameter name="transport.tcp.port">6789</parameter>
    <parameter name="transport.tcp.recordDelimiterType">character</parameter>
</proxy>

这是我的 Java 客户端,用于发送 tcp 请求

import java.io.*;
import java.net.*;

class TCPClient {
    public static void main(String argv[]) throws Exception {
        String delimiter = "|";
        int modifiedSentence;
        Socket clientSocket = new Socket("localhost", 6789);
        DataOutputStream outToServer = new 
           DataOutputStream(clientSocket.getOutputStream());
        BufferedReader inFromServer = new BufferedReader(new 
        InputStreamReader(clientSocket.getInputStream()));
        String message = "Pietoo,Klaas,also" + delimiter;
        outToServer.writeBytes(message);
        outToServer.flush();
        while ((modifiedSentence = inFromServer.read()) > -1){
           System.out.print((char)modifiedSentence);
        }
        clientSocket.close();
        }
}

我尝试使用 get-property 表达式添加以下属性介体。这有什么问题。

property description="" expression="get-property('message')" name="MessageValue" scope="default" type="STRING"/>

让·米歇尔

<log level="full"/>在您的代理定义中尝试 a ,使用您的 Java 客户端向它发送一条消息,然后查看 wso2-esb-service.log :您应该看到这样的soap 消息

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Body>
        <text xmlns="http://ws.apache.org/commons/ns/payload">your|data</text>
    </soapenv:Body>
</soapenv:Envelope>

您可以使用以下方法获取文本值:

<property xmlns:tp="http://ws.apache.org/commons/ns/payload" name="MessageValue" expression="$body/tp:text"/>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

WSO2 如何在不调用任何 WSO2 api 或客户端应用程序代理的情况下从 ActiveMQ 获取消息?

如何在wso2 ESB中添加wso2 Application Server的功能?

如何使用WSO2 ESB调解器向客户端显示消息

如何在WSO2 ESB中集成RESTful服务

如何在WSO2 ESB 4.9.0中启用代理服务安全性

如何在 WSO2 ESB 中获取响应正文

如何在cxf中使用wso2 esb?

如何在WSO2 ESB中进行HTTPS调用

如何在WSO2 ESB上重新部署崩溃的代理服务

如何在WSO2 API管理器中注册REST客户端

如何在WSO2 EMM Carbon服务器中运行WSO2 EMM Jaggery Web App?

WSO2 ESB:代理服务-如何使用Faultsequence

如何在WSO2 ESB中的每个服务日志中选择主机名

如何在WSO2 ESB中拦截500个内部服务器错误

WSO2 EI:如何在使用 vfs 选择 csv 文件时处理 WSO2 中的瑞典字符

wso2esb 5.0-通过WebSocket将消息从WSO2发送到客户端

如何在 WSO2 ESB 中检索和使用属性的设置值?

如何在WSO2 ESB中为发送中介器的属性分配url?

如何在WSO2 ESB中实现虚拟REST API

如何在WSO2 ESB中运行自定义应用程序

如何在WSO2 ESB 4.8或更高版本中读取查询参数?

如何在WSO2 ESB中动态更改vfs FileURI?

如何在wso2 esb中为不同的端点设置不同的授权标头

如何在WSO2 ESB中实现动态集成模式

如何在 WSO2 EI/ESB 中实现顺序后端调用?

如何在 WSO2 ESB 中获取格式化日期作为属性

如何在WSO2 VFS代理中禁用“ transport.vfs.ActionAfterProcess”

如何为wso2安全令牌服务创建.NET客户端

WSO2 ESB-修改代理服务中的输出消息内容