从量角器中的soap方法返回对象
我正在使用soap在量角器中测试我的应用程序wsdls。 这是我正在使用的代码 我希望“servicechitest”函数返回屏幕截图中突出显示的结果。它将预期输出打印到控制台。从量角器中的soap方法返回对象,soap,protractor,node-modules,node-soap,Soap,Protractor,Node Modules,Node Soap,我正在使用soap在量角器中测试我的应用程序wsdls。 这是我正在使用的代码 我希望“servicechitest”函数返回屏幕截图中突出显示的结果。它将预期输出打印到控制台。 不确定在哪里可以放置return语句来获取results对象。您需要实现从异步方法获取值的承诺。您可以使用npm的q模块来实现承诺 要安装q,请在终端中运行以下命令 npm install q 下载q后,在应用程序中使用它,如下所示 var q= require('q'); servicehitest : fun
不确定在哪里可以放置return语句来获取results对象。您需要实现从异步方法获取值的承诺。您可以使用npm的q模块来实现承诺 要安装q,请在终端中运行以下命令
npm install q
下载q后,在应用程序中使用它,如下所示
var q= require('q');
servicehitest : function () {
var url ="someurl";
var args= [];
var defered = q.defer();
soap.creatClient(url,creatClient);
function clientCreate(err,client) {
if(err){
console.log("in error block");
console.log(client.describe());
}
client.getInstrument(args,instrument);
function instrument(err,result){
if(err){
defered.reject(err);
} else {
console.log(result);
defered.resolve(result);
}
}
}
return defered.promise;
}
要从servicehitest方法获得结果,请使用以下代码
servicehitest().then(function(result){
//this method will be called when the result is obtained from getInstrument() method.
console.log("Successfully got result:"+result);
},
function(error){
//error callback method will be called if there is any error from getInstrument() method.
console.log("Some error occured:"+error);
})
不要将代码作为截图发布。试着把它作为一个文本内容发布,这样别人就可以很容易地提供详细的答案。谢谢老兄!成功了。此后,我将以文本格式添加代码。