Forum Discussion

nschwanke's avatar
nschwanke
Frequent Visitor
6 years ago

Sending SOAPUI requests to mock service via Javascript - HTTP error code 500 - Internal Server Error

I am attempting to make SOAP requests via Javascript to a mock server I have running on my computer (port 8080) via SoapUI. The function I am using to send my built SOAP string is:

function sendSoap(message){
  alert("sendSoap func received soap msg:\n" + message);
  var xmlhttp = new XMLHttpRequest();
  xmlhttp.onreadystatechange = function () 
  {
      if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { // req done, resp rdy
      alert("done. use firebug/console to see network response");
      }
  };
  xmlhttp.open('POST', "http://localhost:8080", true);
  xmlhttp.setRequestHeader('Content-Type', 'text/xml');
  xmlhttp.send(message); // Mock service on port 8080 on soapUI not receiving anything
  var stat = xmlhttp.status;
  alert("The status of the request is: " + stat);
}

 

However, my status is returning 0 and the console is showing an HTTP status code 500 (general Internal Server Error). I am running my code from within jsfiddle.net. I understand that this is most likely a CORS related issue as the jsfilldle.net client is on a different domain than my localhost.

Therefore in SOAPUI I added the header Access-Control-Allow-Origin: * to my mock responses, which I believed would allow the sharing of resources. This has not worked.

I also attempted to use an extension for Chrome which disables CORS features, which changed my error message to: Response for preflight has invalid HTTP status code 500.

Any ideas?

No RepliesBe the first to reply