如何在React js中调用Soap?

我已经尝试了几种方法通过Reactjs进行Soap调用。 但是我总是在每个方法上都面临一些错误。 有人可以帮我一下,或者给我提供一个小的工作例子,以便我可以参考吗?

我曾尝试使用npm soapeasysoap软件包,但是我无法成功。 任何工作的例子是非常appriciated。 我也尝试了以下的方式,但它也无法正常工作。

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); 

npm soapeasysoap都是Node.js包,这意味着它们在服务器运行,而不是在ReactJS所在的客户机上运行。

所以,如果你想从客户端调用SOAP服务,你可以尝试纯JavaScript的例子或使用第三方工具,如jQuery的肥皂 。

希望这可以帮助 :)