我尝试了很多使用节点模块wcf.js的网络示例。但无法得到任何适当的结果。我使用下面的链接如何在node.js中使用WCF soap web服务
https://webservice.kareo.com/services/soap/2.1/KareoServices.svc?wsdl
任何一个谁可以解释我的代码的帮助将是非常有益的。我想知道如何访问node.js中的wsdl
谢谢。
我尝试了很多使用节点模块wcf.js的网络示例。但无法得到任何适当的结果。我使用下面的链接如何在node.js中使用WCF soap web服务
https://webservice.kareo.com/services/soap/2.1/KareoServices.svc?wsdl
任何一个谁可以解释我的代码的帮助将是非常有益的。我想知道如何访问node.js中的wsdl
谢谢。
你可以看看我的代码在这个链接http://stackoverflow.com/questions/15562943/wcf-web- service-in-node-js,但会引发一些错误。你可以帮我解决代码中的错误吗? – user87267867 2013-03-25 10:21:39
我认为一个替代方案将是:
是的,这是一个相当脏,低水平的方法,但它应该没有问题
你没有那么多的选择。
你可能会想使用一个:
我试图节点皂获得INR美元汇率与下面的代码。
app.get('/getcurr', function(req, res) {
var soap = require('soap');
var args = {FromCurrency: 'USD', ToCurrency: 'INR'};
var url = "http://www.webservicex.net/CurrencyConvertor.asmx?WSDL";
soap.createClient(url, function(err, client) {
client.ConversionRate(args, function(err, result) {
console.log(result);
});
});
});
代码项目已经得到了neat sample它使用wcf.js用于其API的是WCF像这样不需要学习新的范例。
请看看wcf.js
总之你可以按照下列步骤操作:
NPM安装WCF。JS
撰写您这样的代码:
代码
var Proxy = require('wcf.js').Proxy;
var BasicHttpBinding = require('wcf.js').BasicHttpBinding;
var binding = new BasicHttpBinding();
//Ensure the proxy variable created below has a working wsdl link that actually loads wsdl
var proxy = new Proxy(binding, "http://YourHost/YourService.svc?wsdl");
/*Ensure your message below looks like a valid working SOAP UI request*/
var message = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:sil='http://YourNamespace'>" +
"<soapenv:Header/>" +
"<soapenv:Body>" +
"<sil:YourMethod>" +
"<sil:YourParameter1>83015348-b9dc-41e5-afe2-85e19d3703f9</sil:YourParameter1>" +
"<sil:YourParameter2>IMUT</sil:YourParameter2>" +
"</sil:YourMethod>" +
"</soapenv:Body>" +
"</soapenv:Envelope>";
/*The message that you created above, ensure it works properly in SOAP UI rather copy a working request from SOAP UI*/
/*proxy.send's second argument is the soap action; you can find the soap action in your wsdl*/
proxy.send(message, "http://YourNamespace/IYourService/YourMethod", function (response, ctx) {
console.log(response);
/*Your response is in xml and which can either be used as it is of you can parse it to JSON etc.....*/
});
的可能重复[Node.js的:如何消费SOAP XML Web服务(http://stackoverflow.com/questions/8655252/node-js-how-to-consume-soap-xml-web-service) – 2015-04-27 10:45:22