我试图使用node-soap调用soa服务,即:https://www.npmjs.com/package/soap
代码是:
var soap = require('soap');
var url = 'http://localhost:8080/tc/services/Core-2008-06-DataManagement?wsdl';
var args = {name: 'value'};
soap.createClient(url, function(err, client) {
client.MyFunction(args, function(err, result) {
console.log(result);
});
});
但是在执行时遇到错误.."无法读取属性' MyFunction'未定义"
如何解决错误
答案 0 :(得分:1)
如何在代理服务器后面运行上述客户端...我尝试使用proxy:参数运行代码,但似乎没有效果...得到相同的错误,即创建未定义。
var soap = require('soap'),
url = 'http://01hw748540:8080/tc/services/Core-2008-06-DataManagement?wsdl',
args = { n1: '2',n2:'3' }
soap.createClient(url, function(err, client) {
client.create(args, function(err, result) {
console.log(result);
}, {proxy: process.env.http_proxy});
});
答案 1 :(得分:0)
MyFunction只是节点包的一个例子。
您必须调用wsdl中指定的函数,此处为:http://localhost:8080/tc/services/Core-2008-06-DataManagement?wsdl
示例,如果您在wsdl中指定了函数UpdateOrder或DeleteOrder,则可以调用:
client.UpdateOrder(....
答案 2 :(得分:0)
示例SOAP 我的案例肥皂网服务
var soap = require('soap');
function xyzFunction() {
var wsdl = 'http://xxy.com/Details.asmx?WSDL';
callSoapService(wsdl, 'GetXYZMethodDataInJSON', {});
}
function callSoapService(wsdl, methodName, args, callback) {
soap.createClient(wsdl, function(err, client) {
console.log(err);
client[methodName](args, function(err, result) {
console.log(err);
console.log(result);
callback(result);
});
});
}