Using SOAP in a JavaScript-exclusive setting

I'm looking into utilizing SOAP as the backend services to supply data for my application.

My query pertains to the feasibility of implementing this with just a JavaScript framework like Ember or Angular, without utilizing server-side languages such as PHP.

Is it possible to achieve this functionality?

Thank you in advance!

Answer №1

To create SOAP services using a JavaScript framework without the use of any server-side languages is not possible. The only way to access SOAP WSDL from JavaScript is through Java script. Here is an 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>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Can the loading of the window be postponed?

I've created a script that displays a message when the user first visits the website. The message then fades out, followed by another section fading in after a short delay. $(window).load(function() { $(".greeting").delay(1500).fadeOut("500"); ...

Encountering an Issue while Deploying a create-react-app to Heroku

Despite trying various online remedies, I am still encountering an error while attempting to deploy a simple React.js app on Heroku. The app successfully builds when I execute git push heroku master, but upon opening it, I consistently receive an applicati ...

Here are the steps to pass the selected dropdown value to ng-repeat for ordering:

I have a dropdown box with options for filtering data in an ng-repeat by different criteria. How can I pass the selected value from the dropdown to the ng-repeat orderby? Here is my dropdown: <select name='filter_range' id='filter_range ...

Is it possible to execute a function within an HTML page simply by clicking on it?

As someone who is new to the world of HTML, CSS, and JS, I'm currently facing a challenge: On my website's page1.html, I have implemented a feature that allows users to sort different articles on the page by selecting a sub-menu from the navigat ...

"Implementing an AngularJS factory that returns a State object instead of typical JSON data fetched from

I have created two factories and I am calling the first one from the second one in my controller. However, instead of receiving JSON data, I am getting data as $$State. I am new to AngularJS and have tried multiple solutions but have not been able to resol ...

Why does clicking to add to an existing array only result in the array being cleared instead?

Need help with an AngularJS question relating to scope binding and click events. I want to add one value on the first click and another value on the second click, but it's only returning an empty array and filling the first value again. Why is that ha ...

Returning Props in Dynamic Components with Vue 3

Exploring the capabilities of Vue3's Dynamic Component <component>, I am currently working with this setup: Component 1: <template> <div> <h1> Name Input: </h2> <Input :model="props.name" /> ...

Retrieve a variable from the context and assign it to the Angular scope

I'm having trouble accessing the sourcePath in the controller $scope. This is the code I have: (function() { var sourcePath; sourcePath = 'app/assets/javascripts/shared/controllers/some_controller.coffee'; angular.module("shared"). ...

Tips for improving the readability of my code

This code snippet pertains to handling a POST request in Express.js with MongoDB integration. router.post('/', function(req, res){ var data = req.body; Tag.find({name: data.name}).limit(1).exec( function(err, result){ if(err) { // ...

Modifying the id attribute dynamically using jQuery during runtime

In my project, I have a submit button with the id of "submit" that is used to save new records. // Function to add a new customer record $("#submit").click(function() { var data = $.param($("#form").serializeArray()); ...

Creating a Powerful Application with Typescript and NodeJS

Currently, I am attempting to utilize Got with Typescript and ESM. With Got being written in Typescript itself, I anticipated a seamless integration. Alas, even after diligently following this comprehensive guide authored by the creator of Got, I am unable ...

When launching JQuery UI Tabs in a new browser tab using ajax, the HTML from the ajax response will be immediately shown

I am currently in the process of upgrading from JQuery UI 1.8.14 to JQuery UI 1.10. Previously, when using v1.8.14 code, opening a tab in a new browser tab would cause the entire page to reload, activating the default tab (tabIndex=0). However, I am faci ...

Tips for verifying whether a variable is a node?

Curiosity strikes me: how can I determine if the variable myVar is a node? I could simply check myVar.nodeType, but that might be misleading with something like {nodeType:1} So, naturally, I start to wonder if there's a way to do this instead: myVa ...

Creating a Halo (external outline) for a circular sector in THREE.JS

I'm working on adding a halo (external black outline) to certain shapes in three.js. While I was able to achieve this easily with rectangles and circles, I am facing challenges with circular sectors (not full circles). Here is my current attempt: It ...

What is the reason that .bin/www is recognized as a JavaScript file even though it does not have the .js extension when utilizing express-generator

Can you explain why .bin/www is recognized as a JavaScript file by express-generator even without the .js extension? Whenever I create a bin/ folder with a www file inside, it's automatically identified as a JavaScript file despite the missing .js ex ...

The HTML anchor tag paired with the italic tag is a powerful combination for

Here is some example code: <a href="#"> <i class="some-bg" /> Some Text </a> Along with some Javascript: $("a").bind("touchstart", function (e) { e.preventDefault(); console.log("Tag: " + e.target); console.log("Tag Nam ...

The reason behind a loop being caused by an IF statement

Here is a snippet of code that I'm trying to understand: ReactDOM.render(<Change />, document.getElementById('app')); function Change() { const [i, setI] = React.useState(0); let rnd = 9; if (i !== rnd) { setTime ...

Unable to make changes to a file authored by a different user within Firestore using Vue.js / Firestore

I appreciate any assistance in advance, as this issue has been causing me a lot of frustration! Currently, I am adhering to the firestore data model where users are able to create their own documents associated with their userID. This ensures that users c ...

Arrange divs in a grid layout with evenly distributed dynamic spacing

I am not a big fan of bootstrap, so I was wondering if it is possible to achieve the layout without using it. I have 6 divs that I want to arrange in 2 rows and 3 columns. I need the space between each row/column to be precise. While I can calculate this ...

Error encountered while running `ionic build android`. To view the stack trace, try running the command with the `--stacktrace` option

I've gone ahead and installed the sdk, as well as added JAVA_HOME, so why am I encountering this error when executing ionic build android? It seems that you haven't accepted the license agreements for certain SDK components: [Android SDK Platf ...