Author : Jean-Yves Tigli - tigli@unice.fr
If Web Services are used for data exchange in classical distributed software, they are also used in cars, television sets, routers, printers, audio equipment, mobile phones, tablets, settop boxes, media players and is the internet transfer backbone for thousands ofcode software applications affecting billions of humans daily.
curl is used in command lines or scripts to transfer data.
Curl is mainly used to send/receive some HTTP messages with command lines. That's the reason why curl is well adapted for first tests of Rest services.
Lot of WS-REST API are available on the web. Big compagnies provide some Cloud of Services using this kind of access. For example the IBM Cloud provides its own list of services.
Look at a “text to speech” demonstration here
Exercice: After Sign up, test services like TexttoSpeech with curl. Find more details in a step by step tutorial here.
Question: Look at IBM Watson IoT Plateform. What does it provide ?
In fact, WS-Rest basicaly uses HTTP to communicate with some GET and POST HTTP commands.
Rest client
Exercice: Get current cities temperatures and display them use openweathermap
Drag the http request node from the output block. This will output the payload of the msg as response of remote web service API.
Create a client to get Weather Temperature from openweathermap with a WS-REST
use ThingSpeak for WS-Rest that provides a Web UI
The ThingSpeak server is install on https://sparks-vm24.i3s.unice.fr/. Sign up to start using ThingSpeak getting an ID and a Key for future ThingSpeak requests (see explainations Here (you can test ThingSpeak alone with curl).
Get consecutive temperatures for a city and display them in ThingSpeak using Node-Red like in the figure.
node-red_solution_assembly_export.rtf
Rest server :
So using basic HTTP nodes, we can developp a REST server that answers to GET requests and returns some values.
Exercice: To create a WS-Rest in Node-Red :
Advanced Exercice: write your own REST server that gets an MQTT topic and provides it through a web service API. You can extend a past lab MQTT example to do that.
http://www.dataaccess.com/ provide a list of WS-SOAP. The main initial difference between WS-REST and WS-SOAP was the explicit description of the WS-SOAP API in a WSDL format (Web Service Descrition Language).
Question: Thanks to
http://www.dataaccess.com/webservicesserver/NumberConversion.wso?WSDL
URI, display this description for NumberConversion WS-SOAP. Look at the different part of this XML file to understand the corresponding SOAP API. Test this WS-SOAP with
http://www.dataaccess.com/webservicesserver/NumberConversion.wso?op=NumberToWords
Soap client
Exercice: Create a WS-Soap Client to test your own WS-Soap server :
http://www.dataaccess.com/webservicesserver/NumberConversion.wso?op=NumberToWords
To do that in node-red you must install two packages :
use the manage palette to install them
Constrained Application Protocol (CoAP) is a specialized Internet Application Protocol for constrained devices, as defined in RFC 7252.
CoAP is a service layer protocol that is intended for use in resource-constrained internet devices, such as wireless sensor network nodes. CoAP is designed to easily translate to HTTP for simplified integration with the web, while also meeting specialized requirements such as multicast support, very low overhead, and simplicity.
Exercice : Answer to this question : why CoAP is much more adapted to Local Internet Network (on LAN) than Wide Internet Network (on WAN). What might be the solution to allow CoAP communications between distant places.
CoAP-CLI is a command line interface for CoAP, built on node.js and node-coap. Install it under a shell after Node-Red (or at least node.js) installation with : npm install coap-cli -g
Some examples to test are then available in https://github.com/reederz/node-red-contrib-coap.git Start observe_server.js, import client_flow.json to your Node-RED instance and start red.js…