Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a Soap call in React js?

I have tried a few ways to make a Soap call through Reactjs. But I am always facing some error in every approach. Can someone help me out here or kindly provide me with any small working example so that I could refer it?

I had tried using the npm soap and easysoap package but I am not able to succeed. Any working example is greatly appriciated. I also tried the following way but it too doesn't work.

var xmlhttp = new XMLHttpRequest();
xmlhttp.open('GET', '{My soap endpoint}', true);

// build SOAP request
var sr =
    '<soap:Envelope xmlns:soap="{My soap request}"'

xmlhttp.onreadystatechange = function () {
    if (xmlhttp.readyState == 4) {
        if (xmlhttp.status == 200) {
            alert('done. use firebug/console to see network response');
        }
    }
}
// Send the POST request
xmlhttp.setRequestHeader('Content-Type', 'text/xml');
xmlhttp.send(sr);
like image 982
Mr.T.K Avatar asked Jan 19 '17 12:01

Mr.T.K


People also ask

How do you call a SOAP webservice in react JS?

Both npm soap and easysoap are Node. js packages, which means that they run on the server but not on the client, where ReactJS lives. So, if you want to call a soap service from the client, you can try this example of pure javascript or use a third-party tool like jquery-soap.

Can I use react JS with Python?

This is because React uses a very different syntax and data structures than Python, which makes it difficult for Python developers to adapt to. In this article, we'll map out a road plan for getting started with React, as well as the core prerequisites for diving into React as a Python developer.


1 Answers

Both npm soap and easysoap are Node.js packages, which means that they run on the server but not on the client, where ReactJS lives.

So, if you want to call a soap service from the client, you can try this example of pure javascript or use a third-party tool like jquery-soap.

Hope this helps :)

like image 62
cristianzamar Avatar answered Sep 16 '22 17:09

cristianzamar