2017-08-06 1 views
6

私は強力なsoapノードモジュールを使用しています。私はwebserviceを呼び出したい、私はwsdlファイルを持っています。ノードjsを介してwsdl webserviceを消費する方法

var soap = require('strong-soap').soap; 
var WSDL = soap.WSDL; 
var path = require('path'); 
var options = {}; 
WSDL.open('./wsdls/RateService_v22.wsdl',options, 
    function(err, wsdl) { 
    // You should be able to get to any information of this WSDL from this object. Traverse 
    // the WSDL tree to get bindings, operations, services, portTypes, messages, 
    // parts, and XSD elements/Attributes. 

    var service = wsdl.definitions.services['RateService']; 
    //console.log(service.Definitions.call()); 
    //how to Call rateService ?? 
}); 
+0

私の答えについてのフィードバックはありますか? – ffeast

答えて

3

sample SOAP serviceを使用できるようにします:

あなたが使用したいと思います。コードから判断するには(WHOIS)

ホスト名/ドメイン名でドメイン名の登録レコードを取得します。 a .wsdlファイルはローカルでご利用になれますので、保存してください。

mkdir wsdl && curl 'http://www.webservicex.net/whois.asmx?WSDL' > wsdl/whois.wsdl 

今それを照会するには、次のコードを使用することができます:

'use strict'; 

var soap = require('strong-soap').soap; 
var url = './wsdl/whois.wsdl'; 

var requestArgs = { 
    HostName: 'webservicex.net' 
}; 

var options = {}; 
soap.createClient(url, options, function(err, client) { 
    var method = client['GetWhoIS']; 
    method(requestArgs, function(err, result, envelope, soapHeader) { 
    //response envelope 
    console.log('Response Envelope: \n' + envelope); 
    //'result' is the response body 
    console.log('Result: \n' + JSON.stringify(result)); 
    }); 
}); 

それはいくつかの意味のある結果をもたらすでしょう。あなたが使用しようとしている WSDL.openはツリー形式にmeant for WSDL構造で作業

ロードのWSDLです。 WSDLツリーをたどって、 バインディング、サービス、ポート、操作などを取得します。

あなたは、必ずしも私がどのようにstrong-soap作品についてはよく分からないサービス

6

を呼び出すためにそれを必要としません。 はしかし、私はnode-soapパッケージが要求同時処理数を維持するためにPromisesを使用してSOAPのいくつかの実装は、基本的に

node-soapを使用しています。

var soap = require('soap'); 
    var url = 'http://www.webservicex.net/whois.asmx?WSDL'; 
    var args = {name: 'value'}; 
    soap.createClient(url, function(err, client) { 
     client.GetWhoIS(args, function(err, result) { 
      console.log(result); 
     }); 
    }); 
関連する問題