O$8.0.3.2 Consume JSON services from Omnis...

Rocco Ventura [Kunvi] r.ventura at kunvi.it
Tue Jul 25 03:50:36 EDT 2017


Hi O$-Group,

I'm trying to consume a JSON service using Omnis last-version; I've followed the documentation, but I had problems in reading the result-row structure from the server.

Has anyone had problems like this!?

Here is my example code:

__________________________
;  PREPARE THE HEADERS-LIST... IS THERE SOMETHING MISSING!?
Do iHeadersList.$define(iHeaderName,iHeaderValue)
Do iHeadersList.$add('Content-type','application/json')

;  PREPARE THE STRUCTURES/SCHEMA FOR THIS PARTICULAR JSON-SERVICE...
Do RecRisped.$definefromsqlclass(con($clib().$name,'.sx_risped_pvs_bnt_json'))
Do ListaPrels.$definefromsqlclass(con($clib().$name,'.sx_risped_pvs_bnt_json_1'))
Calculate RecRisped.OrderNumber as "P00000808"
Calculate RecRisped.PickticketNumber as '32'
Calculate RecRisped.CartonNumber as '17FX0000025'
Calculate RecRisped.GrossWeight as 1
Calculate RecRisped.PackageType as 'BNT-1'
Do ListaPrels.$add('8032590011854',1)
Calculate RecRisped.PackingList as ListaPrels

;  PREPARE THE JSON/STRUCTURE IN A BINARY-VAR (JsonField)
Do OJSON.$listorrowtojson(RecRisped,kUniTypeUTF8,Message) Returns JsonField

Calculate iURL as "http://bnstagebe.keros-digital.com:8080/api/packinglistimporter"
Calculate iMethod as kOWEBhttpMethodPost
Do ioRestfulObj.$shareconnections.$assign(kTrue)
Do ioRestfulObj.$timeout.$assign(100)
Do ioRestfulObj.$init(iURL,iMethod,iHeadersList,JsonField)

;  THE FOLLOWING $run() SEEMS TO WORK...
Do ioRestfulObj.$run() Returns Retc
If not(Retc)
	Calculate pMessage as ioRestfulObj.$errortext
	Quit method 0
End If

;  READ THE ANSWER FROM THE JSON-SERVER...
;  HERE I OBTAIN NOTHING... :(
If kTrue
	;  PREPARE THE SCHEMA FOR THE ANSWER, AS SHOWN IN DOCUMENTATION.
	Do iResponse.$definefromsqlclass('MAIN.sx_json_response')
	Do ioRestfulObj.$completed(iResponse) Returns Retc
Else
	;  IT DOES NOT WORK ALSO WITH THIS CALL, AS SHOWN IN THE EXAMPLE-DOCS...
	Do ioRestfulObj.$returnVal(iResponseHeaders,iResponse,iJSONRow) Returns iJSONStr
End If
If iResponse.$colcount=0
	Calculate pMessage as con("No answer from Json-Server.////",iURL)
	Quit method 0
End If
If isnull(iResponse.errorCode)
	Calculate pMessage as con("NULL answer from Json-Server.////",iURL)
	Quit method 0
End If
__________________________

Thanks.

Bye

Rocco
_________________________________
Distinti saluti. Best regards.

Rocco Dr. Ventura
WMS Analist and Software Developer

KUNVI srl - Experiences Holding - www.kunvi.it
Email: r.ventura at kunvi.it - Mobile: +39 348 5186051



---
Questa e-mail è stata controllata per individuare virus con Avast antivirus.
https://www.avast.com/antivirus





More information about the omnisdev-en mailing list