I see in 5.0 you have a web service feature. It looks like this feature is wrapped around being a provider of web services. Is there a way to use Valence API's to be a requester of web services? I'm interested in a tool that handles http connectivity management and json parsing. I am aware that Valence handles the parson of json, but I'm curious as to how I can tap into that when calling a web service.
Announcement
Collapse
No announcement yet.
Using Valence As A Requester of Web Services
Collapse
X
-
Johnny,
Thanks for your response. Am I correct in that I'd have to write my own code to parse the response? Also, I couldn't seem to get other web services to work, which I assume means the http header also needs to be modified to accommodate other services, correct?
Are any other Valence users using Valence to request data from web services? If so, can you post some sample code?
Comment
-
Below is a quick example calling an endpoint via GET method. This was taken directly from "EXHTTPGET1" example program. Instead of pulling the url from the front-end and responding I just hardcoded a url that responds with some data.
Code:/include qcpylesrc,vvHspec /define includeJSON d url s 2048a varying d inClob_len s 10u 0 d inClob_Data s a Len(16773104) d inMSGID s 10a d inMSGTEXT s 25a d vPointer s * inz d Obj_Data s a len(1048586) d Buffer s a len(16000000) based(vPointer) d i S 10i 0 d vUserId S 10 d vId S 10 d vTitle S 50 d vBody S 200 D ljson S * inz /include qcpylesrc,vvDspec /Free exec sql set option commit=*none; //url url = 'http://jsonplaceholder.typicode.com/posts/1'; vvUtility_http(url : vvGET : vPointer : inClob_len : inMSGID : inMSGTEXT); // Check for a Successfule response and process If inMsgId = '200'; //pull in the data obj_Data = %subst(Buffer:1:inClob_len); // Parse the json Monitor; ljson = vvjson_parse(%Addr(obj_Data)); vUserId = %str(vvjson_get(ljson: 'userId')); vId = %str(vvjson_get(ljson: 'id')); vTitle = %str(vvjson_get(ljson: 'title')); vBody = %str(vvjson_get(ljson: 'body')); //now that we have the data userId, id, title & body do something on-Error; //Error parsing data Endmon; // All added arrays and objects are also disposed. vvjson_dispose(ljson); Else; //Error 'inmsgId' Endif; *inlr = *on; /end-free
Comment
Comment