基于Node.js實現的SOAP客戶端和服務器:Node-SOAP
Node-SOAP 是基于 Node.js 的 SOAP 客戶端和服務器。
該模塊可以讓你使用SOAP連接到Web服務。它還提供了一個服務器,它允許你運行你自己的SOAP服務。
特性
-
非常簡單的 API
-
可以處理 RPC 和 Document schema 類型
-
支持 multiRef SOAP 信息 (thanks to @kaven276)
-
支持同步和異步方法處理器
-
WS-Security (當前只支持 UsernameToken 和 PasswordText 編碼)
Module
soap.createClient(url[, options], callback) - create a new SOAP client from a WSDL url. Also supports a local filesystem path.
var soap = require('soap'); var url = 'http://example.com/wsdl?wsdl'; var args = {name: 'value'}; soap.createClient(url, function(err, client) { client.MyFunction(args, function(err, result) { console.log(result); }); });
Within the options object you may provide an endpoint
property in case you want to override the SOAP service's host specified in the .wsdl
file.
soap.listen(server, path, services, wsdl) - create a new SOAP server that listens on path and provides services.
wsdl is an xml string that defines the service.
var myService = { MyService: { MyPort: { MyFunction: function(args) { return { name: args.name }; } // This is how to define an asynchronous function. MyAsyncFunction: function(args, callback) { // do some work callback({ name: args.name }) } } } } var xml = require('fs').readFileSync('myservice.wsdl', 'utf8'), server = http.createServer(function(request,response) { response.end("404: Not Found: "+request.url) }); server.listen(8000); soap.listen(server, '/wsdl', myService, xml);
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!