Share
Explore

Programming Distributed and Edge Computing Systems with a Microservices Client using SOAP/WSDL and REST-API

Pre-requisites:

Introduction to TypeScript

Distributed Systems are a collection of autonomous computing elements that appear to the users as a single coherent system. They are an essential aspect of current computing trends and are at the heart of many business, telecommunication and scientific applications.
Edge Computing, on the other hand, is a distributed computing paradigm that brings computation and data storage closer to the location where it is needed, to improve response times and save bandwidth.

Distributed Systems

Characteristics

Distributed systems have several distinct characteristics. They are:
Concurrency of Components: Multiple events are happening simultaneously in different parts of the system.
Lack of a Global Clock: There's no single timekeeper in the system, and different parts of the system can have different notions of time.
Independent Failures: Each component in the system can fail independently, without leading to the system as a whole failing.

Advantages

The advantages of distributed systems include performance, reliability, and scalability. The distributed system allows you to have a system that can scale up (or down) as your needs change.

Edge Computing

Edge computing is a networking philosophy focused on bringing computing as close to the source of data as possible in order to reduce latency and bandwidth use. It can deliver faster response times and better user experience while also reducing costs.
The main advantages of edge computing are:
Reduced latency
Lower bandwidth usage
Improved privacy and security

Lab: Serving and Consuming SOAP Objects Using TypeScript

Pre-requisites

This lab requires:
Node.js and npm installed
Basic knowledge of TypeScript and SOAP

Step 1: Setup the Project

Create a new directory for the project and initialize it with npm.
mkdir soap-server-client
cd soap-server-client
npm init -y

Step 2: Install Dependencies

We will use soap npm package to create SOAP server and client.
npm install --save soap typescript ts-node

Step 3: Create a SOAP Server

Let's create a new file server.ts and write a simple SOAP server that provides weather information for different cities.
import { soap } from 'soap';

const service = {
WeatherService: {
WeatherPort: {
getWeather: (args: { city: string }) => {
const cityWeathers = {
'San Francisco': 'Sunny',
'Los Angeles': 'Hot',
'Seattle': 'Rainy',
'Denver': 'Snowy'
};
return cityWeathers[args.city] || 'Unknown';
}
}
}
};

const xml = require('fs').readFileSync('weatherService.wsdl', 'utf8');
const server = http.createServer((req, res) => res.end('404: Not Found: ' + req.url));
server.listen(8000);
soap.listen(server, '/wsdl', service, xml);

Step 4: Create a SOAP Client

Next, we'll create a SOAP client in a new file client.ts to consume the SOAP service.
import { soap } from 'soap';

const url = 'http://localhost:8000/wsdl?wsdl';
const args = { city: 'San Francisco' };

soap.createClient(url, (err, client) => {
client.getWeather(args, (err, result) => {
console.log(`Weather in ${args.city}: ${result}`);
});
});

Step 5: Run the Server and Client

Now you can run the server and client using the ts-node command.
npx ts-node server.ts
npx ts-node client.ts
You should see the console output Weather in San Francisco: Sunny.

Conclusion

In this lab, you've learned how to create a SOAP server and client using TypeScript and Node.js. You've also seen how SOAP can be used to enable communication between applications over a network. This is just a simple example, but SOAP is capable of handling much more complex interactions, including those in distributed and edge computing environments.


Student Lab Learning Workbook: Node.js TypeScript for SOAP Objects and Web Services Description
Learnng Outcomes: Write Node.js TypeScript to Serve and Consume SOAP Objects and Use Web Services Description Language WSDL Using TypeScript.
Make an application that mashes up Google Maps API calls and OpenWeather API calls.

Objective: This workbook aims to teach you how to write Node.js TypeScript code to serve and consume SOAP Objects and use Web Services Description Language (WSDL) using TypeScript. We will also demonstrate how to mash up Google Maps API calls and OpenWeather API calls.
Chapter 1: Introduction to SOAP, WSDL, and TypeScript
SOAP is a protocol for exchanging structured information in web services using XML, while WSDL is an XML-based protocol for information exchange in decentralized and distributed environments. TypeScript is a statically typed superset of JavaScript, which compiles down to plain JavaScript [1].
Chapter 2: Setting up your TypeScript environment
Before we dive into writing TypeScript code, let's ensure your environment is set up correctly. To do this, you'll need to install WSDL TSClient, a library that generates TypeScript code and SOAP from a WSDL file [2].
Chapter 3: Consuming SOAP Objects with TypeScript
Once you've set up your environment, the next step is to write TypeScript code to consume SOAP Objects. This can be done by running a SOAP request. You may encounter issues while compiling the code, but with practice and troubleshooting, you'll become proficient [3].
Chapter 4: Using Web Services Description Language (WSDL) with TypeScript
In this chapter, we'll guide you through using WSDL with TypeScript. You'll learn how to generate a soap client with TypeScript definitions from a WSDL file using the WSDL TSClient library [2].
Chapter 5: Mashing up Google Maps API and OpenWeather API calls
To wrap up our workbook, we're going to create a practical example where we mash up Google Maps API calls and OpenWeather API calls. This will demonstrate the power and flexibility of using TypeScript in conjunction with SOAP and WSDL.
Remember, practice makes perfect. Keep experimenting with different SOAP objects and WSDL files to enhance your understanding and proficiency. Happy coding!
Note: This content is based on the information found in the web search results [1, 2, 3].
References:
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.