【问题标题】:WSO2 EI Sequence failing when calling a Data Service调用数据服务时 WSO2 EI 序列失败
【发布时间】:2018-12-05 12:28:57
【问题描述】:

运行 WSO2 EI 6.2.0

我的顺序很简单:

  1. 从初始请求接收 1 个参数 (mac)
  2. 调用 DS 以提取第二个参数 (time_hour)
  3. 同时使用参数 (mac) 和 (time_hour) 调用 DS

手动调用两个 DS 时,效果很好。

通过 ESB 调用第二个 DS 时,我收到一个奇怪的错误。

顺序:

<?xml version="1.0" encoding="UTF-8"?>
<sequence name="udp_nxt_gethfcprofilecapacity" trace="enable" xmlns="http://ws.apache.org/ns/synapse">
    <property expression="$url:mac" name="uri.var.mac" scope="default"
        type="STRING" xmlns:ns="http://org.apache.synapse/xsd"/>
    <property name="mac" scope="default" type="STRING" value="get-property('uri.var.mac')"/>
    <call>
        <endpoint>
            <http method="GET" uri-template="http://rhtdflow001.corporativo.pt:8290/services/udp_nxt/gethfcprofilecapacity_hour?mac={uri.var.mac}"/>
        </endpoint>
    </call>
    <enrich>
        <source clone="true" type="body"/>
        <target action="replace" property="payload" type="property"/>
    </enrich>
    <log level="custom">
        <property expression="get-property('payload')" name="bbb" xmlns:ns="http://org.apache.synapse/xsd"/>
    </log>
    <property expression="$ctx:payload//ns2:hour" name="time_hour"
        scope="default" type="STRING"
        xmlns:ns="http://org.apache.synapse/xsd" xmlns:ns2="http://ws.wso2.org/dataservice"/>
    <header action="remove" name="Content-Type" scope="transport"/>
    <log level="custom">
        <property expression="get-property('uri.var.mac')" name="mac" xmlns:ns="http://org.apache.synapse/xsd"/>
    </log>
    <log level="custom">
        <property expression="get-property('time_hour')"
            name="time_hour" xmlns:ns="http://org.apache.synapse/xsd"/>
    </log>
    <call>
        <endpoint>
            <http method="GET" uri-template="http://rhtdflow001.corporativo.pt:8290/services/udp_nxt/gethfcprofilecapacity?mac={uri.var.mac}&amp;hour={time_hour}"/>
        </endpoint>
    </call>
    <log level="custom">
        <property name="xxx" value="FIM"/>
    </log>
    <respond/>
</sequence>

我尝试在调用 DS 之前记录参数并正确打印,但是当我在 DS 调用中使用它时,hour={time_hour} 参数为空。

输出和错误:

(...)
TID: [-1234] [] [2018-12-05 12:24:02,562]  INFO {org.apache.synapse.mediators.builtin.LogMediator} -  mac = 0003081B9E70 {org.apache.synapse.mediators.builtin.LogMediator}
TID: [-1234] [] [2018-12-05 12:24:02,562]  INFO {org.apache.synapse.mediators.builtin.LogMediator} -  time_hour = 2018-12-03T11:00:00.000+00:00 {org.apache.synapse.mediators.builtin.LogMediator}
TID: [-1234] [] [2018-12-05 12:24:02,569] ERROR {org.wso2.carbon.dataservices.core.DBInOutMessageReceiver} -  Error in in-out message receiver {org.wso2.carbon.dataservices.core.DBInOutMessageReceiver}
DS Code: DATABASE_ERROR
Nested Exception:-
javax.xml.stream.XMLStreamException: DS Fault Message: Error in 'SQLQuery.processPreNormalQuery': DS Fault Message: Error processing parameter - hour, Error - DS Fault Message: Empty string or null value was found as timeStamp.
DS Code: UNKNOWN_ERROR

DS Code: UNKNOWN_ERROR
Nested Exception:-
DS Fault Message: Empty string or null value was found as timeStamp.
DS Code: UNKNOWN_ERROR


DS Code: DATABASE_ERROR
Source Data Service:-
Name: udp_nxt
Location: /udp_nxt.dbs
Description: UDP Call to NXT
Default Namespace: http://ws.wso2.org/dataservice
Current Request Name: _getgethfcprofilecapacity
Current Params: {hour=, mac=0003081B9E70}
Nested Exception:-
DS Fault Message: Error processing parameter - hour, Error - DS Fault Message: Empty string or null value was found as timeStamp.
DS Code: UNKNOWN_ERROR
(...)

有谁知道如何正确地将 time_hour 参数引用到 ESB 序列中的数据服务?

解释为什么变量 time_hour 没有被评估

来自WSO2 Documentation

URI 模板允许 RESTful URI 包含可以被 在中介运行时使用其名称的属性值填充 有 "uri.var" 前缀

根据 Jan 的回复得出的最终序列:

<?xml version="1.0" encoding="UTF-8"?>
<sequence name="udp_nxt_gethfcprofilecapacity" trace="enable" xmlns="http://ws.apache.org/ns/synapse">
    <property expression="$url:mac" name="uri.var.mac" scope="default"
        type="STRING" xmlns:ns="http://org.apache.synapse/xsd"/>
    <call>
        <endpoint>
            <http method="GET" uri-template="http://rhtdflow001.corporativo.pt:8290/services/udp_nxt/gethfcprofilecapacity_hour?mac={uri.var.mac}"/>
        </endpoint>
    </call>
    <enrich>
        <source clone="true" type="body"/>
        <target action="replace" property="payload" type="property"/>
    </enrich>
    <property expression="$ctx:payload//ns2:hour"
        name="uri.var.time_hour" scope="default" type="STRING"
        xmlns:ns="http://org.apache.synapse/xsd" xmlns:ns2="http://ws.wso2.org/dataservice"/>
    <header action="remove" name="Content-Type" scope="transport"/>
    <call>
        <endpoint>
            <http method="GET" uri-template="http://rhtdflow001.corporativo.pt:8290/services/udp_nxt/gethfcprofilecapacity?mac={uri.var.mac}&amp;hour={uri.var.time_hour}"/>
            <property name="time_h" value="{time_hour}"/>
        </endpoint>
    </call>
    <respond/>
</sequence>

【问题讨论】:

    标签: wso2 wso2esb wso2dss wso2ei


    【解决方案1】:

    它需要 'uri.var' 作为变量名才能用作 uri-template 变量。

    所以创建一个具有当前时间的属性。 (顺便说一句,我很惊讶 'time_hour' 对你有用,在我的情况下,我使用的是 SYSTEM_DATE,time_hour 恢复为 'null')

    <property expression="get-property('SYSTEM_DATE')" name="uri.var.time_hour"/>
    

    并在您的端点中使用它。

    【讨论】:

    • 我在 5 分钟前得出了 uri.var 的结论 :) 因为我认为 MAC 工作但 time_hour 没有工作很奇怪。 time_hour 来自先前调用的基于丰富的属性
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多