2013-04-15 16 views
5

Właśnie zaczynam pracę z NodeJS i przekopuję się na rozmowę z usługą SOAP przy użyciu milewise's node-soap. Korzystam z interfejsu API SOAP do sprawdzania adresów e-mail jako mojego przypadku testowego.Wysyłanie argumentów za pośrednictwem Soap w Node.js za pomocą węzła-mydła

Nie wydaje mi się, że rozumiem prawidłowy sposób formatowania list argumentów.

Moje SOAP kod klienta:

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

Komenda

client.describe() mówi mi, jak chcieliby jego API wejście formatowane i jak powróci jego wyjście. To jest to, co mówi:

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

Jednakże kiedy wysłać argumenty jako obiekt: {request:"[email protected]"}

czuję się moich problemów leży w jaki sposób mam definiowania obiektu arguments ... co zrobić nawiasy w request[] oznaczają?

Odpowiedz

9

Powinien działać, jeśli dodasz przestrzeń nazw na żądanie. To jest przykładowy kod.

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

Jednakże zwraca "Dostęp jest zabroniony".

Używam usługi soapUI do testowania tej usługi internetowej, która zwraca ten sam wynik.

Próbuję innej usługi sieciowej i to działa.

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 pobiera żądanie tablicy. Oto co oznacza request[]. Jeśli był to obiekt, powinien po prostu poprosić. Dlatego też, jeśli spróbujesz args następująco może działać:

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

To naprawdę nie odpowiedzieć na pytanie. Jeśli masz inne pytanie, możesz je zadać, klikając [Zadaj pytanie] (https://stackoverflow.com/questions/ask). Możesz również [dodać nagrodę] (https://stackoverflow.com/help/privileges/set-bounties), aby zwrócić więcej uwagi na to pytanie, gdy już masz wystarczającą [reputację] (https://stackoverflow.com/help/ whats-reputation). - [Z recenzji] (/ opinia/niskiej jakości-posts/17793753) – Psi

Powiązane problemy