SOAP request with credentials on Vue.js

ios

#1

I need to use a soap web service and get information from it by giving credentials. I want to do it with NativeScript + Vue.js. For this task, I first implemented program in Python language as

from requests import Session
from requests.auth import HTTPBasicAuth

import zeep
from zeep.transports import Transport

# Example using basic authentication with a webservice

session = Session()
session.auth = HTTPBasicAuth('soap-user', 'soap2018')
transport_with_basic_auth = Transport(session=session)

client = zeep.Client(
    wsdl='http://localhost/_common/webservices/Eval?wsdl',
    transport=transport_with_basic_auth
)

result = client.service.getValue('#ahu-032/sa_temp')

It works like a charm. If it was REST, it would be easy such as,

const Vue = require('nativescript-vue/dist/index');
const http = require('http');

Vue.prototype.$http = http;

methods:
  {
    getData() {
      this.$http
        .getJSON(`https://jsonplaceholder.typicode.com/users`)
        .then(res => {
          console.log(res);
          this.users = res.map(
            user => {
              return {
                name: user.name,
                username: user.username,
                email: user.email
              };
            }
          );
        })
        .catch(err => {
          console.log("err.." + err);
        });
    }
  }

In case of Soap, I would need to get xml request with credentials, then parse it. But even if I found some javascript code snippet for it as below, I could not even come close to solution. So I would appreciate much any help.

var xmlHttp = new XMLHttpRequest();
    xmlHttp.open('POST','http://MY_DOMAIN_ADDRESS/WebService.asmx',true);
    var soapRequest =  '<?xml version="1.0" encoding="utf-8"?>' +
                        '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"'+
                        '<soapenv:Header/>'+
                        '<soapenv:Body>'+
                            '<web:GetUserLoginForApp>'+                          
                                '<web:UserName>USERNAME</web:UserName>'+                         
                                '<web:Password>PASSWORD</web:Password>'+
                            '</web:GetUserLoginForApp>'+
                        '</soapenv:Body>'+
                        '</soapenv:Envelope>' ;

                         xmlHttp.onreadystatechange = function () {
                            if (xmlHttp.readyState == 4) {
                                if (xmlHttp.status == 200) {
                                    alert('done. use firebug/console to see network response');
                                }
                            }
                        }
       xmlHttp.setRequestHeader('Content-Type', 'text/xml');
            xmlHttp.send(soapRequest);