PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • 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
RESULT 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
This page is also available for…
Comments
Click [Add] to post a comment