2013-03-25 11 views
6

Tôi đã thử rất nhiều ví dụ có sẵn trong mạng bằng cách sử dụng mô-đun nút wcf.js. Nhưng không thể có được kết quả phù hợp. Tôi đang sử dụng url bên dướiCách sử dụng dịch vụ web xà phòng WCF trong node.js

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

Bất kỳ ai có thể giải thích cho tôi với sự giúp đỡ của mã sẽ thực sự hữu ích. Tôi muốn biết cách truy cập wsdl trong node.js

Cảm ơn.

+0

thể trùng lặp của [Node.js: làm thế nào để tiêu thụ SOAP dịch vụ web XML] (http://stackoverflow.com/câu hỏi/8655252/nút-js-cách-để-tiêu-xà-xml-web-dịch vụ) –

Trả lời

0

Có thể bạn sẽ muốn sử dụng một trong số:

Aslo, có an existing question.

+0

U có thể xem mã của tôi trong liên kết này http://stackoverflow.com/questions/15562943/wcf-web- dịch vụ-trong-nút-js nhưng nó ném một số lỗi. U có thể giúp tôi trong những gì sai trong mã? – user87267867

0

Tôi nghĩ rằng một sự thay thế sẽ được:

  • sử dụng một công cụ như SoapUI để ghi lại đầu vào và đầu ra xml điệp
  • sử dụng node request để tạo thành thông điệp xml nhập để gửi (POST) yêu cầu đến các dịch vụ web (lưu ý rằng tiêu chuẩn javascript cơ chế khuôn mẫu như ejs hoặc mustache có thể giúp bạn ở đây) và cuối cùng
  • sử dụng một phân tích cú pháp XML để deserialize dữ liệu đáp ứng với các đối tượng JavaScript

Có, đây là một cách tiếp cận khá bẩn và thấp nhưng nó sẽ hoạt động mà không có vấn đề

1

Bạn không có nhiều tùy chọn.

Có thể bạn sẽ muốn sử dụng một trong số:

  • nút-xà phòng
  • douche
  • soapjs

tôi đã cố gắng nút-xà phòng để có được tỷ lệ INR USD với đoạn mã sau .

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); 
    }); 
    }); 
}); 
1

Mã số dự án đã có một neat sample trong đó sử dụng wcf.js mà api được WCF như vậy không cần phải học hỏi mô hình mới.

0

hãy có một cái nhìn tại wcf.js

Nói tóm lại bạn có thể làm theo các bước sau:

  1. NPM cài đặt WCF.js

  2. Viết mã của bạn như thế này:

đang

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