我有2个API,如下所示,我正在尝试使用SEND mediator从我的API1调用API2,但没有返回任何响应并且在日志中打印错误:
API1 -
URL https://localhost:8243/sendtest/1.0/{num}
在流程序列中
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="send_mediator_test_in" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<property expression="get-property('uri.var.num')" name="uri.var.num" scope="default" type="STRING"/>
<send>
<endpoint>
<http method="get" uri-template="https://localhost:8243/protest/1.0/{uri.var.num}"/>
</endpoint>
</send>
</sequence>
API2 - (原型)
URL https://localhost:8243/protest/1.0/{num}
内联脚本
mc.setProperty('CONTENT_TYPE', 'application/json');
var Num = mc.getProperty('uri.var.num');
mc.setPayloadJSON({ "NumberReturn": Num });
响应
{
"NumberReturn": "100"
}
在以下环境中调用API1工作正常,并返回正确的响应。
OS: Windows 7
Java: 1.7.0_45
WSO2 AM: 2.0.0
但是在下面的环境中获得错误
OS: Red Hat Enterprise Linux Server release 6.8 (Santiago)
Java: 1.7.0_101
WSO2 AM: 2.0.0
调用API1时出错
TID: [-1] [] [2017-02-03 06:34:23,265] DEBUG {org.apache.synapse.transport.http.wire} - HTTPS-Sender I/O dispatcher-2 >> "[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2017-02-03 06:34:23,265] DEBUG {org.apache.synapse.transport.http.wire} - HTTPS-Sender I/O dispatcher-2 >> "a4[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2017-02-03 06:34:23,265] DEBUG {org.apache.synapse.transport.http.wire} - HTTPS-Sender I/O dispatcher-2 >> "0[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2017-02-03 06:34:23,265] DEBUG {org.apache.synapse.transport.http.wire} - HTTPS-Sender I/O dispatcher-2 >> "[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1234] [] [2017-02-03 06:34:23,278] ERROR {org.apache.axis2.transport.base.threads.NativeWorkerPool} - Uncaught exception {org.apache.axis2.transport.base.threads.NativeWorkerPool}
java.lang.NumberFormatException: null
at java.lang.Long.parseLong(Long.java:404)
at java.lang.Long.parseLong(Long.java:483)
at org.wso2.carbon.apimgt.gateway.handlers.common.APIMgtLatencyStatsHandler.handleResponse(APIMgtLatencyStatsHandler.java:43)
at org.apache.synapse.rest.API.process(API.java:323)
at org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:90)
at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:56)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:300)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:554)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:188)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:255)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
TID: [-1234] [] [2017-02-03 06:34:30,750] INFO {org.wso2.andes.server.handler.ChannelCloseHandler} - Received channel close for id 1 citing class 0 and method 0 {org.wso2.andes.server.handler.ChannelCloseHandler}
TID: [-1234] [] [2017-02-03 06:34:30,750] INFO {org.wso2.andes.server.AMQChannel} - No consumers to unsubscribe on channel [/127.0.0.1:53226(admin):1] {org.wso2.andes.server.AMQChannel}
TID: [-1234] [] [2017-02-03 06:34:30,750] INFO {org.wso2.andes.kernel.FlowControlManager} - Channel removed (ID: 127.0.0.1:53226) {org.wso2.andes.kernel.FlowControlManager}
TID: [-1234] [] [2017-02-03 06:34:30,752] INFO {org.wso2.andes.server.handler.ConnectionCloseMethodHandler} - ConnectionClose received with reply code/reply text 200/JMS client is closing the connection. for /127.0.0.1:53226(admin) {org.wso2.andes.server.handler.ConnectionCloseMethodHandler}
请告知错误。
答案 0 :(得分:0)
这是APIM 2.0.0中的a known issue,并在2.1.0中修复
当您启用了分析时,原型API或其他没有APIAuthenticationHandler
的API会发生这种情况。也许您只在Windows安装程序中启用了分析。
作为解决方法,请输入
<property expression="get-property('SYSTEM_TIME')" name="api.ut.backendRequestTime"/>
在您的原型API的inSequence
内,就像这样。
<inSequence>
<script language="js">your-js-goes-here</script>
<property expression="get-property('SYSTEM_TIME')" name="api.ut.backendRequestTime"/>
...
...
<inSequence>