PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • 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/iPadApple WatchUniversal Windows 10 AppWindows Mobile
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. See Generating a Webservice for more details.
DeclareWebserviceContext is taken into account when running the Webservices deployed on the WEBDEV application server (Webservice in.AWWS).
We recommend that you use this function in the project "Initializing" event (for the project variables) and/or in the initialization code of sets of procedures or classes. In most cases, this function must be used in the process where the variables are declared and initialized.
Versions 20 and later
If your project uses pre-launched sessions, this function must not be used in the event "Initializing" of the project. This function must be used in the event "Initializing the project after connection to the site".
New in version 20
If your project uses pre-launched sessions, this function must not be used in the event "Initializing" of the project. This function must be used in the event "Initializing the project after connection to the site".
If your project uses pre-launched sessions, this function must not be used in the event "Initializing" of the project. This function must be used in the event "Initializing the project after connection to the site".
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 "Initializing" 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 first 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.
<Name of variable 2>: Type of variable
Name of second 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.
<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 is using the 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 during a call to a Webservice 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 is using 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 : wd240awws.dll
Minimum version required
  • Version 16
This page is also available for…
Comments
Click [Add] to post a comment