I am communicating to a web service using nodejs and node-soap. But i just can't seem to get the syntax right for passing the parameters to the service.
The documentation says i need to send an array with the field uuid and its value.
Here is the Php code i got as an example from the web service owner
$uuid = "xxxx";
$param = array("uuid"=>new SoapVar($uuid,
XSD_STRING,
"string", "http://www.w3.org/2001/XMLSchema")
)
and here is the code i am using in my node server
function getSoapResponse()
{
var soap = require('soap');
var url = 'http://live.pagoagil.net/soapserver?wsdl';
var auth = [{'uuid': 'XXXXXXXXX'}];
soap.createClient(url, function(err, client) {
client.ListaBancosPSE(auth, function(err, result)
{
console.log(result);
console.log(err);
});
});
With this i get bad xml error
var auth = [{'uuid': 'XXXXXXXXX'}];
or
var auth = [["uuid",key1],XSD_STRING,"string","http://www.w3.org/2001/XMLSchema"];
and with this i get the response "the user id is empty" (the uuid)
var auth = {'uuid': 'XXXXXXXXX'};
Any suggestions?
There is not much I can do for you but here are a few tips to get you started.
The service you are trying to reach has the following structure:
{ App_SoapService:
{ App_SoapPort:
{ Autorizar: [Object],
AutorizarAdvance: [Object],
AutorizarIac: [Object],
ListaBancosPSE: [Object],
AutorizarPSE: [Object],
AutorizarTuya: [Object],
AutorizarBotonCredibanco: [Object],
FinalizarPSE: [Object],
FinalizarTuya: [Object],
ConsultarReferencia: [Object] } } }
Taking a closer look to the specific method ListaBancosPSE it provides this info:
{input: { auth: 'soap-enc:Array' },
output: { return: 'soap-enc:Array' }}
I tried with this:
var soap = require('soap');
function getSoapResponse(url, auth) {
soap.createClient(url, function(err, client) {
console.log(client.describe());
console.log(client.describe().App_SoapService.App_SoapPort.ListaBancosPSE);
client.ListaBancosPSE(auth, function(err, result) {
console.log(JSON.stringify(result));
console.log(err);
});
});
}
getSoapResponse('http://live.pagoagil.net/soapserver?wsdl', {'soap-enc:Array' : {'uuid': 'XXXXXXXXX'}});
The response is the same "Negada, Error nombre de usuario vacio, No se pudo autenticar en pagoagil.net.".
The next steps for you would be to determine which is the message the service is expecting.
Could be something like:
<tns:ListaBancosPSE><uuid>XXXXXXXXX</uuid></tns:ListaBancosPSE>
Or
<tns:ListaBancosPSE><soap-enc:Array><uuid>XXXXXXXXX</uuid></soap-enc:Array></tns:ListaBancosPSE>
Once you know that, you just have to add a console.log in the node-soap package you installed, so go to where you have your node_modules installed and open the file
node_modules/soap/lib/client.js
Add a console.log at line 187, right after the message has been set and
console.log("Message! ", message);
This will show the message, that should give you enough information to figure out the format of the arguments.