0

I try to parse WSDL information from http://rates.kazpost.kz/postratesprodv2/postratesws.wsdl But when I try it, I have nothing. xmlhttp.readyState == 4, but xmlhttp.status == 0.

var xmlhttp = new XMLHttpRequest();
 xmlhttp.open('POST', 'http://rates.kazpost.kz/postratesprodv2/postratesws.wsdl', true);

 // build SOAP request
 var sr =
  '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pos="http://webservices.kazpost.kz/postratesws">' +
  '<soapenv:Header/>' +
  '<soapenv:Body>' +
   '<pos:GetPostRateRequest>' +
    '<pos:GetPostRateInfo>' +
     '<pos:SndrCtg>1</pos:SndrCtg>' +
     '<pos:Product>P102</pos:Product>' +
     '<pos:MailCat>1</pos:MailCat>' +
     '<pos:SendMethod>2</pos:SendMethod>' +
     '<pos:Weight>750</pos:Weight>' +
     '<pos:Dimension>s</pos:Dimension>' +
     '<pos:Value>100</pos:Value>' +
     '<pos:From>050031</pos:From>' +
     '<pos:To>010001</pos:To>' +
     '<pos:ToCountry>au</pos:ToCountry>' +
    '</pos:GetPostRateInfo>' +
   '</pos:GetPostRateRequest>' +
  '</soapenv:Body>' +
  '</soapenv:Envelope>';

 xmlhttp.onreadystatechange = function () {
  if (xmlhttp.readyState == 4) {
   if (xmlhttp.status == 200) {
    alert('done. use firebug/console to see network response');
   } else {
    alert('ERROR. Status: ' + xmlhttp.status + " " + xmlhttp.statusText);
   }
  }
 }
 // Send the POST request
 xmlhttp.setRequestHeader('Content-Type', 'text/xml');
 
 xmlhttp.send(sr);
 // send request
 // alert("Ready.");
GoldenScrew
  • 181
  • 2
  • 3
  • 14

1 Answers1

0

Seems like you're trying to make http request under https connection, so request is blocked by browser for security reasons.

HTTP Ajax Request via HTTPS Page for more details

darkside
  • 47
  • 5
  • I think - no, I tried it from HTTP website also, and from local computer, I had next error: Failed to load http://rates.kazpost.kz/postratesprodv2/postratesws.wsdl: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. – GoldenScrew Jun 01 '18 at 17:49
  • @GoldenScrew https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin - server must send this header to allow CORS Maybe you haven't access to this server, so your solution may be your own proxy – darkside Jun 01 '18 at 18:05
  • Sorry, my level in programming is very low. Your information for JAVA. I need get WSDL information from this link: http://rates.kazpost.kz/postratesprodv2/postratesws.wsdl How can I do this? – GoldenScrew Jun 02 '18 at 08:36
  • @GoldenScrew, simply you can't do it from browser directly. https://stackoverflow.com/questions/27139725/cross-domain-request-without-cors-or-jsonp?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa#comment42777432_27139725 – darkside Jun 04 '18 at 10:18