I am using WSO2 ESB Sequence templates to generate a generic validation template. This template will receive a simple XML message and it will validate it against it's schema. Validate Mediator requires two things as input. one is "sourceElement" and other is "schemaFilePath"
Problem:
I have successfully passed the "sourceElement" as parameter but i am not getting any luck passing the schema file path through the call-template mediator's parameters. I am able to receive it in the template but i am not able to use it in the "validate" mediator.
Note: I am using WSO2 ESB 4.8.1 and WSO2 developer studio 3.7.0.
"Template Code:"
<?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 Mediator Code:"
<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>
"Exception in the Logs"
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}