Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

WEbservice call Issue

$
0
0

Not able to call webservice from javascript. below is the code. please help

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/.../xhtml1-transitional.dtd">
<html>
<head>
<meta charset="utf-8">
<title>Feedback</title>
<style type="text/css">
body {
font-family: Segoe UI,Tahoma,Arial;
font-size: 11px;
}
</style>

<script type="text/javascript">
function CreateXMLHttpRequest() {
if (typeof XMLHttpRequest != "undefined") {
//All modern browsers (IE7+, Firefox, Chrome, Safari, and Opera) uses XMLHttpRequest object
return new XMLHttpRequest();
}
else if (typeof ActiveXObject != "undefined") {
//Internet Explorer (IE5 and IE6) uses an ActiveX Object
return new ActiveXObject("Microsoft.XMLHTTP");
}
else {
throw new Error("XMLHttpRequestnot supported");
}
}
function callService() {
var objXMLHttpRequest = CreateXMLHttpRequest();
objXMLHttpRequest.open("POST", "www.dneonline.com/calculator.asmx", true);
var packet = '<?xml version="1.0" encoding="utf-8"?>\
<soap:Envelope xmlns:xsi="www.w3.org/.../XMLSchema-instance" xmlns:xsd="www.w3.org/.../XMLSchema" xmlns:soap="schemas.xmlsoap.org/.../envelope">\
<soap:Body>\
<Add xmlns="http://tempuri.org/">\
<intA>10</intA>\
<intB>20</intB>\
</Add>\
</soap:Body>\
</soap:Envelope>';
objXMLHttpRequest.setRequestHeader("SOAPAction", "http://tempuri.org/Add");
objXMLHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
objXMLHttpRequest.send(packet);
// Add mentioned below code only if your application calls webservice synchronously. Otherwise use "onreadystatechange" process response.
response = objXMLHttpRequest.responseXML;
objXMLHttpRequest.onreadystatechange = function () {
if (objXMLHttpRequest.readyState == 4 && objXMLHttpRequest.status == 200) {
result = objXMLHttpRequest.responseXML;
}
}
}
</script>


</head>
<body style="overflow: hidden; margin-left: 20px;" spellcheck="true">
<table style="width: 100px;">
<td>
<div id="mydiv" style="width: 350px; height: 200px;">
<input onclick="callService()" type="submit" value="Call Service">
</div>
</td>
</tr>
</tbody>
</table>

</body>
</html>


Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>