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)

Send a SOAP Request via Javascript

(0) ShareShare
ReportReport
Posted on by 605

Hi All,

I am trying to send a Soap request via Javascript in Dynamics CRM 2016 online.

here is my JS:

var xmlhttp = new XMLHttpRequest();

//replace second argument with the path to your Secret Server webservices
xmlhttp.open('POST', 'www.test.com/.../testservice2.asmx', true);
var soapData = '<soapenv:Envelope xmlns:soapenv="schemas.xmlsoap.org/.../envelope" xmlns:hs="www.holidaywebservice.com/HolidayService_v2">'
+ '<soapenv:Body>'
+ '<hs:GetHolidaysAvailable>'
+ '<hs:countryCode>Canada</hs:countryCode>'
+ '</hs:GetHolidaysAvailable>'
+ '</soapenv:Body>'
+ '</soapenv:Envelope>';

xmlhttp.setRequestHeader('Content-Type', 'text/xml; charset=utf-8');

xmlhttp.setRequestHeader('SOAPAction', 'http://www.testwebservice.com');
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4) {
alert(xmlhttp.responseText);
}
};

//send the SOAP request
xmlhttp.send(soapData);

Response is always null for me. I tried the same in Postman i am able to get the response. But when I try the same via CRM Javascript i get NULL as reponse.

Regards,

Rahul

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    imayur Profile Picture
    630 on at

    Hi,

    First check your Soap XML string is valid or not. If its valid try using sending request using jQuery Ajax, refer below snippet.

    var myServiceUrl = 'www.someurl.com/service.svc';

    var mySoapXml = "mysoapxml";

      $.ajax({

             type: "POST",

             url: myServiceUrl ,

              contentType: "text/xml",

              dataType: "xml",

              data: mySoapXml,

               success:function(data, status, req) {

               if (status == "success")

                   alert(req.responseText);

           },

              error: function(data, status, req) {

              alert(req.responseText + " " + status);

           }

                   });

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