Use parameters in the Web Service Address
- Last UpdatedSep 27, 2024
- 3 minute read
Parameters as Variables
Using variables in the address field allows the same basic web service connection to query a different result set, based on the variables used in the web service address itself. The variables can be tied to tag names to be set externally from an application. To convert any parameter to a variable, add the parameter within double angle brackets (<<..>>).
Example - Connect to the Open Weather Map Web Service
To request the weather forecast for a specific city, for example, London, enter the the following URL in the Web Service Address field.
http://api.openweathermap.org/data/2.5/weather?q=London&appid={Your API Key}
Note: The OpenWeather API requires a valid API Key to be submitted with the appid URL parameter as an identification of the caller. The API keys linked to an account are used to take count of the calls made to the OpenWeather platform, and to enforce the limit of free API calls permitted for the account. Visit the OpenWeather website to acquire your own API key for use with this example.
To convert the address in order to query any city, replace the city name 'London' with a variable - <<City>>. The web service address changes to:
http://api.openweathermap.org/data/2.5/weather?q=<<City>>&appid={Your API Key}
Upon analyzing the web service address, the URL Parameters grid populates the Tag Name column with the <<City>> variable.
To get the weather forecast of any city of your choice, set the Default Value of <<City>> variable to the city name and execute the test operation. URL Parameters are exposed as tags which can be set by consuming applications. For instance, the <<City>> parameter is accessible via the item name $op$ww.get.query.<<City>>.

Parameters as References
When a web service address is analyzed, the WEBSVC Communication Driver exposes each parameter from the result set as references that can be easily addressed individually.
Example - Connect to the Online Web Service
To connect to the online web service, enter the online web service query in the Web Service Address field.
Note: You must have an account with AVEVA Insight to complete these steps. If you do not have a AVEVA Insight account, go to the AVEVA Insight site (https://online.wonderware.com) and select Sign Up.
Use Basic Authentication
-
Enter the web service address: https://online.wonderware.com/s/<<Solution_ID>>/apis/Historian/v2/Tags.
Each account has a unique Solution_ID.The Solution_ID entered within double angle brackets '<<..>>' is displayed as a parameter in the URL Parameters grid. To use the Solution_ID parameter as a variable (for instance, tecpny), set the parameter default value to tecpny, in the URL Parameters grid.
Note: When using basic authentication, the web service address must include the Solution_ID as part of the URL.
-
Select Analyze.
-
In the Authentication Credentials section, select the Enable check box.
-
From the Authentication Type list, select Basic.
-
Enter the credentials used for the AVEVA Insight account in the Username and Password fields.
-
Select Connect.
Use OAuth Authentication
-
Enter the web service address: https://online.wonderware.com/apis/Historian/v2/Tags.
-
Select Analyze.
-
In the Authentication Credentials section, select the Enable check box.
-
From the Authentication Type list, select OAuth 2.0.
-
Enter the bearer token for the web service. The bearer token can be obtained from the API Key Authentication section of the AVEVA Insight website.
-
Select Connect.
Note: The OAuth 2.0 authentication uses a URL different from the web service URL.
Use Custom Authentication
-
Enter the web service address: https://online.wonderware.com/apis/Historian/v2/Tags.
-
Select Analyze.
-
In the Authentication Credentials section, select the Enable check box.
-
From the Authentication Type list, select Custom.
-
Edit the existing values of the Header, Body and Authentication grids.
-
In the Key column of the Body grid, enter the AppId and Secret in different rows.
-
In the Value column, enter the values for the AppId and Secret.
-
-
Enter the Authentication Server Address, and select Request Token.
-
The token populates in the Access Token field.