我正在尝试使用脚本介体编辑有效负载,但是它给出了这个错误:
TID: [0] [ESB] [2014-02-26 11:55:31,709] ERROR {org.apache.axis2.transport.base.threads.NativeWorkerPool} - Uncaught exception {org.apache.axis2.transport.base.threads.NativeWorkerPool}
java.lang.RuntimeException: ContentID is null
at org.apache.axiom.om.impl.llom.OMTextImpl.getDataHandler(OMTextImpl.java:360)
at org.apache.synapse.mediators.bsf.ScriptMediator.prepareExternalScript(ScriptMediator.java:366)
at org.apache.synapse.mediators.bsf.ScriptMediator.mediateWithExternalScript(ScriptMediator.java:244)
at org.apache.synapse.mediators.bsf.ScriptMediator.invokeScript(ScriptMediator.java:212)
at org.apache.synapse.mediators.bsf.ScriptMediator.mediate(ScriptMediator.java:187)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:71)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:114)
at org.apache.synapse.core.axis2.ProxyServiceMessageReceiver.receive(ProxyServiceMessageReceiver.java:154)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:434)
at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:219)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
代码:
<script language="js" key="conf:SecHeaderGenerator.js" function="getBodyWithSecHeader" />
javascript文件:
function getBodyWithSecHeader(mc)
{
var body = mc.getPayloadXML();
var time = new Date().format("yyyy-MM-dd'T'HH:mm:ss+0300");
var user = 'user';
var domain = 'testdomain';
var password = 'pass';
var encoded = hex_md5(time + hex_md5(password)).toLowerCase();
mc.setPayloadXML(
<set_message_status>
<user>
<now>{time}</now>
<login>{user}</login>
<company>{domain}</company>
<auth_string>{encoded}</auth_string>
</user>
{body}
</set_message_status>);
return mc.getPayloadXML();
}
[...]
为什么会出现此错误? 我正在使用WSO2 ESB 4.6.0。
更新
使用相同版本的另一个ESB副本尝试完全相同的场景,它可以正常工作。
答案 0 :(得分:1)
我找到了解决方案。问题是javascript文件的媒体类型是text/plain
而不是application/javascript
。