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

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