我刚刚开始使用 Node.js,并且尝试使用 Node Soap 扩展来使用 SOAP 服务。我现在只是使用示例服务调用,但似乎无法启动并运行它。
var soap = require('soap');
var fs = require('fs');
reqURL = fs.readFile('www.webservicex.net/stockquote.asmx?WSDL', 'UTF-8', function(err, data){
if(err) console.log(err)
soap.createClient(data, function(err, client){
client.StockQuote.StockQuoteSoap.GetQuote({symbol:'NKE'}, function(err, response){
if(err) console.log(err);
console.log(response);
});
console.log('Here is the SOAP sent to ' + data + client.lastrequest);
});
});
Run Code Online (Sandbox Code Playgroud)
这是我收到的错误:
{ [Error: ENOENT, open 'c:\dev\workspace\WebDevClass\node\www.webservicex.net\st
ockquote.asmx?WSDL']
errno: -4058,
code: 'ENOENT',
path: 'c:\\dev\\workspace\\WebDevClass\\node\\www.webservicex.net\\stockquote.
asmx?WSDL' }
fs.js:491
binding.open(pathModule._makeLong(path),
^
TypeError: path must be a string
at TypeError (native)
at Object.fs.open (fs.js:491:11)
at Object.fs.readFile (fs.js:262:6)
at …Run Code Online (Sandbox Code Playgroud)