ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Mobile specific functions / Background task functions
  • Using a Webservice
DeclareWebserviceContext (Example)
Using a Webservice
This example is used to start a Webservice with all the required initializations.
//----Global declarations of the WebService
// Client name
gsClientName is string
// Manage the client name:
// if the lient name is alreay specified,
// it means that the user is already authenticated
DeclareWebserviceContext(gsClientName)
//---- Global Connection procedure to the Webservice,
// to be called once to initialize the Webservice
PROCEDURE Connection(sUser, sPassword)
// Check that the client exists
IF NOT HReadSeekFirst(CLIENT, NAME, sUser) THEN
RESULT False
ELSE
// Checks the password
IF CLIENT.PASSWORD = sPassword THEN
// Stores the client name
// in the variable stored by DeclareWebServiceContext
gsClientName = sUser
RETURN True
ELSE
RESULT False
END
END
// ---- Global check procedure
// if a connection was established with a valid user/password
PROCEDURE CheckConnection()
IF gsClientName = "" THEN RESULT False ELSE RESULT True
//----Global procedure that requires a connection (with the connection method)
PROCEDURE Calc(nParam1 is int, nParam2 is int)
// Check that the connection was established
IF NOT CheckConnection() THEN ExceptionThrow(1, "Invalid connection/authorization")
// Connection OK, performs the calculation
nResult is int
nResult = nParam1 + nParam2
RESULT nResult
Minimum version required
  • Version 16
Comments
Click [Add] to post a comment

Last update: 05/26/2022

Send a report | Local help