[英]calling a SOAP service from Node.js
I just started using Node.js, and I am trying to consume a SOAP service using the node soap extension. 我刚刚开始使用Node.js,并且尝试使用节点肥皂扩展来使用SOAP服务。 I am just using a sample service call right now, but can't seem to get it up and running. 我现在仅使用一个示例服务呼叫,但似乎无法启动和运行它。
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);
});
});
here is the error I am getting: 这是我得到的错误:
{ [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 open_wsdl (c:\dev\workspace\WebDevClass\node\node_modules\soap\lib\wsdl.j
s:1832:8)
at _requestWSDL (c:\dev\workspace\WebDevClass\node\node_modules\soap\lib\soa
p.js:31:5)
at Object.createClient (c:\dev\workspace\WebDevClass\node\node_modules\soap\
lib\soap.js:48:3)
at c:\dev\workspace\WebDevClass\node\cliSoapTest.js:6:14
at fs.js:263:20
at FSReqWrap.oncomplete (fs.js:95:15)
Check this out 看一下这个
var soap = require("soap");
var url = 'http://www.webservicex.net/stockquote.asmx?WSDL';
reqURL = soap.createClient(url, function(err, client){
if(err) {
console.log(err);
return;
}
client.StockQuote.StockQuoteSoap.GetQuote({symbol:'NKE'}, function(err, response){
if(err) {
console.log(err);
return;
}
console.log(response);
});
});
Try this 尝试这个
var soap = require('soap');
var url = 'www.webservicex.net/stockquote.asmx?WSDL'
reqURL = soap.createClient(url, function(err, client){
client.StockQuote.StockQuoteSoap.GetQuote({symbol:'NKE'}, function(err, response){
if(err) console.log(err);
console.log(response);
});
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.