如何在node.js中使用WCF soap web服务

我尝试了很多使用节点模块wcf.js的例子。 但是得不到合适的结果。 我正在使用下面的url

https://webservice.kareo.com/services/soap/2.1/KareoServices.svc?wsdl

任何能够通过代码解释我的人都会很有帮助。 我想知道如何访问node.js中的wsdl

谢谢。

你没有那么多的select。

您可能会想要使用以下之一:

  • 节点皂
  • 灌洗
  • soapjs

我尝试节点肥皂以获得以下代码的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); }); }); }); 

代码项目已经得到了一个整洁的示例 ,使用wcf.js为api是wcf像没有必要学习新的范式。

您可能会想要使用以下之一:

  • 节点皂
  • 灌洗
  • soapjs

另外,还有一个问题 。

我认为,另一种select是:

  • 使用诸如SoapUI之类的工具来logginginput和输出xml消息
  • 使用节点请求来形成inputXML消息来发送(POST)请求到Web服务(请注意标准的JavaScript模板机制,如ejs或胡子可以帮助你在这里),最后
  • 使用XMLparsing器来反序列化JavaScript对象的响应数据

是的,这是一个相当脏,低水平的方法,但应该没有问题

请看看wcf.js

总之,您可以按照以下步骤操作:

  1. npm安装wcf.js

  2. 写下你的代码如下:

 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.....*/ });