Issue
Web Service addition Script Web Service
Product Line
EcoStruxure Building Operation
Environment
StruxureWare Building Operation site with release 1.2 or later
Cause
What are Web Services and how to add to my existing StruxureWare Building Operation site.
- How to add Script Web Service files and how to add to a project or site
- How to create values from Script Web Service Files
- How to add values to graphic that uses the values from Script Web Service
Resolution
Wikipedia: A Web Service is a method of communication between two electronic devices over the web (internet). W3C: A "Web Service" as "a software system designed to support interoperable machine-to-machine interaction over a network."
Web Services:
1. are hardware, programming language, and operating system independent
2. Applications written in different programming languages and running on different platforms can seamlessly exchange data over intranet or the internet using Web Services
3. Web Service interfaces are supported in both the AS and ES
4. Like BACnet, Lon, and Modbus, you can create a Web Service interface.
- EWS Interface - EcoStruxure Web Services
- Script Web Service - Generic Consume via Script
- Simple XML Web Service - Rest Generic Consume via Binding Tool (Web Service addition Simple XML Web Service)
- SOAP Web Service - SOAP Generic Consume via Binding Tool (Web Service addition SOAP Web Service)
This article explains adding Sunrise and Sunset for a particular location data using Script Web Service:
-Select New...Interface...Web Service...Script Web Service
This first example is for a Calculation program for Results=A+B
-Enter the WSDL
- Service and Endpoint are auto-filled
- Not necessarily all the time
- IP Cameras
-Script Web Services Interface:
-Script Programs can bind to the web service with the "Webservice" declaration.
-When the name bound service is typed and a "." is put after it, intellisense drop down will show the available methods
- WSDL file is brought into the database
- Drop down methods become available even if the URL of the WSDL is not
-The web service capabilities can be used within the code for manipulation, data gathering, or whatever else.
-Script Web Services Post and Gets
-Script programs can send requests directly to a web service with the SendWebRequest keyword.
-The syntax requires 5 specific arguments
- BaseURL - URL that will be processing the message
- Method - Method of processing the POST and GET (dictated by URL)
- Headers - Defines certain parameters that are meaningful to the URL (IsMobileApp:True;IsAndroidClient:True)
- Content-Type - Defined by the URL
- Message - What is actually being sent to the URL
-Script Web Services - Considerations
-Bindings to a web service require a recompile
-Display of captured information will get localized
Next, Create a Script Program for Calculations
Here is a simple script program which defines the calc and values
The below shot is the values A=12, B=3, and the Results of the calculation.
Below are the binding for the Script Calc program to the Values
The below shot is the binding of the Calc program to the Script Web Service
The results are a calculation in which we supply value A and B and the Script Web Service performs the calculation with results of 15.
We can change the value of A to from 12 to a value of 13 which Results in 16 as shown in the shot below.