Created
November 12, 2023 14:38
-
-
Save mksddn/393c43b4713e28d887d0d4372c622f58 to your computer and use it in GitHub Desktop.
Simplest SOAP example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>SOAP JavaScript Client Test</title> | |
<script type="text/javascript"> | |
function soap() { | |
var xmlhttp = new XMLHttpRequest(); | |
xmlhttp.open('POST', 'https://somesoapurl.com/', true); | |
// build SOAP request | |
var sr = | |
'<?xml version="1.0" encoding="utf-8"?>' + | |
'<soapenv:Envelope ' + | |
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' + | |
'xmlns:api="http://127.0.0.1/Integrics/Enswitch/API" ' + | |
'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' + | |
'xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">' + | |
'<soapenv:Body>' + | |
'<api:some_api_call soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">' + | |
'<username xsi:type="xsd:string">login_username</username>' + | |
'<password xsi:type="xsd:string">password</password>' + | |
'</api:some_api_call>' + | |
'</soapenv:Body>' + | |
'</soapenv:Envelope>'; | |
xmlhttp.onreadystatechange = function () { | |
if (xmlhttp.readyState == 4) { | |
if (xmlhttp.status == 200) { | |
alert(xmlhttp.responseText); | |
// alert('done. use firebug/console to see network response'); | |
} | |
} | |
} | |
// Send the POST request | |
xmlhttp.setRequestHeader('Content-Type', 'text/xml'); | |
xmlhttp.send(sr); | |
// send request | |
// ... | |
} | |
</script> | |
</head> | |
<body> | |
<form name="Demo" action="" method="post"> | |
<div> | |
<input type="button" value="Soap" onclick="soap();" /> | |
</div> | |
</form> | |
</body> | |
</html> <!-- typo --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment