Garethp Posted January 22, 2010 Share Posted January 22, 2010 I'm trying to make a SOAP call using XMLHttpRequest. This is my code <html> <head> <title>SOAP call sample</title> <script language="Javascript"> // Variables var xmlHttpReq = false; var callname = "http://autoi.com.au/PartGroups"; function xmlhttpPost() { // Mozilla/Safari if (window.XMLHttpRequest) { xmlHttpReq = new XMLHttpRequest(); } // IE else if (window.ActiveXObject) { xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); } xmlHttpReq.open('POST', 'http://119.31.230.58/', true); //Set the Headers xmlHttpReq.setRequestHeader('Content-Type','text/xml'); xmlHttpReq.setRequestHeader('SOAPAction',callname); //When the response is available, update the response text xmlHttpReq.onreadystatechange = function() { if (xmlHttpReq.readyState == 4) { //document.forms['main'].eBayXMLResponse.value = xmlHttpReq.responseText; alert(xmlHttpReq.responseText); } } //get the XML Request string xmlHttpReq.send ('<?xml version="1.0" encoding="utf-8"?>' + '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">' + '<soap:Body>' + '<PartGroups xmlns="http://autoi.com.au/">' + '<UserId>int</UserId>' + ' <AuthCode>string</AuthCode>' + '</PartGroups>' + '</soap:Body>' + '</soap:Envelope>'); //document.forms['main'].eBayXMLResponse.value = xmlHttpReq.responseText; alert('2: ' + xmlHttpReq.responseText); } </script> </head> <form name="main"> <table> <tr> <td> <input value="Submit to eBay => " type="button" onclick='JavaScript:xmlhttpPost()'></td> <td><textarea name="eBayXMLResponse" wrap="soft" rows="40" cols="50" style="overflow:scroll" ID="Textarea1"></textarea></td> </tr> </table> </form> </html> And these are the intructions I was given on how to format the SOAP http://125.236.209.214/autoiaspwebservice.asmx?op=PartGroups But the thing is, I don't get a response. I mean, it's blank. I don't understand. I've tried changing the destination, but I still have no idea why it's not working. Is there anybody who can help? Quote Link to comment https://forums.phpfreaks.com/topic/189396-i-have-no-idea-what-im-doing-wrong/ Share on other sites More sharing options...
salathe Posted January 22, 2010 Share Posted January 22, 2010 Are you running that code from the same IP address as the web service (125.236.209.214)? Quote Link to comment https://forums.phpfreaks.com/topic/189396-i-have-no-idea-what-im-doing-wrong/#findComment-999785 Share on other sites More sharing options...
Garethp Posted January 22, 2010 Author Share Posted January 22, 2010 No I'm not, and I can't get access to it. How can I run this on my own webservice for it to work? Quote Link to comment https://forums.phpfreaks.com/topic/189396-i-have-no-idea-what-im-doing-wrong/#findComment-999830 Share on other sites More sharing options...
RichardRotterdam Posted January 22, 2010 Share Posted January 22, 2010 With javascript alone you have a cross domain issue. A little work around is to request a local serverside script (PHP for example) and make that local script do the soap request. Quote Link to comment https://forums.phpfreaks.com/topic/189396-i-have-no-idea-what-im-doing-wrong/#findComment-999846 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.