domingo, 23 de agosto de 2020

DICAS 3044 - WINDEV TUTORIAL 67 - CONSUMINDO SERVICO WEBSERVICE

https://youtu.be/quiZkDpFqhw



Bom Dia/Boa Tarde/Boa Noite


Esse Ao Vivo vai estrear as 14:00 do dia 01/09/2020 

DICAS 3044 - WINDEV TUTORIAL 67 - CONSUMINDO SERVICO WEBSERVICE
Tutoriel WINDEV : Leçon 4.12. Consommer un Webservice

ASSUNTOS

EXPLICANDO O QUE É WEBSERVICE
EXPLICANDO O EXEMPLO PRATICO 
EXPLICANDO COMO FAZER A IMPORTACAO DO WEB SERVICO
IMPORTANDO O WEBSERVICE
MOSTRANDO O LOCAL ONDE FICA O WEBSERVICE
EXPLICANDO O QUE SIGNIFICA O QUE ELE TROUXE
CRIANDO O BOTAO PARA BUSCAR ESTOQUE
EXPLICANDO O CODIGO
EXECUTANDO O APLICATIVO


LINK DO WEBSERVICE


Video original da Franca

https://youtu.be/cQexMInRYbc


Playlist Windev TUTORIAL

https://youtu.be/3DshsXJ8I2M



========================


//btn em estoque
// Displays the Webservice response
// Exibe a resposta do webservice

InfoBuild("Produto de %1 em Estoque : %2",COL_Reference,ProduitEnStock(COL_Reference))











Lesson 4.12. Consuming a Webservice
This lesson will teach you 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 platform of the Web server (.NET, J2EE, ...), a Web service is accessible 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.
Importing a Webservice
  • Close the current project if necessary. The WINDEV home page is displayed.
  • In the home page, click "Tutorial" and select "Full application (Exercise)". The project is loaded.

    Answers

    If you did not create the windows in the previous lessons, you can follow this lesson by opening a corrected project: in WINDEV's home page (Ctrl + <), click "Tutorial" and select "Full application (With windows)".
    A full corrected application project is also available: in WINDEV's home page (Ctrl + <), click "Tutorial" and select "Full application (Answer)"
  • Position (if necessary) on the "32-bit Windows executable" configuration: in the "Project explorer" pane, in the "Configurations" folder, double-click "Windows 32-bit executable".
  • 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 find out how to call the Webservice, simply 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. 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 Creating a Button control.
      • 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?".
      Position of the Button control '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_ReferenceProductInStock(COL_Reference))
      Let's study this code:
      • The ProductInStock function of Webservice is called. This code uses 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 ( Save the window or Ctrl + S).
  • We are going to check the operating mode of Webservice:
    1. Run the project test ( Run 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 "In stock?".
      Test of Webservice
    4. Validate the information window and close the application.

DICAS 2978 - WINDEV TUTORIAL 1 - 1.1B - WINDEV TEMA ESCURO E IDIOMA DO AMBIENTE
DICAS 2979 - WINDEV TUTORIAL 2 - 1.2- CRIAR JANELA E INSERIR TEXTO E EXIBIR
DICAS 2980 - WINDEV TUTORIAL 3 - 2.1- VARIAVEIS PARTE 1
DICAS 2981 - WINDEV TUTORIAL 4 - 2.2- VARIAVEIS ESCOPO - PARTE 2
DICAS 2982 - WINDEV TUTORIAL 5 - 2.1- VARIAVEIS OPERADORES PARTE 3
DICAS 2983 - WINDEV TUTORIAL 6 - 2.1.D - VARIAVEIS STRINGS PARTE 4
DICAS 2984 - WINDEV TUTORIAL 7 - 2.1.E - VARIAVEIS ARRAYS PARTE 5
DICAS 2985 - WINDEV TUTORIAL 8 - 2.2.A - CONDICOES IF-SWITCH PARTE 1
DICAS 2986 - WINDEV TUTORIAL 9 - 2.2.B - CONDICOES PARTE 2
DICAS 2987 - WINDEV TUTORIAL 10 - 2.3.A - LOOP PARTE 1
DICAS 2988 - WINDEV TUTORIAL 11 - 2.3.B - LOOP EXEMPLOS PARTE 2
DICAS 2989 - WINDEV TUTORIAL 12 - Lesson 2.4. The procedures - PARTE 1
DICAS 2990 - WINDEV TUTORIAL 13 - Leçon 2.4.b. Procedures Parametros - PARTE 2
DICAS 2991 - WINDEV TUTORIAL 14 - PROCEDURES REFERENCIA - PARTE 3
DICAS 2992 - WINDEV TUTORIAL 15 - PROCEDURES OPCIONAIS OU OBRIGATORIAS - PARTE 4
DICAS 2993 - WINDEV TUTORIAL 16 - PROCEDURES EXEMPLOS - PARTE 5
DICAS 2994 - WINDEV TUTORIAL 17 - PERGUNTAS E RESPOSTA - PARTE 1
DICAS 2995 - WINDEV TUTORIAL 18 - PERGUNTAS E RESPOSTA - PARTE 2
DICAS 2996 - WINDEV TUTORIAL 19 - WINDEV E OS BANCOS DE DADOS
DICAS 2997 - WINDEV TUTORIAL 20 - PROJETO E ANALISE - CRIACAO
DICAS 2998 - WINDEV TUTORIAL 21 - PROJETO E ANALISE - ARQUIVOS DADOS CLIENTE - PARTE 2
DICAS 2999 - WINDEV TUTORIAL 22 - PROJETO E ANALISE - ARQUIVOS DADOS CRIACAO ARQUIVO PEDIDO - PARTE 3
DICAS 3000 - WINDEV TUTORIAL 23 - PROJETO E ANALISE - IMPORTANDO CVS-ARQUIVO TEXTO - PARTE 4
DICAS 3001 - WINDEV TUTORIAL 24 - PROJETO E ANALISE - IMPORTANDO ARQUIVO PRODUTO - PARTE 5
DICAS 3002 - WINDEV TUTORIAL 25 - PROJETO E ANALISE - LINK - PARTE 6
DICAS 3003 - WINDEV TUTORIAL 26 - RAD COMPLETO
DICAS 3004 - WINDEV TUTORIAL 27 - VISAO GERAL
DICAS 3005 - WINDEV TUTORIAL 28 - Adicionar e Modificar Janelas PRODUTOS - PARTE A
DICAS 3006 - WINDEV TUTORIAL 29 - Adicionar e Modificar Janelas PRODUTOS Formulario - PARTE B
DICAS 3007 - WINDEV TUTORIAL 30 - Adicionar e Modificar Janelas PRODUTOS ALINHAR CAMPOS - PARTE C








sábado, 22 de agosto de 2020

DICAS 3043 - WINDEV TUTORIAL 66 - COMPONENTES EXTERNOS - USANDO - PARTE B



https://youtu.be/2IFCC0xrdRA


Bom Dia/Boa Tarde/Boa Noite


Esse Ao Vivo vai estrear as 11:00 do dia 01/09/2020 

DICAS 3043 - WINDEV TUTORIAL 66 - COMPONENTES EXTERNOS - USANDO - PARTE B
Tutoriel WINDEV : Leçon 4.11.b. Réutilisez du code grâce aux composants externes - Utilisation

ASSUNTOS

EXPLICANDO O QUE SERA FEITO
CRIANDO UM APLICATIVO SEM ANALISE
IMPORTANDO O COMPONENTE EXTERNO FEITO LICAO ANTERIOR
CRIANDO UMA JANELA CLIENTE POR CIDADE
CRIANDO O CODIGO PARA CHAMAR DataLocation
CRIAR UM EDT_CIDADE,TABELA RESULTADO,BOTAO PESQUISAR
ENTRAR NO BOTAO PESQUISA E FAZER COMANDO RETORNANDO AS CIDADES
NAVEGAR PELO RESULTADO DA PESQUISA DA CIDADE 
ADICIONAR AS LINHAS
AVISAR SE NAO DEU CERTO
COMO FAZER INSTALADOR WDK PARA DISTRIBUIR
FAZENDO O INSTALADOR 


Video original da Franca

https://youtu.be/7gX_xDkRbmg


Playlist Windev TUTORIAL

https://youtu.be/3DshsXJ8I2M


=====================================

// end of initialization

DataLocation("C:\My Projects\My Examples\WD Full Application (Exercises)\Exe\Componente_Cidade")

=====================================
//btn pesquisar
sRESULTADO_LISTA is string
// Gets the list of customers and their orders for the specified city
// Obtém a lista de clientes e seus pedidos para a cidade especificada
sRESULTADO_LISTA=GiveOrdersByCity(EDT_CIDADE)
// Se a lista não estiver vazia
IF sRESULTADO_LISTA<>"" THEN
// Clears the Table control
// Limpa o controle da tabela
//TableDeleteAll(TABLE_RESULTADO)
    TABLE_RESULTADO.DeleteAll()
// Browses the results
// Navega pelos resultados
// AMARILDO 1 + TAB + 100 + CR +
// AMARILDO 2 + TAB + 200
FOR EACH STRING sLINHA IN sRESULTADO_LISTA SEPARATED BY CR 
// Adds this client to the Table control
// Adiciona este cliente ao controle Tabela
//TABLEADD(TABLE_RESULTADO,sLINHA)
TABLE_RESULTADO.Add(sLINHA)
END
ELSE
InfoBuild("NAO ACHADO CIDADE PARA %1 ",EDT_CIDADE)
END

=====================================













Step 2 : Using the external component

Once created, your component can be used in any other WINDEV project. Let's now see how this component can be re-used.
  • To do so, we are going to create a new project and import our component into this project.
    1. Close the current project: on the "Home" pane, in the "General" group, expand "Close" and select "Close the project".
    2. Validate the closing of project and save the modifications if necessary.
    3. The WINDEV home page is displayed.
    4. Create a new project: click "Create a project" in the home page.
      • This project is a Windows application.
      • This project is named "CompUse" and it has no analysis.
    5. On the "Project" pane, in the "Project" group, expand "Import" and select "An External component ... From a file".
    6. In the directory of "WD Full Application" project, select the "EXE\CompoOrdersByCity" sub-directory, then the "CompoOrdersByCity.wdi" file.

      Remark

      If the component was created from:
      • the "WD Full Application (Exercise)" example, select the "My Projects\My Examples\WD Full Application (Exercise)\EXE\CompoOrdersByCity" sub-directory, then the "CompoOrdersByCity.wdi" file.
      • the "WD Full Application (with windows)" example, select the "My Projects\My Examples\WD Full Application (With windows) (Exercise)\EXE\CompoOrdersByCity" sub-directory, then the "CompoOrdersByCity.wdi" file.
    7. Click "Open", the description of our component is displayed. This description contains:
      • On the "General" tab, the elements typed when creating the external component as well as its location.
        Description of component
      • On the "Details" tab, the component description as well as the help that was automatically generated. This allows you to identify the re-usable component elements.

        Remark

        The component description can be accessed at any time. Simply select the component in the "Project explorer" pane and select the "Description" option from the popup menu. In this case, you also have the ability to define the load mode of component.
    8. Validate ("Close" button). The component is included in your project.
  • We are now going to create a blank window to use the component.
    1. Create a blank window.
      • The window title is "Customers by city".
      • The window name is "WIN_Customers_by_city".
      • Save.
    2. Display the WLanguage events associated with the window ( "Code" from the popup menu).
    3. We are going to call the DataLocation function of component in the "End of initialization" event. This function expects in parameter the path used to access the data files handled by the component. Type the access path to the data found in the "WD Full Application" example. For example:
      DataLocation(...// Specify the path of YOUR data
      "C:\WINDEV\Tutorial\WD\Exercises\" + ...
      "WD Full Application\Exe")

      Remark

      If your project uses another procedure named "DataLocation", the name of component procedure must be prefixed by the name of the set of procedures used. The code becomes:
      SET_Component.DataLocation(...
    4. Close the code editor.
    5. Add the following controls into the window:
      • A text Edit control whose caption is "City" and whose name is "EDT_City".
      • A Table control named "TABLE_Result", filled by programming and that includes 2 columns:
        • a "Name" column of Text type.
        • a "Total sales" column of Currency type.
      • A Button control whose caption is "Search" and whose name is "BTN_Search".
  • You can now edit the WLanguage events associated with "BTN_Search". When this control is clicked on, we will run the search procedure found in the component. This procedure:
    • expects the city name in parameter
    • returns a string in the following format:
      Name of customer 1 + TAB + Total sales 1 + CR +
      Name of customer 2 + TAB + Total sales 2 + ...
    So, the code of the "Click" event from "BTN_Search" should:
    • call the GiveOrdersByCity procedure of component while passing the content of EDT_City control in parameter.
    • process the returned string to add it into the Table control.
    Write the following WLanguage code:
    sResultList is string
    // Gets the list of customers and their orders
    // for the specified city
    sResultList = GiveOrdersByCity(EDT_City)
    // If the list is not empty
    IF sResultList <> "" THEN
    // Clears the Table control
    TableDeleteAll(TABLE_Result)
    // Browses the results
    FOR EACH STRING sACustomer OF sResultList SEPARATED BY CR
    // Adds this client to the Table control
    TableAdd(TABLE_ResultsACustomer)
    END
    ELSE // If the list is empty
    InfoBuild("No customer found for %1", ...
    EDT_City)
    END
  • Close the code editor and save your window.
  • Run the window test: click Run the test of a window among the quick access buttons. In the edit control, type "Paris" (while respecting the case) and click the "Search" button. The list of customers is displayed.
    Window test
  • That's it! Child's play isn't it?
You know how to create a component and how to re-use it in your applications. You also have the ability to manage the setup procedures of your components, in order to distribute them separately from your applications for example.
Distributing an external component
Two methods can be used to distribute a component:
  1. Provide the necessary files "manually", this is a "standard" distribution.
  2. Create a more "professional" distribution, via the setup editor of WINDEV (WDInst).

Standard distribution

In this case, you must supply all the files required for your component to operate. These files are created when generating the component (WDI, WDK and WDO files, images, other documents, ...). These files will be manually copied from their source directory to the destination directory. The WINDEV projects that use this component will find the dependent files in this destination directory.
List of files that must be supplied for a standard distribution:
  • the files automatically generated by WINDEV (WDK, WDI, ...).
  • the dependency files.
  • the WDO file must be supplied if the component uses dependency files. This file contains the references to the external files used in the component.

Professional distribution

The distribution of components via a setup procedure consists in providing a setup program to the users of WINDEV component. This program installs all the files required for using the component in the directory specified by the user.
This setup mode is used to automatically manage:
  • the WDO file and the setup of additional files used by the component.
  • the automatic setup of necessary tools (MDAC, ODBC driver for HFSQL, ...).
  • the automatic update of data files used by the component (if necessary).
  • the uninstall program of component.
  • Close the "CompoUse" project: on the "Home" pane, in the "General" group, expand "Close" and select "Close the project".
  • Open the "WD Full Application" project that was used beforehand (for example, display the home page and select the "WD Full Application" project found in the recent projects). If necessary, select the project configuration corresponding to the component in the "Project explorer" pane.
  • To create the setup, on the "Project" pane, in the "Generation" group, click "Setup procedure"..
The component setup creation wizard starts.
We won't go into details about the different setup modes of a component. Follow the steps of the wizard.
See Distributing an external component for more details.

DICAS 2978 - WINDEV TUTORIAL 1 - 1.1B - WINDEV TEMA ESCURO E IDIOMA DO AMBIENTE
DICAS 2979 - WINDEV TUTORIAL 2 - 1.2- CRIAR JANELA E INSERIR TEXTO E EXIBIR
DICAS 2980 - WINDEV TUTORIAL 3 - 2.1- VARIAVEIS PARTE 1
DICAS 2981 - WINDEV TUTORIAL 4 - 2.2- VARIAVEIS ESCOPO - PARTE 2
DICAS 2982 - WINDEV TUTORIAL 5 - 2.1- VARIAVEIS OPERADORES PARTE 3
DICAS 2983 - WINDEV TUTORIAL 6 - 2.1.D - VARIAVEIS STRINGS PARTE 4
DICAS 2984 - WINDEV TUTORIAL 7 - 2.1.E - VARIAVEIS ARRAYS PARTE 5
DICAS 2985 - WINDEV TUTORIAL 8 - 2.2.A - CONDICOES IF-SWITCH PARTE 1
DICAS 2986 - WINDEV TUTORIAL 9 - 2.2.B - CONDICOES PARTE 2
DICAS 2987 - WINDEV TUTORIAL 10 - 2.3.A - LOOP PARTE 1
DICAS 2988 - WINDEV TUTORIAL 11 - 2.3.B - LOOP EXEMPLOS PARTE 2
DICAS 2989 - WINDEV TUTORIAL 12 - Lesson 2.4. The procedures - PARTE 1
DICAS 2990 - WINDEV TUTORIAL 13 - Leçon 2.4.b. Procedures Parametros - PARTE 2
DICAS 2991 - WINDEV TUTORIAL 14 - PROCEDURES REFERENCIA - PARTE 3
DICAS 2992 - WINDEV TUTORIAL 15 - PROCEDURES OPCIONAIS OU OBRIGATORIAS - PARTE 4
DICAS 2993 - WINDEV TUTORIAL 16 - PROCEDURES EXEMPLOS - PARTE 5
DICAS 2994 - WINDEV TUTORIAL 17 - PERGUNTAS E RESPOSTA - PARTE 1
DICAS 2995 - WINDEV TUTORIAL 18 - PERGUNTAS E RESPOSTA - PARTE 2
DICAS 2996 - WINDEV TUTORIAL 19 - WINDEV E OS BANCOS DE DADOS
DICAS 2997 - WINDEV TUTORIAL 20 - PROJETO E ANALISE - CRIACAO
DICAS 2998 - WINDEV TUTORIAL 21 - PROJETO E ANALISE - ARQUIVOS DADOS CLIENTE - PARTE 2
DICAS 2999 - WINDEV TUTORIAL 22 - PROJETO E ANALISE - ARQUIVOS DADOS CRIACAO ARQUIVO PEDIDO - PARTE 3
DICAS 3000 - WINDEV TUTORIAL 23 - PROJETO E ANALISE - IMPORTANDO CVS-ARQUIVO TEXTO - PARTE 4
DICAS 3001 - WINDEV TUTORIAL 24 - PROJETO E ANALISE - IMPORTANDO ARQUIVO PRODUTO - PARTE 5
DICAS 3002 - WINDEV TUTORIAL 25 - PROJETO E ANALISE - LINK - PARTE 6
DICAS 3003 - WINDEV TUTORIAL 26 - RAD COMPLETO
DICAS 3004 - WINDEV TUTORIAL 27 - VISAO GERAL
DICAS 3005 - WINDEV TUTORIAL 28 - Adicionar e Modificar Janelas PRODUTOS - PARTE A
DICAS 3006 - WINDEV TUTORIAL 29 - Adicionar e Modificar Janelas PRODUTOS Formulario - PARTE B
DICAS 3007 - WINDEV TUTORIAL 30 - Adicionar e Modificar Janelas PRODUTOS ALINHAR CAMPOS - PARTE C







Teste

Teste
teste