ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Communication / Web services
  • Operating mode
  • Special case: Using an intermediate WebService
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Allows you to declare a list of variables whose value will be persistent between the successive calls to a Webservice. This function indicates the variables that will be saved and restored during each call to the webservice. This gives you the ability to manage a context in the webservice.
The management of contexts is performed on disk. For more details, see Generating a Webservice.
DeclareWebserviceContext is taken into account when running the Webservices deployed on the WEBDEV Application Server (Webservice in .AWWS).
It is recommended to use this function in the "Initialization" event of the project (for project variables) and/or in the initialization code of classes or sets of procedures. In most cases, this function must be used in the process where the variables are declared and initialized.
If your project uses pre-launched sessions, this function must not be used in the project initialization event. This function must be used in the "Initialize project after connecting to the site" event.
Caution:
  • This function is intended to the developers with a good knowledge of WINDEV/WEBDEV.
  • By default, a REST Webservice does not have a context. Therefore, this function cannot be used in a REST Webservice.
// -- Project "Initialization" event
gnNumCurrentProduct is int = 1
 
// Indicate that the value of gnNumCurrentProduct must be saved
// whenever the Webservice is called
DeclareWebserviceContext(gnNumCurrentProduct)
 
// During the next calls to the Webservice:
// - either the value of gnNumCurrentProduct is not retrieved
// and it is automatically reinitialized with "1"
// (for example, during the first call by a new client)
// - or the value of gnNumCurrentProduct is retrieved and used
// (for example, during successive calls by the same client)
Syntax
<Result> = DeclareWebserviceContext(<Name of variable 1> [, <Name of variable 2> [... [, <Name of variable N>]]])
<Result>: Boolean
  • True if the specified variables have been restored,
  • False otherwise (during the first call to the Webservice for example).
<Name of variable 1>: Type of variable
Name of the first variable that will be saved at the end of the display. The value of this variable will be retrieved during the successive calls to the Webservice.
<Name of variable 2>: Type of variable
Name of the second variable that will be saved at the end of the display. The value of this variable will be retrieved during the successive calls to the Webservice.
<Name of variable N>: Type of variable
Name of Nth variable that will be saved at the end of display. The value of this variable will be retrieved during the successive calls to the Webservice.
Remarks

Operating mode

  • The context is always saved on disk and transmitted via a SOAP header.
  • DeclareWebserviceContext uses contexts on disk. The values of variables are always restored.
  • The total size of values for the different variables is not limited.
  • DeclareWebserviceContext can be used for sensitive data (user password, for example).
  • If two variables are saved with the same name (one in the project and the other one in a page for example), the two variables are stored independently.
  • DeclareWebserviceContext returns False if one of the variables was not restored.
  • All the variables passed to DeclareWebserviceContext when a Webservice is called can be retrieved during the next call. The variables that were passed beforehand are automatically saved again.
  • The simple variables (integer, string, ...) are supported as well as the structure, class, array or associative array variables.
  • Are not supported: the fixed arrays, the global members of classes, the associative arrays of local structures and the advanced types of WLanguage (like the Connection variables for example).

Special case: Using an intermediate WebService

In some cases, you may have to use an intermediate Webservice to use the variables.
Let's study the following case:
  • A "WS1" Webservice uses DeclareWebserviceContext for a global variable named "globalString". This Webservice contains 2 functions:
    • "Write(param)" that assigns "param" in "globalString"
    • "Read()" that returns the content of "globalString".
  • A client executable, consuming WS1, calls "WS1.Write("Hello")", then "WS1.Read()" retrieves the string sent.
  • An intermediate Webservice "WS2", consuming WS1, contains 2 functions:
    • "Write(param)" that calls "WS1.Write()".
    • "Read()" that calls "WS1.Read()".
  • A client executable, consuming WS2, calls "WS2.Write("Hello")", then "WS2.Read()" DOES NOT retrieve the string sent.
Solution: In the WS2 Webservice, use a "WriteRead()" function that runs "WS1.Write()" and "WS1.Read()" in the same process.
Component: wd290awws.dll
Minimum version required
  • Version 16
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 06/21/2023

Send a report | Local help