1
votes

I have defined a "Validate" Mediator fault sequence. I want that if my validation is failed. Message should be sent back to the client as well as to a queue based on JMS.

Problem:

Clone mediator is not working. I am using clone mediator to send message to the queue and then "Respond" mediator to send message back to the client.

Note: If I remove the clone mediator, the message is perfectly send back to the client. But with clone mediator it is not working.

Validate Mediator Code:

 <validate>
         <schema xmlns:ns2="http://org.apache.synapse/xsd" xmlns:ns="http://org.apache.synapse/xsd" key="gov:/xsd/testschema.xsd"></schema>
         <on-fail>
            <makefault version="soap11">
               <detail xmlns:ns2="http://org.apache.synapse/xsd" xmlns:ns="http://org.apache.synapse/xsd" expression="get-property('ERROR_DETAIL')"></detail>
            </makefault>
            <payloadFactory media-type="xml">
               <format>
                  <ErrorMessage xmlns="">
                     <ErrorCode>007</ErrorCode>
                     <ErrorMessage>Not Correct Request</ErrorMessage>
                  </ErrorMessage>
               </format>
            </payloadFactory>
            <clone continueParent="true" sequential="false">
               <target>
                  <endpoint>
                     <address uri="jms:/ErrorQueue?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&amp;java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&amp;java.naming.provider.url=tcp://localhost:61616&amp;transport.jms.DestinationType=queue"></address>
                  </endpoint>
               </target>
            </clone>
            <respond></respond>
         </on-fail>
      </validate>

Exception:

Uncaught exception {org.apache.axis2.transport.base.threads.NativeWorkerPool} java.lang.ClassCastException: org.apache.axiom.om.impl.llom.OMElementImpl cannot be cast to org.apache.axiom.soap.SOAPFault at org.apache.axiom.soap.impl.llom.SOAPBodyImpl.getFault(SOAPBodyImpl.java:120) at org.apache.synapse.util.MessageHelper.cloneSOAPEnvelope(MessageHelper.java:383) at org.apache.synapse.util.MessageHelper.cloneAxis2MessageContext(MessageHelper.java:233) at org.apache.synapse.util.MessageHelper.cloneMessageContext(MessageHelper.java:86) at org.apache.synapse.mediators.eip.splitter.CloneMediator.getClonedMessageContext(CloneMediator.java:159) at org.apache.synapse.mediators.eip.splitter.CloneMediator.mediate(CloneMediator.java:99) 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.builtin.ValidateMediator.mediate(ValidateMediator.java:212) 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.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:411) at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:183) 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)

Note: I also didn't define anything in "SOAP Action" field in "Clone" mediator.

1

1 Answers

1
votes

It is a bug in ESB 4.8.1. Please check this [1]

1.https://wso2.org/jira/browse/ESBJAVA-3087

Try this with call mediator and enrich mediator. I have not tested this.

<validate>
         <schema xmlns:ns2="http://org.apache.synapse/xsd" xmlns:ns="http://org.apache.synapse/xsd" key="gov:/xsd/testschema.xsd"></schema>
         <on-fail>
            <makefault version="soap11">
               <detail xmlns:ns2="http://org.apache.synapse/xsd" xmlns:ns="http://org.apache.synapse/xsd" expression="get-property('ERROR_DETAIL')"></detail>
            </makefault>
            <payloadFactory media-type="xml">
               <format>
                  <ErrorMessage xmlns="">
                     <ErrorCode>007</ErrorCode>
                     <ErrorMessage>Not Correct Request</ErrorMessage>
                  </ErrorMessage>
               </format>
            </payloadFactory>

        **<property name="BODY_ELEMENTS" expression="$body">**
            **<call>**

                  <endpoint>
                     <address uri="jms:/ErrorQueue?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&amp;java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&amp;java.naming.provider.url=tcp://localhost:61616&amp;transport.jms.DestinationType=queue"></address>
                  </endpoint>

            **</call>**
    **<enrich>
            <source xpath="$ctx:BODY_ELEMENTS/> 
            <target type="body"/>
    </enrich>**   
            <respond></respond>
         </on-fail>
      </validate>