Tech Articles


ALTERNATIVA PARA CONSUMIR WEB SERVICES REST JSON VERSIONES ANTERIORES (6.5, … , 11.5)


Con los nuevos sistemas una de las cosas que hoy en día escuchamos es: tenemos un web services donde puedes consultar…

Por lo que ante esta necesidad y teniendo un sistema desarrollado originalmente en powerbuilder 6.5 ( les traigo esta solución.

Un “consumer” de WS REST

Para hacer este ejemplo utilizaremos objetos no visuales, principalmente el objeto internetresult.

1.-  Creamos un objeto heredado de internetresult (Estandard Class) al cual llamaremos: nvo_internet_result.

2.- Declaramos la siguiente variable de instancia

window  lw_child //Handle

 

3.- Agregamos una función la cual llamaremos of_set_window en el objeto  nvo internet_result.

  • Recibe argumento de tipo Window (Handle)

  • Retorna un Entero

4.- Agregamos código a una función la cual debe llamarse internetdata

  • Recibe argumento de tipo blob

  • Retorna un Entero

5.-  Creamos un objeto no visual custom (Custom Class) al cual llamaremos: nvo_cws

6.- Declaramos las siguientes variables de instancia

string is_authorization

string is_endpoint

Inet  iinet_base

nvo_internet_result iir_msgbox  // El objeto creado anteriormente

string is_request

window iw_window   //Handle

 

7.- Agregamos una función la cual llamaremos of_set_endpoint.

  • Recibe argumento de tipo String

  • Retorna un Entero

8.- Agregamos una función la cual llamaremos of_set_window en el objeto cws.

  • Recibe argumento de tipo Window (Handle)

  • Retorna un Entero

 

9.- Agregamos una función la cual llamaremos of_exec en el objeto nvo_cws.

 

10.- Una vez realizadas las acciones anteriores procedemos a crear la interface gráfica.

  1. Agregamos un objeto window a nuestra aplicación con los siguientes objetos:

    1. Single line edit al cual llamaremos: sle_resource, ahí pondremos donde esta nuestro recurso.

    2. Multiline edit al cual llamaremos: mle_1

    3. CommmandButton al cual llamaremos: cb_test

    4. Y finalmente un datawindowsal cual llamaremos: dw_ws, su dataobject será un datawindow tipo external con dos campos tipo string

11.- Procedemos a poner el código en nuestra window

Agregamos el siguiente código en el evento open

obj_cws = CREATE nvo_cws

12.- Agregamos la función of_respuesta  la cual es llamada dinámicamente .

13.- Finalmente ponemos el siguiente código en el evento clicked del botón

 

Imágenes de apoyo

Aunque nuestro web service rest puede producir  json y xml por default genera el json

 

 

GlassFish 5 con el 4.1.1 generaba diversas excepciones

 

Definición del datawindow external

Comments (2)
Monday, Jun 04 2018

where it comesthe object  lib_json.

I get an error trying to create the visual interfase:

Error C0001 Illegal data type: lib_json

Undefined variable: json

Please help where I should do corrections to the example code 

 

#5
0

Monday, Jun 04 2018

Hi,

You can comment this lines
//lib_Json...
//json..

With this you should retrieve since Web service

The lines commented above is for parse, and show in datawindow

#6
0

Find Articles by Tag

Service DragDrop PDFlib Configuration Open Source 32-bit HTTPClient SQL Application Source Code Bug Window RibbonBar Builder Database Connection PowerScript (PS) DLL IDE NativePDF Deployment JSON iOS DataType Debug Messagging PowerBuilder Compiler SqlExecutor Android Repository GhostScript Event Handler PFC Data SOAP Outlook UI Modernization Windows 10 Icons SVN Database Table Git SDK Authorization REST Charts Export WebBrowser CrypterObject Interface Performance UI Menu Source Control Testing Trial MessageBox SqlModelMapper DataWindow Filter Oracle TortoiseGit TreeView RibbonBar Branch & Merge Database Table Schema CoderObject 64-bit JSONParser ActiveX Authentication Database Table Data Import JSON Stored Procedure API License Azure PostgreSQL Platform Database Automated Testing Event Handling Text .NET Std Framework RESTClient OrcaScript PostgreSQL ODBC driver Syntax XML OAuth 2.0 C# Graph Mobile OLE Excel Validation Icon PowerBuilder Database Object Transaction Database Profile Class Encoding Migration DevOps PDF Jenkins SnapDevelop Sort Elevate Conference .NET DataStore UI Themes Array Script TLS/SSL Web API PowerServer Web Expression Error Resize PowerServer Mobile Encryption SQL Server Design CI/CD InfoMaker PBDOM SnapObjects Debugging Export JSON TFS .NET Assembly Database Painter Installation WinAPI Event JSONGenerator BLOB DataWindow JSON Windows OS Model Debugger Variable RichTextEdit Control Linux OS Import COM Web Service Proxy OAuth File PowerBuilder (Appeon) External Functions ODBC