Ceci est une ancienne révision du document !
LAB : Service Oriented Approach for IoT
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.
Requirements :
- Node RED (for example) under Docker : Node-Red
- Help abour Node-Red :
- Liste à puceyour own Node RED assembly : First use of Node RED
- your own Node RED Component with its Function : First Function in Node RED
SOA for IoT and WS-REST
Get started with curl
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.
Exercice: After Signin, test services like TexttoSpeech with curl.
Question: Look at IBM Watson IoT Plateform. What does it provide ?
WS-REST in Node-Red
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 :
- Use the http node from the input block to handle request from outside.
- Drag the http response node from the output block. This will output the payload of the msg as response of API.
- Now go to your browser and hit http://localhost:1880/users to use your WS-REST API.
Advanced Exercice: write your own REST server that getw an MQTT topic and provide it through a web service API. you can extend a past lab MQTT example to do that.
SOA for IoT and WS-SOAP
Get started with WS-SOAP
WS-SOAP in Node-Red
- Exercice: write your own client programm of a SOAP web service and node-red-contrib-soap package SOAP web service.
- Use GetGeoIP SOAP Web Services to easily look up countries by IP addresses.
- Exercice: test your own soap server with npm install node-red-contrib-soapserver (see https://www.npmjs.com/package/node-red-contrib-soapserver).
Soap server Usage
This package provides a node that can be used to start a Node-RED flow. The node is called soap server and listens on a configurable TCP port on the host on which Node-RED run. It is important that the port number be supplied as there is no default assumed. The listener is listening for an incoming SOAP/HTTP request. The WSDL that describes the SOAP server can be retrieved through an HTTP GET request using the /soap?wsdl URL and query parameters. For example:
http://<node-RED-Host>:<port>/soap?wsdl **.
The endpoint for the SOAP request is found at the same address
