我嘗試了很多使用節點模塊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