WSO2 ESB序列模板错误

时间:2015-01-27 06:08:37

标签: templates wso2 wso2esb wso2developerstudio

我正在使用WSO2 ESB Sequence模板生成通用验证模板。此模板将接收一条简单的XML消息,并将根据其模式对其进行验证。验证介体需要两个输入。一个是“sourceElement”,另一个是“schemaFilePath”

问题:

我已经成功传递了“sourceElement”作为参数,但我没有运气通过调用模板介体的参数传递模式文件路径。我能够在模板中收到它,但我无法在“验证”中介中使用它。

注意:我使用的是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}

2 个答案:

答案 0 :(得分:2)

$ func:当用作密钥时,XXX必须用大括号括起来:

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

并且perharps你需要对source属性做同样的事情:

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

答案 1 :(得分:1)

您希望传递动态键值,但首先请检查关键区域中允许的任何x路径或属性值?请检查并确认。如果wso2不允许,那么就不可能,但请先确认。

谢谢, Awais Naeem