0
I’m using Soapui to take the test at WS:
Another image that shows authentication to consume XML:
Only when I try to consume the same xml only through javascript, I can’t (I think it lacks technical knowledge)
$(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);
});
Someone has done this with javascript or jquery?
The header
SOAPAction
should be empty?– Woss
@Andersoncarloswoss I’ve been reading some things, will it be because of the security policies, that I can not make or receive request from the same server. (using javascript)
– Milrak Pereira Pessoa