Help / WLanguage / WLanguage functions / Communication / Webservices
  • Overview
  • How to make a Webservice available?
  • Creating the Webservice
  • Managing contexts
  • Generating the Webservice
  • Deploying a Webservice and running its test
  • Deploying a Webservice
  • Special case: Deploying a Webservice and running its test on the local computer
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WindowsLinuxPHPWEBDEV - Browser code
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Stored procedures
WINDEV and WEBDEV allow you to generate Webservices directly. Then, these Webservices can be used in the WINDEV, WEBDEV, WINDEV Mobile projects or in any other language.
A Webservice includes a set of functions WITHOUT interface. Indeed, this type of module being run on a server, there is no need to develop a user interface. Therefore, the webservice will include WLanguage functions organized in sets of procedures. These functions can handle a database (HFSQL, Oracle, AS/400, ...).
Caution: Deploying a WINDEV or WEBDEV Webservice requires the use of a WEBDEV Application Server. Via this distribution mode, the Webservices created with WINDEV/WEBDEV present several types of benefits:
  • Webservices deployed on a WEBDEV Application Server (compatible with all the Web servers).
  • Several modes for deploying the Webservice (physical media, FTP, Cloud).
  • Heavy workload possible.
  • Webservices that can operate on all the Windows versions (32 and 64 bits) as well as in Linux.
How to make a Webservice available?
To make a Webservice available, you must:
  1. Create a Webservice.
  2. Generate a Webservice.
  3. Deploy the Webservice on a WEBDEV Application Server.
Remark: To run the test of the Webservice, you have the ability to deploy it locally for test.
Creating the Webservice
To create a Webservice:
  1. Create a WINDEV or WEBDEV project whose type is Webservice or a Webservice configuration in an existing project.
    • When creating a project, select "SOAP or REST webservice".
    • To create a Webservice project configuration, go to the "Project" tab, "Project configuration" group, expand "New configuration" and select "Webservice".
  2. Create one or more sets of procedures:
    • In the project explorer, select the "Procedures" folder.
    • Select "New" in the context menu..
  3. Create the global procedures or the functions corresponding to the processes that must be performed on the server.
    // Global Addition procedure
    PROCÉDURE Addition(nNumber1 is int, nNumber2 is int)
    nResult is int
    nResult = nNumber1 + nNumber2
    RESULT nResult

    Each global procedure can be run by the WEBDEV Application Server.

    • If the parameters of the procedures have no type, they will be automatically received as Unicode character strings. Therefore, you must specify the type of the parameters that must be different from a Unicode character string.
    • The procedures can be marked as public or private. A public procedure can be used in the projects that will import the Webservice. A private procedure cannot be used in the projects that will import the Webservice (the procedure will not be visible in the project explorer). To mark a procedure as public or private, use the popup menu on the name of the procedure in the project explorer.
    • The procedures can return classes, structures, arrays of structures or arrays of classes. The returned arrays are limited to one dimension.
    Caution: The Webservice must have no GUI (no window, report, trace window or dialog box). It is also limited by the rights defined on the Web server ("Internet guest" account in Windows).
  4. Type (if necessary) the initialization code and the project closing code. These two codes will be respectively run when loading and when unloading the library of the Webservice.

Managing contexts

To keep the value of global variables during successive calls to a webservice, you have the ability to use a management of contexts. The management of contexts is performed on disk: the value of different variables is stored in a file on the server. A context identifier is used to retrieve the context stored during a next call to the webservice. This identifier is stored in a SOAP header on the client computer. This identifier guarantees the security of the data stored.
This operating mode is as follows:
  • The identifier is stored in a SOAP header. When using DeclareWebserviceContext, the WSDL is modified and it indicates that the format accepts a header section with a precise name and a specific format.
  • The client transmits this information.
    • During the first call, the value is empty, the server creates a new session.
    • If the value is missing, the server creates a new session.
  • The server returns the requested information.
To implement a management of contexts:
  1. Use DeclareWebserviceContext to store the desired variables. We recommend that you use this function in the initialization code of project (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.
    • The context is always saved on disk and transmitted via a SOAP header.
    • DeclareWebserviceContext uses the contexts on disk. The values of variables are always restored.
    • The total size of values for the different variables is not limited.
    • The DeclareWebserviceContext function can be used for the 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. The fixed arrays, the global members of classes and the associative arrays of local structures are not supported.
  2. To delete a specific variable from the context, you have the ability to use CancelWebserviceContext.
Remark: The WEBDEV administrator gives you the ability to configure the duration regarding the validity of webservice contexts ("Duration of webservice contexts" in the "Configuration" tab). As soon as the specified duration is exceeded, and if no new request was performed, the context file is deleted.
Generating the Webservice
To generate a Webservice:
  1. Select (if necessary) the configuration corresponding to the Webservice in the project explorer.
  2. Generate the Webservice:
    • On the "Project" tab, in the "Generation" group, click "Generate".
    • Click the generation icon in the quick access buttons.
  3. The Webservice generation wizard starts.
  4. In the wizard, specify:
    • the name of the Webservice. By default, the Webservice name corresponds to the name of the current project. You can change the name of the Webservice (the project name will not change).
    • the mode for passing parameters to the functions.
      Remark: We recommend that you use the direct setting of functions.
  5. Go to the next step.
  6. Select the elements that will be included in the Webservice. These elements correspond to anything but the interface elements (window, page, report, ...).
    Check the elements to include and the ones that will be called in the Webservice. You can:
    • Add elements
      Any type of file can be added to the list of elements inserted into the library: images, text files, etc.
    • Delete elements
      The corresponding files and their dependencies will be ignored in the library.
    • Create the webservice from an existing description (*.WDU file)
      When creating a WINDEV library, a ".WDU" file with the same name is automatically created. This file contains all the references of the elements included in the library.
  7. Go to the next step.
  8. Check the accessible elements. The accessible elements correspond to the procedures that contain functions visible by the client application that calls the Webservice.

    Caution: If a set of procedures becomes accessible, all the global procedures belonging to this set will be accessible. Two methods can be used to hide some procedures:
    • include these procedures in a specific set and do not make this set accessible.
    • use the PRIVATE keyword to make the procedure inaccessible (syntax: PRIVATE PROCEDURE MyProc()). For more details, see Global procedures.
  9. End the wizard to generate the Webservice.
  10. The deployment wizard is automatically started thereafter.
Deploying a Webservice and running its test

Deploying a Webservice

In order to be used, a Webservice must be deployed on a WEBDEV Application Server.
Several deployment methods can be used:
  • Deploying the Webservice on a remote WEBDEV Application Server.
  • Deploying the Webservice in the CLOUD for PC SOFT applications.
  • Deploying the Webservice via the test hosting service of PC SOFT.
  • Creating a remote deployment package.
  • Creating a setup by physical media.
  • Deploying the Webservice on the local computer.
  • Creating a Webservice docker image.
The options for deploying a Webservice are identical to the options for deploying a WEBDEV site. For more details, see Deploying a site.

Special case: Deploying a Webservice and running its test on the local computer

The test of the created Webservice can be run on the developer computer. To do so, select "Deploy the Webservice on the local computer". This type of setup is available only if WEBDEV is available on the development computer. In this case, the application server used is the one of WEBDEV.
At the end of the setup, a screen appears showing 2 links:
  • a link that indicates the address of the test page of the webservice (http://user-pc/MYWEBSERVICE_WEB/awws/index.htm)
  • a link that indicates the address of WSDL (http://user-PC/MYWEBSERVICE_WEB/awws/MyWebservice.awws?wsdl)
Once the link was clicked or the address typed in your browser, an HTML page is displayed: this page contains the accesses to all the functions developed in the Webservice as well as a link to the WSDL. This page is automatically created when generating the Webservice as well as all the HTML pages used to run the test of each Webservice function.
In our example, you will find the access to the "Addition" function:
When you click a function to test it, a new HTML page is displayed: This page contains controls used to enter the parameters for calling the function being tested. In this case, simply fill out the controls and click "Test". A result page will be displayed in return. In our example, two numbers must be passed to the "Addition" function:
The result page generated will be:
The result is in XML format. The return values are encapsulated in XML tags. In our example, the return value of the "Addition" functions is enclosed in the "AdditionResult" tag.
Minimum version required
  • Version 9
This page is also available for…
Click [Add] to post a comment

Last update: 04/21/2023

Send a report | Local help