This sample demonstrates how to build a custom connector for wmio. It includes as well an E2E scenario, where this connector is used.
The E2E scenario demonstrate how webMethods.io and Cumulocity can be used to build a fleetmanagment. The simulator of the Daimler Connecte Vehicle site simulates a daimer car. The reference data of the car as as the dynamic data: fuel status, location, mileage can be tramsmitted to Cumulocity IoT. The integration between these two API is achieved using the webMethoods.io platform. The E2E scenario is as follows:
The connector call the connected vehicleexperimental API. This API is secured with OAuth 2.0. Therefore a oauth2 provider needs to be created. The specific documentation on how this works is availalble under: https://developer.mercedes-benz.com/apis/connected_vehicle_experimental_api/docs#_authentication
The relevant integration flow to create a vehicle in cumulocity IoT looks as follows. This flow uses the following connectors:
- Cumulocity CreateVehicle:
- Step 1: Select Functional Area: Inventory
- Step 2: Select the Operation: Select the Operation
- Cumulocity UpdateExternalId:
- Step 1: Select Functional Area: Identity
- Step 2: Select the Operation: Create an External ID
- Connected Car:
- Getvehicles
- Getvehiclesbyid
The relevant integration flow to update the location in cumulocity IoT looks as follows. This flow uses the following connectors:
- Cumulocity GetIdByExternalId :
- Step 1: Select Functional Area: Identity
- Step 2: Select the Operation: Get An External ID
- Cumulocity Update Location:
- Step 1: Select Functional Area: Events
- Step 2: Select the Operation: Create an new event.
- Connected Car Getlocation:
- Getlocation
The relevant integration flow to update the mileage in cumulocity IoT looks as follows. This flow uses the following connectors:
- Cumulocity GetIdByExternalId :
- Step 1: Select Functional Area: Identity
- Step 2: Select the Operation: Get An External ID
- Cumulocity CreateOdometerMeasurement:
- Step 1: Select Functional Area: Measurements
- Step 2: Select the Operation: Create an new measurement.
- Connected Car Getodometer:
- Getodometer
The integration flow is triggered through a webhook:
NOTE: Since the vehicle simulation needs to be updated in a shorter frequency than 5 minutes (minimum for wmio standard scheduled trigger) an external phython script is provided https://github.com/SoftwareAG/wmio-connector-connectedcar/blob/master/resources/trigger_update.py . This script triggers the webhooks every 20 seconds.
- Register for Cumulocity IoT account: https://www.softwareag.cloud/site/index.html#/
- Register for webMethods.io integration account: https://www.softwareag.cloud/site/index.html#/
- Register for an developer account to use the Daimler Connected Vehicle (experimental) API: https://developer.mercedes-benz.com/
- Login to https://developer.mercedes-benz.com/
- Open console: https://developer.mercedes-benz.com/console
- Register your app and
Client ID
andClient Secret
. Leave the fieldRedirect URLs
empty. This needs to be filled out whit information generated in a later step.
The following screenshot shows the UI in the daimler developer portal:
- After login access simulator: https://car-simulator.developer.mercedes-benz.com
- Define simulation for your vehicle, as shown below:
The connector allows the following actions:
- getlocation: For getting the latest location of an vehicle by id
- getodometer: For getting the latest mileage of an vehicle by id
- getvehiclebyid: For getting the reference data (name, model, ...) of an vehicle by id
- getvehicles: For getting the list of all vehicles (simulator only lets you generate one vehicle) These actons are to used in the E2E workflow in webmethios.io.
Chech out information for npm modul wmiocli: https://www.npmjs.com/package/@webmethodsio/wmiocli and install modul
>npm i @webmethodsio/wmiocli -g
>wmio login
Enter Tenant URL eg: (https://wmiodemo.webmethods.io): https://YOUR:WEBMETHODS.IO-URL
Enter Email: E_MAIL
Enter Developer Key: ************************************
Loading...
[SYSTEM:] Successfully logged in.
>cd source
>npm install
>wmio auth
? Select auth type oauth
? Select one of the type create new
? Select type of Oauth OAuth2
Please provide name for your oauth: mydaimlerprovider
[TENANT:USER] OAuth configuration file created successfully. Kindly populate the oauth.json file
[TENANT:USER] Kindly set redirect url as https://YOUR:WEBMETHODS.IO-URL/auth/oauth/mydaimlerprovider__XXXXXXXX/XXXXXXXXXXXXXXXXXX/return in your Oauth Application
The returned URL needs to is written as "redirectURL" in authentication.js. Nothing needs to be modified in this file.
Another file oauth.json
is generated.
- Back up this file by renaming
oauth.json
tooauth.json_gen
. - copy the value of
redirectURL
from the newly renamed fileoauth.json_gen
- and place it in - the by git provided - file
oauth.json_template
in line 49
"redirectURL": "TO_BE_UPDATED"
- update value with the value from the Daimler developer console:
"clientId": "TO_BE_UPDATED",
"clientSecret": "TO_BE_UPDATED",
- finally save this file as
oauth.json
- you need to go back to your app in the Daimler developer portal and add the redirect URL in the web console in the field
Redirect URLs
.
Now you are ready to deploy yor authprovider
>wmio oauth deploy
>wmio deploy
[TENANT:USER] Registering Connector..
[TENANT:USER] Connector Registered Successfully
...
Now that the connector is uploaded you can use it to build an integration flow as shown on the screenshot in the beginning.
These tools are provided as-is and without warranty or support. They do not constitute part of the Software AG product suite. Users are free to use, fork and modify them, subject to the license agreement. While Software AG welcomes contributions, we cannot guarantee to include every contribution in the master project.
Contact us at TECHcommunity if you have any questions.