PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
New WINDEV 26 feature!
  • In this lesson you will learn the following concepts
  • Overview
  • Practical example
  • Importing a Webservice
  • Consuming a Webservice
Lesson 4.11. Consuming a Webservice
In this lesson you will learn the following concepts
  • Overview.
  • Importing and consuming a Webservice.
Lesson duration

Estimated time: 10 mn
Previous LessonTable of contentsNext Lesson
Overview
In most cases, a Web service is defined as an application that can be accessed via 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 Web server platform (.NET, J2EE, etc.), a Web service can be accessed via the SOAP protocol.

Remark

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 this tutorial allows you to check the different operations that can be performed on a Webservice.
When integrated to the "WD Full Application" project, this Webservice is used to interrogate a supplier database to check whether a product is available in stock using 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.
  • Open the project you worked on in the previous lesson if necessary.
    1. Go to the WINDEV home page (Ctrl + <).
    2. On the home page, click "Tutorial", then in "Part 4 - Full application with data", double-click "Full application (Exercise)".
    3. A dialogue box prompts you to open the project you worked on in the previous lesson. You can open the local copy or the original project. Select "Open the local copy".

Answers

A corrected project is available. This project contains all the elements created or imported in this lesson. To open the corrected project, go to the home page and click "Tutorial", then in "Part 4 - Full application with data", double-click "Full application (Answers)".


  • Go to the "32-bit Windows executable" configuration: in the "Project explorer" pane, in the "Configurations" folder, double-click "Windows 32-bit executable".
Importing a Webservice
  • 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 the Webservice must be imported:
      https://examples.webdev.info/WSTUTORIALV2_WEB/awws/WSTutorialV2.awws?wsdl

      Reminder: This Webservice is used to interrogate a supplier database to check the availability (stock) of a product from its reference.
      Webservice import wizard
    4. Go to the next step. The Webservice is imported.
      Import completed
    5. Validate the information window. The imported Webservice is in the "Imported Webservices" folder of the "Project explorer" tab pane.
    6. In the "Project explorer" pane, expand the "Imported Webservices" folder.
Let's take a closer look at the information displayed in the "Project Explorer" pane:
'Project explorer' pane
The structure includes:
  • the Webservice name (WSTutorialV2 in this example),
  • the name of each function (ProductInStock in this example).
To see the Webservice call syntax, double-click the name of the function in the "Project explorer" pane. The code editor displays the function description, with the prototype for calling the function:
Call to 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. An "In stock?" button will allow you to check whether the product displayed via the Webservice is available.
  • To use the Webservice:
    1. Open the "WIN_Menu" window in the editor (double-click its name in the "Project explorer" pane, for example).
    2. Add a Button control in the "List of products" tab pane:
      • On the "Creation" pane, in the "Usual controls" group, click Create a Button control.
      • Click below the "Modify " Button control in the window.
      • The control is automatically created.
    3. Modify the characteristics of the control (select "Description" in the context menu):
      • Name this control "BTN_InStock".
      • Enter the caption "In stock?".
        Position of the 'In stock?' Button control
    4. Validate.
    5. Open the events associated with the control (select "Code" in the context menu).
    6. Write the following WLanguage code in the "Click BTN_InStock" event:
      // Displays the Webservice response
      InfoBuild("Number of ""%1"" products in stock: %2", ...
         COL_Reference, ProductInStock(COL_Reference))
      Let's analyze this code:
      • The ProductInStock function of the Webservice is called. This code uses the function prototype that was displayed beforehand in the code editor.
      • The response is formatted and displayed.
    7. Close the code editor and save the window ( Save window or Ctrl + S).
  • We will test the Webservice:
    1. Test the project (click Test project in the quick access buttons).
    2. Click the "List of products" tab if necessary.
    3. Select any product in the Table control and click "In stock?".
      Webservice test
    4. Validate the information window and close the application.
Previous LessonTable of contentsNext Lesson
Minimum version required
  • Version 26
Comments
Click [Add] to post a comment