ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Communication / Web services
  • Overview
  • How to make a web service available?
  • Creating the web service
  • Managing contexts
  • Generating the web service
  • Deploying a web service and running its test
  • Deploying a web service
  • Special case: Deploying a web service and running its test on the local computer
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Overview
WINDEV and WEBDEV allow you to generate web services directly. Then, these web services can be used in the WINDEV, WEBDEV, WINDEV Mobile projects or in any other language.
A web service 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 web service will include WLanguage functions organized in sets of procedures. These functions can use a database (HFSQL, Oracle, AS/400, etc.).
Caution: Deploying a WINDEV or WEBDEV web service requires the use of a WEBDEV Application Server. Via this distribution mode, the web services created with WINDEV/WEBDEV present several types of benefits:
  • Web services deployed on a WEBDEV Application Server (compatible with all the Web servers).
  • Several modes for deploying the web service (physical media, FTP, Cloud).
  • Heavy workload possible.
  • Web services that can operate on all the Windows versions (32 and 64 bits) as well as in Linux.
How to make a web service available?
To make a web service available, you must:
  1. Create a web service.
  2. Generate a web service.
  3. Deploy the web service on a WEBDEV Application Server.
Remark: To run the test of the web service, you have the ability to deploy it locally for test.
Creating the web service
To create a web service:
  1. Create a WINDEV or WEBDEV project whose type is web service or a web service configuration in an existing project.
    • When creating a project, select "SOAP or REST web service".
    • To create a web service project configuration, go to the "Project" tab, "Project configuration" group, expand "New configuration" and select "Web service".
  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
    PROCEDURE Addition(nNumber1 is int, nNumber2 is int)

    nResult is int
    nResult = nNumber1 + nNumber2

    RETURN nResult

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

    Remarks:
    • 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 web service. A private procedure cannot be used in the projects that will import the web service (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 web service 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 web service.

Managing contexts

To keep the value of global variables during successive calls to a web service, 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 web service. 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.
    Remarks:
    • 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 web service can be retrieved during the next call. Variables previously passed are automatically saved again.
    • Simple variables (integer, string, etc.) are supported as well as structure, class, array or associative array variables. Fixed arrays, global class members and 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 web service contexts ("Duration of web service 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 web service
To generate a web service:
  1. Select (if necessary) the configuration corresponding to the web service in the project explorer.
  2. Generate the web service:
    • On the "Project" tab, in the "Generation" group, click "Generate".
    • Click the generation icon in the quick access buttons.
  3. The web service generation wizard starts.
  4. In the wizard, specify:
    • the name of the web service. By default, the web service name corresponds to the name of the current project. You can change the name of the web service (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 web service. This excludes all UI elements (window, page, report, etc.).
    Check the elements to include and the ones that will be called in the web service. 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 web service 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 web service.

    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. Finish the wizard to generate the web service.
  10. The deployment wizard is automatically started thereafter.
Deploying a web service and running its test

Deploying a web service

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

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

The test of the created web service can be run on the developer computer. To do so, select "Deploy the web service 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 web service (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 web service as well as a link to the WSDL. This page is automatically created when generating the web service as well as all the HTML pages used to run the test of each web service 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…
Comments
Click [Add] to post a comment

Last update: 01/09/2024

Send a report | Local help