gpt4 book ai didi

templates - WSO2 ESB 序列模板错误

转载 作者:行者123 更新时间:2023-12-03 08:22:55 25 4
gpt4 key购买 nike

我正在使用 WSO2 ESB 序列模板生成通用验证模板。该模板将接收一个简单的 XML 消息,并将根据其架构对其进行验证。 Validate Mediator 需要两件事作为输入。一个是“sourceElement”,另一个是“schemaFilePath”

问题:

我已成功将“sourceElement”作为参数传递,但通过调用模板调解器的参数传递架构文件路径时,我没有得到任何运气。我可以在模板中接收它,但无法在“validate”调解器中使用它。

注意:我使用的是 WSO2 ESB 4.8.1 和 WSO2 developer studio 3.7.0。

“模板代码:”

<?xml version="1.0" encoding="UTF-8"?>
<template xmlns="http://ws.apache.org/ns/synapse" name="ValidateCDM">
<parameter name="sourceElement"/>
<parameter name="schemaFilePath"/>
<sequence>
<validate xmlns:ns="http://org.apache.synapse/xsd" source="$func:sourceElement">
<schema key="$func:schemaFilePath"/>
<on-fail>
<makefault version="pox">
<reason value="Invalid Request"/>
<detail>Invalid Request</detail>
</makefault>
<payloadFactory media-type="xml" description="ErrorMessageTransformation">
<format>
<Error>
<ErrorCode>404</ErrorCode>
<ErrorMessage>Error Thrown.</ErrorMessage>
<ErrorException>Unknown Exception</ErrorException>
</Error>
</format>
</payloadFactory>
<send>
<endpoint key="conf:ErrorQueue.xml"/>
</send>
</on-fail>
</validate>
</sequence>
</template>

“调用模板调解器代码:”

<call-template target="ValidateCDM" description="ValidateCDM">
<with-param xmlns:abc="http://com.example/finance/datafile" name="sourceElement" value="{//abc:Message}"/>
<with-param name="schemaFilePath" value="conf:/Example/XSD/IncomingMessage.xsd"/>
</call-template>

“日志中的异常”

ERROR_MESSAGE : Cannot convert null to a StreamSource {org.apache.synapse.FaultHandler}
TID: [0] [ESB] [2015-01-27 10:32:50,559] WARN {org.apache.synapse.FaultHandler} - ERROR_DETAIL : org.apache.synapse.SynapseException: Cannot convert null to a StreamSource
at org.apache.synapse.config.SynapseConfigUtils.handleException(SynapseConfigUtils.java:576)
at org.apache.synapse.config.SynapseConfigUtils.getStreamSource(SynapseConfigUtils.java:77)
at org.apache.synapse.mediators.builtin.ValidateMediator.mediate(ValidateMediator.java:146)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:77)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:47)
at org.apache.synapse.mediators.template.TemplateMediator.mediate(TemplateMediator.java:77)
at org.apache.synapse.mediators.template.InvokeMediator.mediate(InvokeMediator.java:129)
at org.apache.synapse.mediators.template.InvokeMediator.mediate(InvokeMediator.java:78)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:77)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:47)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:131)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:196)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:77)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:47)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:131)
at org.apache.synapse.core.axis2.ProxyServiceMessageReceiver.receive(ProxyServiceMessageReceiver.java:166)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.axis2.transport.base.AbstractTransportListener.handleIncomingMessage(AbstractTransportListener.java:328)
at org.apache.axis2.transport.jms.JMSMessageReceiver.processThoughEngine(JMSMessageReceiver.java:200)
at org.apache.axis2.transport.jms.JMSMessageReceiver.onMessage(JMSMessageReceiver.java:122)
at org.apache.axis2.transport.jms.ServiceTaskManager$MessageListenerTask.handleMessage(ServiceTaskManager.java:556)
at org.apache.axis2.transport.jms.ServiceTaskManager$MessageListenerTask.run(ServiceTaskManager.java:449)
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:744)
{org.apache.synapse.FaultHandler}

最佳答案

$func:XXX 用作键时必须用大括号括起来:

<schema key="{$func:schemaFilePath}"/>

也许你需要对源属性做同样的事情:

<validate xmlns:ns="http://org.apache.synapse/xsd" source="{$func:sourceElement}">

关于templates - WSO2 ESB 序列模板错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28164244/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com