简体   繁体   English

在仅JavaScript的环境中实现肥皂

[英]Implementing soap in javascript only environment

I am trying to use soap as the backend services and provide data for my app. 我正在尝试使用肥皂作为后端服务,并为我的应用提供数据。

My question is if we only use javascript framework (ex: Ember, Angular) without server side languages (ex: php) 我的问题是,如果我们仅使用JavaScript框架(例如Ember,Angular)而不使用服务器端语言(例如php)

Is that possible to implement it? 可以实现吗?

Thanks a lot! 非常感谢!

You cannot create SOAP services using javascript framework without using any server side languages. 如果不使用任何服务器端语言,则无法使用javascript框架创建SOAP服务。 It is only possible to access SOAP WSDL from java script. 从Java脚本只能访问SOAP WSDL。 Here goes the example : 这里是例子:

<script type="text/javascript">
    function soap() {
        var xmlhttp = new XMLHttpRequest();
        xmlhttp.open('POST', 'https://testSoapURL.com/', true);

        // build SOAP request
        var service =
            '<?xml version="1.0" encoding="utf-8"?>' +
            '<soapenv:Envelope ' + 
                'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
                'xmlns:api="http://127.0.0.1/Integrics/Enswitch/API" ' +
                'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' +
                'xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">' +
                '<soapenv:Body>' +
                '<api:some_api_callsoapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">' +
                        '<username xsi:type="xsd:string">login_uName</username>' +
                        '<password xsi:type="xsd:string">pass</password>' +
                    '</api:some_api_call>' +
                '</soapenv:Body>' +
            '</soapenv:Envelope>';

        xmlhttp.onreadystatechange = function () {
            if (xmlhttp.readyState == 4) {
                if (xmlhttp.status == 200) {

                    alert('done check the response');
                }
            }
        }
        // Send the POST request
        xmlhttp.setRequestHeader('Content-Type', 'text/xml');
        xmlhttp.send(service);
        //Now send the request        
    }
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM