web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

WEbservice call Issue

(0) ShareShare
ReportReport
Posted on by 170

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>

*This post is locked for comments

I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans