gpt4 book ai didi

xpath - Xpath base64Decode在Wso2Esb 4.8.1中不起作用

转载 作者:行者123 更新时间:2023-12-03 17:21:45 26 4
gpt4 key购买 nike

我收到需要解码的base64流。
我正在做一些研究,但是我被卡住了,这是我的代码:

<outSequence>
<property name="cadena" value="Hola mundo" scope="default" type="STRING"/>
<property name="cadena64"
expression="base64Encode(get-property('cadena'))"
scope="default"
type="STRING"/>
<property
name="cadenaASCII"
expression="syn:base64Decode(syn:get-property('cadena64'))"
scope="default"
type="STRING"/>
<payloadFactory media-type="json">
<format>
{"cadena":"$1",
"cadena64":"$2",
"cadenaASCII":"$3",
}
</format>
<args>
<arg evaluator="xml" expression="get-property('cadena')"/>
<arg evaluator="xml" expression="get-property('cadena64')"/>
<arg evaluator="xml" expression="get-property('cadenaASCII')"/>
</args>
</payloadFactory>
<send/>
</outSequence>


我通过取消注释该行来启用Xpath 2.0

synapse.xpath.dom.failover.enabled=true


位于$ ESB_HOME / repository / conf目录中(并重新启动服务)。

这是我得到的错误:

Evaluation of the XPath expression syn:base64Decode(syn:get-property('cadena64')) resulted in an error  More TID[-1234] [ESB] [2019-03-04 19:27:23,359] ERROR {org.apache.synapse.util.xpath.SynapseXPath} - Evaluation of the XPath expression syn:base64Decode(syn:get-property('cadena64')) resulted in an error net.sf.saxon.xpath.XPathEvaluator.compile(XPathEvaluator.java:378) org.apache.synapse.util.xpath.SynapseXPath.evaluateDOMXPath(SynapseXPath.java:529) org.apache.synapse.util.xpath.SynapseXPath.stringValueOf(SynapseXPath.java:364) org.apache.synapse.mediators.builtin.PropertyMediator.getResultValue(PropertyMediator.java:302) org.apache.synapse.mediators.builtin.PropertyMediator.mediate(PropertyMediator.java:96) org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:77) org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:47) org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:131) org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:268) org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:488) org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:170) org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180) org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:225) org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) java.lang.Thread.run(Thread.java:745) 

最佳答案

我认为在4.8.1中仅支持/实现编码,否则如前所述,可以选择升级esb。以下在4.8.1中为我工作

   <property name="contentBase64" expression="//t:Content" scope="default" type="STRING"/>

<script language="js"><![CDATA[importPackage(Packages.org.apache.commons.codec.binary); var log = mc.getServiceLog(); log.info("1");var c = mc.getProperty("contentBase64");log.info("2:"+c);var bc = Base64.decodeBase64(c);log.info("3:"+bc); var result = ""; for(var i = 0; i
< bc.length; ++i){ result+= (String.fromCharCode(bc[i])); } log.info("result:"+result); mc.setProperty("contentDecoded", result);]]></script>


可以在属性“ contentDecoded”中访问已解码的内容。

希望有帮助。

关于xpath - Xpath base64Decode在Wso2Esb 4.8.1中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54989486/

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