AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Funciones WLanguage / Comunicación / Servicios web
  • Operating mode
  • Special case: using an intermediate WebService
WINDEV
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
Allows you to declare a list of variables whose value will be persistent between successive calls to a web service. This function indicates the variables that will be saved and restored during each call to the web service. This gives you the ability to manage a context in the web service.
The management of contexts is performed on disk. For more details, see Generate a Webservice.
DeclareWebserviceContext is taken into account when running the web services 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 "Initialization in pre-launched session mode" event.
Caution:
  • This function is intended to the developers with a good knowledge of WINDEV/WEBDEV.
  • By default, a REST web service does not have a context. Therefore, this function cannot be used in a REST web service.
// -- Project "Initialization" event 
gnNumCurrentProduct is int = 1

// Indicate that the value of gnNumCurrentProduct must be saved
// whenever the web service is called
DeclareWebserviceContext(gnNumCurrentProduct)

// During the next calls to the web service:
// - 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)
Sintaxis
<Result> = DeclareWebserviceContext(<Variable name 1> [, <Variable name 2> [... [, <Name of variable N>]]])
<Result>: Boolean
  • True if the specified variables have been restored,
  • False otherwise (during the first call to the web service for example).
<Variable name 1>: Variable type
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 web service.
<Variable name 2>: Variable type
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 web service.
<Name of variable N>: Variable type
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 web service.
Observaciones

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 web service is called can be retrieved during the next call. Variables previously passed are automatically saved again.
  • Variables of simple type (integer, string, etc.) are managed, as well as variables of structure, class, array or associative array type.
  • Fixed arrays, global class members, associative arrays of local structures and advanced WLanguage types (such as Connexion variables) are not supported.

Special case: using an intermediate WebService

In some cases, you may have to use an intermediate web service to use the variables.
Let's study the following case:
  • A "WS1" web service uses DeclareWebserviceContext for a global variable named "globalString". This web service 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 web service "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 web service, use an "EcritLit()" function that does "WS1.Ecrit()" and "WS1.Lit()" in the same processing.
Componente: wd300awws.dll
Versión mínima requerida
  • Versión 16
Esta página también está disponible para…
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 25/03/2025

Señalar un error o enviar una sugerencia | Ayuda local