WSO2 DBLookup 未返回 JSON 结果

WSO2 DBLookup not returning a JSON result

我是 WSO2 世界的新手,我有一个 DBLookup 配置如下:

    <resource methods="GET" uri-template="/consultadb">
        <inSequence>
            <log/>
            <dblookup>
                <connection>
                    <pool>
                        <driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver>
                        <url>jdbc:sqlserver://****.CORP:1433;databaseName=*****;</url>
                        <user>user</user>
                        <password>user</password>
                    </pool>
                </connection>
                <statement>
                    <sql><![CDATA[SELECT NAME FROM CLIENT]]></sql>
                    <result column="NAME" name="getName"/>
                </statement>
            </dblookup>
            <property name="messageType" scope="axis2" type="STRING" value="application/json"/>
            <log/>
            <respond/>
        </inSequence>
        <outSequence/>
        <faultSequence/>
    </resource>

但是当我 运行 时,我没有收到邮递员的任何回复...我做错了什么?我已经设置了一个 Respond Meditor

没有错误,响应为 200 OK,日志中的最终消息为:

[2021-06-25 11:39:31,542] INFO {LogMediator} - {api:salesforceinit} To: /salesforceinit/consultadb, MessageID: urn:uuid:d9ba7fc8-733e-413a-a47b-f7ebac8ae4e3, correlation_id: d9ba7fc8-733e-413a-a47b-f7ebac8ae4e3, Direction: request

我认为那是因为您的查询 returns 来自 DB 的元素不止一个。而 DBLookupMediator 只能处理一行。 mediator documentation:

中提到了这一点

The DBLookup mediator can set a property from one row in a result set. It cannot return multiple rows. If you need to get multiple records, or if you have a table with multiple parameters (such as URLs), you can use the WSO2 Data Services Server to create a data service and invoke that service from the ESB using the Callout mediator instead.

如果你想从数据库中读取数据,你应该使用数据服务。如何创建,你可以在文档中找到:Creating a Data Service