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

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