2013-04-15 123 views
5

NodeJSを使い始めたばかりで、milewise's node-soapを使用してSOAPサービスと話をしています。私はテストケースとして基本的な電子メールアドレスの検証SOAP APIを使用しています。Node-soapを使用してNode.jsのSoap経由で引数を送信

私は引数リストをフォーマットする正しい方法を理解していないようです。

私のSOAPクライアントコード:

var url = "http://www.restfulwebservices.net/wcf/EmailValidationService.svc?wsdl"; 
soap.createClient(url, function(err, client){ 
    console.log(client.describe().EmailValidationService.BasicHttpBinding_IEmailValidationService.Validate); 
    client.Validate({result:"[email protected]"}, function(err, result){ 
      console.log(result); 
    }); 
}); 

client.describe()コマンドは、APIがフォーマットされたその入力をしたいと思いますどのように私に語った、とどのようにそれは、その出力を返します。

{ input: { 'request[]': 'xs:string' }, output: { 'ValidateResult[]': 'xs:boolean' } }

しかし、私はオブジェクトとして引数を送信する場合:これが何であるかを言うです{request:"[email protected]"}

私は私の問題のように感じる私は、引数をオブジェクト定義していますどのようにある...何をすべきか角かっこはrequest[]にありますか?

答えて

9

リクエスト引数に名前空間を追加するとうまくいくはずです。 これはサンプルコードです。

var soap = require('soap'); 

var url = "http://www.restfulwebservices.net/wcf/EmailValidationService.svc?wsdl"; 

var args = {"tns:request":"[email protected]"}; 

soap.createClient(url, function(err, client){ 
    client.EmailValidationService.BasicHttpBinding_IEmailValidationService.Validate(args, function(err, result){ 
      if (err) throw err; 
      console.log(result); 
    }); 
}); 

ただし、「アクセスが拒否されました」を返します。

私はこのWebサービスをテストするためにsoapUIを使用しますが、同じ結果を返します。

私は別のWebサービスを試してみました。

var soap = require('soap'); 

var url = "http://www.restfulwebservices.net/wcf/StockQuoteService.svc?wsdl"; 

var args = {"tns:request":"GOOG"}; 

soap.createClient(url, function(err, client){ 

    client.StockQuoteService.BasicHttpBinding_IStockQuoteService.GetStockQuote(args, function(err, result){ 
      if (err) throw err; 
      console.log(result); 
    }); 
}); 
1

ValidateResultが配列要求を受け取ります。つまり、request[]の意味です。それがオブジェクトであれば、それはちょうど要求であるべきです。したがって、次のように引数をしようとした場合、それが動作可能性があります

var args = {request[]: ["[email protected]", "another email adress if you 
want"]}; 
-1
I have similar situation where i have accountId[] , i need to pass multiple accountID, when i pass like "tns:accountId[]": [2321,2345325], it failing saying incorrect request parameter, it comes as <tns:accountId[]>2321</tns:accountId[]> 
<tns:accountId[]>2345325</tns:accountId[]>. 

I need to get <tns:accountId>2321</tns:accountId> 
<tns:accountId>2345325</tns:accountId>. When i tried removing "[]", it comes as <accountId> only and it is failing. Can someone please help me? 
+0

これは本当に質問に答えていません。別の質問がある場合は、[質問する](https://stackoverflow.com/questions/ask)をクリックして質問することができます。十分な[評判](https://stackoverflow.com/help/)があれば、この問題にもっと注意を払うために[奨励金を追加](https://stackoverflow.com/help/privileges/set-bounties)することもできます何が評判か)。 - [レビューから](/レビュー/低品質の投稿/ 17793753) – Psi

関連する問題