WSO2 API管理器版本:2.5.0
我有一个Out Mediator应该做的很简单:
uri.var.stackstormexecId
的属性(有效)Accept: */*
标题(有效)第4步只是为了阻止序列,我不在乎它的响应。完成某些向南的工作后,该特定端点将释放HTTP连接,从而允许5)中的下一个Call检索有意义的信息。
问题在于,通过设置Accept: */*
,我希望API Gw将处理4)调用的非结构化响应,其Content-Type
为text/event-stream
。由于没有与此特定Content-Type关联的axis2消息生成器,因此在该调用上引发了XML解析器异常。
问题:有人知道应该使用哪个消息生成器类并在axis2.xml中定义来克服此问题吗?
我不确定它试图使用什么,但是异常来自getSOAPBuilder
,当然不是这样。它期望一个“ <”但得到一个“ e”(这是步骤4的非结构化响应的第一个字符):
TID: [-1234] [] [2018-12-18 11:22:08,656] INFO {org.apache.axis2.builder.BuilderUtil} - OMException in getSOAPBuilder {org.apache.axis2.builder.BuilderUtil}
org.apache.axiom.om.OMException: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character 'e' (code 101) in prolog; expected '<'
at [row,col {unknown-source}]: [1,1]
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:296)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.getSOAPEnvelope(StAXSOAPModelBuilder.java:204)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.<init>(StAXSOAPModelBuilder.java:154)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.<init>(StAXSOAPModelBuilder.java:140)
at org.apache.axis2.builder.BuilderUtil.getSOAPBuilder(BuilderUtil.java:658)
at org.apache.axis2.transport.TransportUtils.createDocumentElement(TransportUtils.java:206)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:146)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:109)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:68)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:351)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:456)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:227)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:149)
at org.apache.synapse.message.senders.blocking.BlockingMsgSender.sendReceive(BlockingMsgSender.java:490)
at org.apache.synapse.message.senders.blocking.BlockingMsgSender.send(BlockingMsgSender.java:382)
at org.apache.synapse.core.axis2.Axis2FlexibleMEPClient.send(Axis2FlexibleMEPClient.java:88)
at org.apache.synapse.core.axis2.Axis2Sender.sendOn(Axis2Sender.java:85)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:511)
at org.apache.synapse.endpoints.AbstractEndpoint.send(AbstractEndpoint.java:384)
at org.apache.synapse.endpoints.HTTPEndpoint.send(HTTPEndpoint.java:85)
at org.apache.synapse.mediators.builtin.CallMediator.handleBlockingCall(CallMediator.java:164)
at org.apache.synapse.mediators.builtin.CallMediator.mediate(CallMediator.java:119)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:108)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:70)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158)
at org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler.mediate(APIManagerExtensionHandler.java:66)
at org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler.handleResponse(APIManagerExtensionHandler.java:87)
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:303)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:570)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:193)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:263)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character 'e' (code 101) in prolog; expected '<'
at [row,col {unknown-source}]: [1,1]
at com.ctc.wstx.sr.StreamScanner.throwUnexpectedChar(StreamScanner.java:639)
at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2052)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1134)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.parserNext(StAXOMBuilder.java:681)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:214)
... 38 more
TID: [-1234] [] [2018-12-18 11:22:08,894] INFO {org.apache.axis2.builder.BuilderUtil} - Remaining input stream :[event: st2.execution.output__create
data: {"timestamp": "2018-12-18T11:22:08.654318Z", "runner_ref": "local-shell-script", "output_type": "stdout", "action_ref": "nos_utils.dsi_sync", "data": "id: 5c18d85ca832cb61d235c1d4\n", "id": "5c18d860a832cb6079e87993", "execution_id": "5c18d85ba832cb61d235c1d1"}
我的目标仅仅是调用此端点,等待其响应,忽略响应并继续执行序列。
序列代码:
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="dsi_sync_out.xml" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<enrich>
<source clone="true" type="body"/>
<target property="stackOutput" type="property"/>
</enrich>
<property expression="$ctx:stackOutput/id" name="uri.var.stackstormexecId" scope="default" type="STRING"/>
<header name="St2-Api-Key" scope="transport" value="somekey"/>
<header name="Accept" scope="transport" value="*/*"/>
<call blocking="true">
<endpoint>
<http method="get" uri-template="http://10.220.7.50:9102/v1/executions/{uri.var.stackstormexecId}/output"/>
</endpoint>
</call>
<header name="St2-Api-Key" scope="transport" value="somekey"/>
<header name="Accept" scope="transport" value="application/json"/>
<call>
<endpoint>
<http method="get" uri-template="http://10.220.7.50:9101/v1/executions/{uri.var.stackstormexecId}"/>
</endpoint>
</call>
<respond/>
</sequence>
答案 0 :(得分:0)
发生此问题是因为呼叫响应的Content-Type
是text/event-stream
,WSO2 API Manager axis2消息生成器没有开箱即用地定义它。