任何正文都可以告诉我如何检查传入的消息是否包含唯一的字符串值。如何在wso2 esb中实现这一点。我正在尝试使用switch,但是无法正常工作。
我的switch语句代码是:
<switch xmlns:ns="http://org.apache.synapse/xsd" source="$ctx:ErrorDetail">
<case regex="/Unable to perform XSLT transformation/">
<log level="full" separator="**************mached****************"></log>
</case>
<default>
<log level="full" separator="Not mat"></log>
</default>
</switch>
我正在尝试这个:regex = /无法执行XSLT转换/.
这是错误详细信息日志($ ctx:ErrorDetail):
ErrorDetail = org.apache.synapse.SynapseException: Unable to perform XSLT transformation using : Value {name ='null', keyValue ='conf:/xslt/CDMXSLT.xslt'} against source XPath : s11:Body/child::*[position()=1] | s12:Body/child::*[position()=1] reason : Unable to create an OMElement using XSLT result
at org.apache.synapse.mediators.AbstractMediator.handleException(AbstractMediator.java:313)
at org.apache.synapse.mediators.transform.XSLTMediator.mediate(XSLTMediator.java:194)
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)
Caused by: org.apache.synapse.SynapseException: Unable to create an OMElement using XSLT result
at org.apache.synapse.mediators.transform.XSLTMediator.performXSLT(XSLTMediator.java:302)
at org.apache.synapse.mediators.transform.XSLTMediator.mediate(XSLTMediator.java:191)
... 18 more
Caused by: org.apache.axiom.om.OMException: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[3,1]
Message: Content is not allowed in prolog.
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:296)
at org.apache.axiom.om.impl.llom.OMDocumentImpl.getOMDocumentElement(OMDocumentImpl.java:109)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:570)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:566)
at org.apache.synapse.util.jaxp.StreamResultBuilder.getNode(StreamResultBuilder.java:87)
at org.apache.synapse.mediators.transform.XSLTMediator.performXSLT(XSLTMediator.java:300)
... 19 more
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[3,1]
Message: Content is not allowed in prolog.
at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:598)
at org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper.next(XMLStreamReaderWrapper.java:225)
at org.apache.axiom.util.stax.dialect.SJSXPStreamReaderWrapper.next(SJSXPStreamReaderWrapper.java:138)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.parserNext(StAXOMBuilder.java:681)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:214)
... 24 more
答案 0 :(得分:0)
<filter xmlns:ns="http://org.apache.synapse/xsd" source="json-eval($.node[0].nid)" regex="100">
<then>
//your business here
</then>
<else>
//your business here
</else>
</filter>
您可以像这样比较请求体参数。上面的示例代码比较了身体参数&#39; nid&#39;等于100
答案 1 :(得分:0)
在交换机中介中尝试以下正则表达式。
<case regex="*.Unable to perform XSLT transformation*.">