Hi Everyone,

I am trying to use Ajax to submit an XML Web Service request and receive a response XML. While it works perfectly when I submit these requests directly from the XXXX, YYYY, ZZZZ servers on the intranet. The request gets stuck at .open if I connect from any other server ABCD. However, if I use the url(asmx) to check the connection from a browser on ABCD, I am able to see the list of available web method and the corresponding wsdl file. Not sure why its not letting me submit requests through AJAX.

Apologies if my language is very amateurish as I am not much aware of this stuff. I am not even using localhost or anything in the url.

Please help. I have attached the full HTML file for reference.

Thanks in advance.

Best Regards,

Sriram

var url = document.getElementById("GWSInstance").getAttribute("value");
var mthd = document.getElementById("WebMethod").getAttribute("value");
//Set target node
objXMLHttpRequest.open("POST", url, true);
objXMLHttpRequest.setRequestHeader("Content-Type", "text/xml");

//Set web method to consume
objXMLHttpRequest.setRequestHeader("SOAPAction",mthd);

The corresponding <select> elements in the HTML file are as follows:

<label>Instance:</label>
<select id = 'GWSInstance'>
<option value = 'http://XXXX/GwsIS/IntegrationService.asmx'>http://XXXX/GwsIS/IntegrationService.asmx</option>
<option value = 'http://YYYY/GwsIS138002320/IntegrationService.asmx'>http://YYYY/GwsIS138002320/IntegrationService.asmx</option>
<option value = 'http://ZZZZ/GwsIS/IntegrationService.asmx'>http://ZZZZ/GwsIS/IntegrationService.asmx</option>
</select>
<label>Web Method:</label>
<select id = 'WebMethod'>
<option value = 'http://rebusis.com/webservices/gcs/IntegrationService/ProcessNA'>ProcessNA</option>
<option value = 'http://rebusis.com/webservices/gcs/IntegrationService/ProcessUW'>ProcessUW</option>
<option value = 'http://rebusis.com/webservices/gcs/IntegrationService/ProcessClaim'>ProcessClaim</option>
<option value = 'http://rebusis.com/webservices/gcs/IntegrationService/ProcessAccounts'>ProcessAccounts</option>
</select>

Are you aware that XMLHTTPRequest can only be made to the same domain?

You need the domain you're requesting from to grant cross domain access somehow or you will have to proxy the request.

Yes, I agree that it can't be a cross-domain request. However, I had enabled Miscellaneous -> Access Data Sources across domains... in the IE security setup. I happened to understand that once that is enabled, you can actually submit cross-domain request through Ajax. Please correct me if I am wrong.

Thanks for your help.

From the docs it seems it should work.

Try taking a look at the HTTP request with a tool like Wireshark so see if you're actually getting a HTTP request.

Also if you use a try/catch block around the xmlhttprequest open method you should see the error mesage.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.