I'm using SoapUI to take the WS test:
AnotherimagethatshowsauthenticationtoconsumeXML:
OnlywhenItrytoconsumethesamexmlonlythroughthejavascript,Icannot(IthinkIlacktechnicalknowledge)
$(document).ready(function (){
var url = 'http://SERVIDOR:PORTA/wsConsultaSQL/IwsConsultaSQL';
var method = 'POST';
var postData =
'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tot="http://www.totvs.com/">\n'
+ ' <soapenv:Header/>\n'
+ ' <soapenv:Body>\n'
+ ' <tot:RealizarConsultaSQL>\n'
+ ' <tot:codSentenca>06</tot:codSentenca>\n'
+ ' <tot:codColigada>1</tot:codColigada>\n'
+ ' <tot:codSistema>S</tot:codSistema>\n'
+ ' <tot:parameters>NUMEROINSCRICAO=192;IDPS=6</tot:parameters>\n'
+ ' </tot:RealizarConsultaSQL>\n'
+ ' </soapenv:Body>\n'
+ ' </soapenv:Envelope>\n';
var req = new XMLHttpRequest();
req.open("POST", url, true);
req.setRequestHeader('Content-type', 'text/xml; charset=utf-8');
req.setRequestHeader('SOAPAction', '');
req.withCredentials = true;
req.setRequestHeader("Authorization", "Basic " + btoa('milrak.pessoa' + ":" + 'MINHASENHA'))
req.onreadystatechange = function () {
if (req.readyState != 4) return;
if (req.status != 200 && req.status != 304) {
console.log('HTTP error ' + req.status);
return;
}
console.log(req.responseText);
}
if (req.readyState == 4) return;
req.send(postData);
});