Tuto WINDEV 25
Part 4: Full application with data 277 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 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 . • Click below the "Modify " Button control in the window. • The control is automatically created. 3. Modify the characteristics of the control ("Description" from the popup menu). This control is named "BTN_InStock" and its caption is "In stock?". 4. Display the events associated with the control ("Code" from the popup menu). 5. 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 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.
Made with FlippingBook
RkJQdWJsaXNoZXIy NDQ0OA==