- How To Connect To SOAP Services With JavaScript
- What is SOAP?
- What are the advantages of SOAP?
- How to Get Ext.Data.Store Up and Running with SOAP Data
- How to Load Data into the Store
- How to Customize SOAP Envelope and Body
- How to Create, Update and Destroy Requests
- How to Create Requests
- How to Update Requests
- How to Destroy Requests
- Should I use SOAP for data exchange?
- What’s your reaction?
- Written by Md. Ehsanul Haque Kanan
- Related Posts
- Leave a Reply Cancel reply
- Blog Categories
How To Connect To SOAP Services With JavaScript
Today, developers building modern web applications have a wide range of solutions to choose from. The options include a variety of languages and frameworks. There are also many web services options they can use. One of the most popular options is SOAP. Soap lets platform and language-independent web applications easily exchange data. In this post, we look at how to plug SOAP services into your application using our JavaScript web framework quickly.
What is SOAP?
SOAP stands for Simple Object Access Protocol. It is an XML-based protocol for accessing web services over HTTP. It is platform and language independent. This means you can use it with applications that have different programming languages without any hassle.
What are the advantages of SOAP?
- Compatible with different programming languages and platforms
- Supports built-in error handling
- Provides WS-security support to protect the web service
How to Get Ext.Data.Store Up and Running with SOAP Data
Getting Ext.data.Store up and running with SOAP data is very simple. Just follow these steps:
1. First, you have to define Blender and extend Ext.data.Store. Then define three fields: id, name, and price.
2. Next, you have to create the proxy. Then you have to define url, API, soapAction, operationParam and targetNamespace. You also have to create reader.
var store = Ext.create(‘Ext.data.Store’,
How to Load Data into the Store
To load your data, follow these steps:
1. First, call the store’s load method. Then add a parameter, called brand. It will create a SOAP request to GetBlenders, which is specified by the read property in the proxy api. Let’s assume that the GetBlenders SOAP operation requires a brand parameter. You can pass it to the store’s load method.
This code triggers a post to this URL:
2. Let’s assume that the response to your request looks like this:
3. Now, you can pass a callback function to store’s load method. It show you what the store’s record looks like after it is loaded.
console.log(store.getCount()); // 2 records were loaded.
console.log(store.getAt(0).get(‘name’)); // get the name field of the first record.
How to Customize SOAP Envelope and Body
To customize your SOAP envelope and body, follow these steps:
1. Use the developer tool on your web browser to analyze the outgoing request. You will find a HTTP post to this URL:
2. Analyze the request post body. The SOAP envelope looks like this:
3. Next, use this code, to change the soap envelope namespace prefix to “s“.
4. Now, to view the post body generated from the new templates, simply call the store.load() function with the specified prefix.
How to Create, Update and Destroy Requests
Create, update, and destroy requests work almost the same as read requests. But there is a key difference. Read requests construct the SOAP body using a set of parameters. However, create, update, and destroy requests construct the SOAP body using a set of records.
How to Create Requests
1. To create a request, you have to make a new record by using Ext.create() function and define the required fields, like name and price:
var blender = Ext.create(‘Blender’,
2. Next, you have to add the record to the store. Then, call store.sync() method.
The code will result in an HTTP POST, which looks like this:
3. Now, it’s time to analyze the request post body. As, you can see, the name and price of the newly created record are into the SOAP body:
How to Update Requests
1. To update a record, simply change the value of the required field. For example, if you want to set the value of price to 200, use this line:
2. Now, you can synchronize the store with this code:
How to Destroy Requests
1. To destroy a record, you have to remove it from the store. Simply use this line:
2. Now, you can synchronize the store.
Should I use SOAP for data exchange?
SOAP is an XML based HTTP protocol. It is platform-independent. It enables you to interchange data between applications built with a variety of languages conveniently. Also, it is lightweight. So, you should consider using SOAP for exchanging data.
What’s your reaction?
Written by Md. Ehsanul Haque Kanan
Md. Ehsanul Haque Kanan is specialized in technical writing, UI/UX designing, and web development. Also, he is a machine learning enthusiast.
Related Posts
Leave a Reply Cancel reply
Blog Categories
- Rapid Ext JS 5
- Widget 1
- Angular 1
- React 5
- GRUI by Sencha 21
- React Grid 14
- Sencha Themer 10
- SenchaInspector 3
- Ext.NET 2
- WebTestIt 5
- ExtWebComponents 17
- ExtAngular 20
- 日本語 82
- Android 2
- Apple 2
- Applications 11
- Architect 56
- Charting & Drawing 2
- Cmd 54
- Community 1
- CSS3 1
- ExtReact 38
- Events 22
- Ext JS 520
- Google 3
- GXT 48
- HTML5 34
- HTML5 Scorecard 12
- Java 1
- JavaScript 84
- News 56
- Plugins 8
- Sencha Complete 9
- Sencha Space 1
- Sencha Test 52
- Sencha Test Tips 7
- Sencha Touch 129
- Sencha Touch Bundle 1
- SenchaCon 48
- Spotlight 35
- Support Tips 21
- Theming 23
- Training 16
- Tutorials 59
- Uncategorized 35
- Web Application Manager 2
- Webinar 12