M
M
MaoCzedun2015-11-22 02:15:03
SOAP
MaoCzedun, 2015-11-22 02:15:03

Node soap, how to call methods synchronously?

I'm trying to do a newsletter using the turboSms service, I did it in php, it is easily solved there, then I download the soap package, after which I try to connect and authorize following the instructions, then I try to send sms, and then an error occurs, turboSms does not allow me to send a message and writes that I am not authorized, although before that authorization was successful, it turns out that the methods work asynchronously
d6159b82c90a4b1faa5c5c26a56a0219.png

var url='http://turbosms.in.ua/api/wsdl.html',
    soap = require('soap'),
    report = require('./errorReporting').report,
    clientPhoneAlex="+30090999990",
    clientPhoneVictoria="+30090999991"
    authData={login:"11111",password:"22222"},
    sender="BigLapa.com",
    soapClient;

soap.createClient(url,function(error,client){
     report(error);
     client.Auth(authData,function(error,result){
        report(error);
        console.log(result);
        console.log(1);
      });
      setTimeout(function(){
        client.SendSMS({sender:"BigLapa.com",destination:clientPhoneAlex,text:"Пять минут полет нормальный"},function(error,result){
          console.log(2);
           report(error);
            console.log(result);
        });
      },4000);

    console.log(client.getHttpHeaders());
});

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
yeti357, 2015-11-26
@yeti357

maybe because you need to send a message in the authorization callback, and not in parallel with it, albeit with a timeout. You write asynchronous code, if you understand what I mean.

M
MaoCzedun, 2015-11-26
@MaoCzedun

decided, the problem was not in this, but in the fact that soap does not natively support working with sessions in node , for this it is worth downloading a separate extension

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question