我试图在javascript中调用空手道功能并捕获其响应,如下所示,但同时,来自karate.call的响应显示垃圾值(com.intuit.karate.ScriptObjectMap@XXXX)。请帮助从karate.call中获取实际值,或向我提出最佳建议?
function RequestMandator(featurepath,data) {
var Mandator = [];
data.forEach(function(data){
var TransferId = data.TransferID;
var FocusKey = data.TransferID + ':';
var TimeStamp = data.LastUpdate;
var result = karate.call(featurepath, { input: [TransferId, FocusKey,TimeStamp ] });
karate.log('Added Mandator :', result);
Mandator.push(result);
})
return Mandator;
}
输出:
11:32:53.307 [main] WARN com.intuit.karate - xml parsing failed, response data type set to string: org.xml.sax.SAXParseException; lineNumber: 5; columnNumber: 15; Open quote is expected for attribute "border" associated with an element type "table".
11:32:53.310 [main] INFO com.intuit.karate - Added Mandator : com.intuit.karate.ScriptObjectMap@102d92c4
Error:
com.intuit.karate.exception.KarateFileNotFoundException: C:\XXXXXXXX\com.intuit.karate.ScriptObjectMap@7808fb9,com.intuit.karate.ScriptObjectMap@25d958c6,com.intuit.karate.ScriptObjectMap@5eeedb60,com.intuit.karate.ScriptObjectMap@6ad6fa53,com.intuit.karate.ScriptObjectMap@6f099cef,com.intuit.karate.ScriptObjectMap@2d66530f,com.intuit.karate.ScriptObjectMap@25b865b5 (The filename, directory name, or volume label syntax is incorrect)
at com.intuit.karate.FileUtils.getFileStream(FileUtils.java:146)
at com.intuit.karate.FileUtils.readFile(FileUtils.java:110)
at com.intuit.karate.ScriptBridge.read(ScriptBridge.java:67)
答案 0 :(得分:0)
请参考有关类型转换的文档:https://github.com/intuit/karate#type-conversion
无法根据您提供的不完整信息来确定。还是让我尝试一下,我认为您在调用此函数之前在字符串连接中犯了一些错误。 featurepath
的值是完全错误的。
在下面的示例中,查看JS函数中的字符串连接如何导致所谓的“垃圾值”:
* def fun = function(){ var temp = { hello: 'world' }; return temp + '' }
* def bar = fun()
* print "bar:", bar
输出结果:
13:52:50.912 [main] INFO com.intuit.karate - [print] bar: [object Object]
如果您仍然遇到问题,我唯一的建议是按照此处的说明进行操作:https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue