Home | Sign in | English UK
  • This lesson will teach you the following concepts
  • Overview
  • Practical example
  • Importing a Webservice
  • Consuming a Webservice
Lesson 4.12. Consuming a Webservice
This lesson will teach you the following concepts
  • Overview.
  • Importing and consuming a Webservice.

Estimated time: 10 mn
Previous LessonTable of contentsNext Lesson
In most cases, an XML Web service is defined as an application accessible via the standard Internet protocols. More specifically, Web services allow several computers connected via Internet to interact.
Web services allow you to run procedures and processes on a remote Web server (.NET, SOAP or J2EE) from a client computer.
With WINDEV, these Web services can be used as client, via the SOAP protocol on HTTP (the standard Internet protocol for transferring HTML pages), with the SOAPxx, DotNetxx and J2EExx functions.
Regardless of the platform of the Web server (.NET, J2EE, ...), a Web service is accessible via the SOAP protocol.


With WINDEV, you don't even have to be an expert in this field. A wizard takes care of ("almost") everything!

Practical example

A Webservice specific to the Tutorial allows you to check the different operations that can be performed on a Webservice.
Integrated to the "WD Full Application" project, this Webservice is used to interrogate a supplier database to check whether a product is available (stock) from its reference.
In a first time, the Webservice will be imported into the "WD Full Application" project then it will be used in the application to check the product availability from a Product form.
Importing a Webservice
  • Close the current project if necessary. The WINDEV home page is displayed.
  • In the home page, click "Tutorial" and select the project named "Full application (Exercise)". The project is loaded.


    If you did not create the windows in the previous lessons, you can follow this lesson by opening a corrected project: in the WINDEV home page (Ctrl + <), click "Tutorial" and select "Full application (With windows)".
    A full corrected application project is also available: in the WINDEV home page (Ctrl + <), click "Tutorial" and select "Full application (Answer)"
  • Position (if necessary) on the "32-bit Windows executable" configuration: in the project explorer, double-click "32-bit Windows executable" in the "Configurations" folder.
  • To import a Webservice into the project:
    1. On the "Project" pane, in the "Project" group, expand "Import" and select "A Webservice".
    2. The import wizard starts. Go to the next step.
    3. Specify the address into which the WSDL description of Webservice must be imported:

      Reminder: This Webservice is used to interrogate a supplier database to check the availability (stock) of a product from its reference.
    4. Go to the next step. The Webservice is imported.
    5. Validate the information window. The imported Webservice is found in the "Imported Webservices" folder of project explorer.
    6. In the project explorer, expand the "Imported Webservices" folder.
Let's take a look at the information displayed in the project explorer:
The structure includes:
  • the Webservice name (WSTutorialV2 in this example),
  • the name of each function (ProductInStock in this example).
To find out the call mode of Webservice, all you have to do is double-click the function name in the project explorer. The code editor displays the function description, with the prototype for calling the function:
Consuming a Webservice
In our "WD Full Application" example, the call to the Webservice will be included in the tab used to see the list of products. A button "In stock?" is used to check whether the product displayed via the Webservice is available.
  • To use the Webservice:
    1. Open the "WIN_Menu" window in the window editor (double-click its name in the project explorer for example).
    2. Add a button into the "List of products" pane:
      • On the "Creation" pane, in the "Usual controls" group, click .
      • In the window, click below the "Modify " button.
      • The button is automatically created.
    3. Modify the button characteristics ("Description" from the popup menu). This control is named "BTN_InStock" and its caption is "In stock?".
    4. Display the events associated with the button ("Code" from the popup menu).
    5. Type the following code in the "Click BTN_InStock" event:
      // Displays the Webservice response
         "Number of ""%1"" products in stock: %2", ...
         COL_Reference, ProductInStock(COL_Reference))
      Let's study this code:
      • The ProductInStock function of Webservice is called. This code is using the function prototype that was displayed beforehand in the code editor.
      • The response is formatted and displayed.
    6. Close the code editor and save the window ( or Ctrl + S).
  • We are going to check the operating mode of Webservice:
    1. Run the project test ( among the quick access buttons).
    2. Click the "List of products" tab if necessary.
    3. Select any product in the Table control and click the button "In stock?".
    4. Validate the information window and close the application.
Previous LessonTable of contentsNext Lesson
Minimum version required
  • Version 24
Click [Add] to post a comment