Welcome! Log In Create A New Profile


[WX22] WebDev - restResponse - I give up

Posted by DerekM 
[WX22] WebDev - restResponse - I give up
March 10, 2021 09:04PM
This is Version 22

I have spent 2 weeks trying to use WebDev functions for a REST https PUT function.

It seems to be "almost" there - but for the moment I have had to accept defeat and resort to scripting everything using cURL.

I have tried to debug the WebDev REST request/response using Chrome, Fiddler, and Postman - but it's not easy.

The PUT request has multiple headers and a 2 part embedded/encrypted body. The response should come as both a Received Header and a Received Body. I can get the Received Header but in order to debug an apparent issue with the request, I need the information in the response body.

It seems that WebDev fetches the response header (e.g. FAIL) - but not the response body with the detailed information needed (e.g. the reason for the failure).

I can construct this request in soapUI or in cURL and run it via Postman or the Windows Cmd window - and it works just fine (eg. Header says FAIL - body tells me why).

So for the moment I will have to use WebDev to construct cURL commands - run bat scripts - then get my Json results (body).

This to me is not ideal - but I THINK that WebDev is not capable of correctly processing REST results.

(Note: I can successfully use WebDev REST requests for my own WebDev REST services)

If someone has experience with interfacing with REST services other than WebDev REST services - perhaps there is something obvious that I may be missing - or even some clear way of monitoring raw WevDev http requests and results. I will eventually have to try this again with WebDev.

Thanks in Advance for any hints, tips, or suggestions.


Edited 2 time(s). Last edit at 03/11/2021 12:11AM by DerekM.
Re: [WX22] WebDev - restResponse - I give up
March 12, 2021 10:15AM
Hi Derek

I'm using Oracle AIS REST services from all three products via a single dedicated class and it all works fine.
A couple of things to start with.
1) Get a sample JSON for the input
2) Get a sample JSON for the expected output or get a definition JSON from the vendor
3) Get a sample JSON or a definition JSON of the structure when errors are returned
4) Make your project configuration UNICODE, everything running over the internet is UNICODE or at least UTF8 based. Don't know of any ANSI based web service nowadays to be honest...

In my example an Oracle JDE AIS REST reference used to develop the above files: JDE REST AIS API Reference
If you prefer samples instead of definitions those can easily be generated with PostMan. WX still has an issue on working with JSON or XML definition files. Samples work best.

Drop these JSON files in the external files description node in your project explorer or add them to the project object list.
Now you get all the benefits of syntax type-ahead, validation, etc...

Here is next a sample method that calls such a REST service and returns the result and the received JSON.
I hope this helps...

FUNCTION JDEMOFileGetList(pErrLst is soErrorList, pMOStructure is string, pMOKey is string, pIncludeData is boolean = True, pServiceURL is string="v2/file/list", ...)
pToken		is string	= :AISToken, pUserName is string	= :JDEUserName, pUserPassword is string = :JDEUserPassword)sad smileyboolean,JSON,oJDEMediaObjectList)
//POST Doc: [docs.oracle.com]
//Local variables
Success		is boolean	= False
ErrMsg		is soErrorMessage
RESTRqst	is restRequest
RESTResp	is restResponse
JSONRqst	is JSON	<description="v2.file.list">
JSONResp	is JSON	<description="resp.v2.file.list"> 
JSONError	is JSON	<description="resp.vx.orchestrator.service-error">	

	//Build JSON Request
	JSONRqst.token			= pToken	
	JSONRqst.moStructure	= pMOStructure
	JSONRqst.moKey			= pMOKey
	JSONRqst.includeData	= pIncludeData
	JSONRqst.thumbnailSize	= 80
	JSONRqst.formName		= ""
	JSONRqst.version		= ""
	//Set REST Request Parameters
	RESTRqst..UserAgent		= "Pixontri JDEdwards REST"
	RESTRqst..ContentType	= "application/json"
	RESTRqst..Content		= JSONRqst
	RESTRqst..Method		= httpPost
	RESTRqst..URL			= :JDEEndPointURL+["/"]+pServiceURL
	RESTRqst..User			= pUserName
	RESTRqst..Password		= pUserPassword
	//Clear current list
	//Execute REST request
	RESTResp = RESTSend(RESTRqst)
	//Server was reachable?
	IF NOT ErrorOccurred THEN	
		//Evaluate REST response
		//Possible values for this request:
		//	200 Response	Successful Execution
		//	400 Response	Bad Request - Invalid JSON Input
		//	403 Response	Authorization Failure
		//	405 Response	Allowed Hosts on the HTML server is not configured to accept requests from this AIS Server
		//	415 Response	Invalid Content-Type Header
		//	445 Response	Mobile SSO Failed
		//	446 Response	Mobile SSO Requested, but SSO is not Enabled on this AIS Server
		//	500 Response	Server Failed to Process Request
		SWITCH RESTResp.StatusCode 
			CASE 200:
				JSONResp = RESTResp.Content
				//Transfer to WX Media Object list too
				obj is JSON <description = "resp.v2.file.list.mediaObjects">
				FOR EACH obj IN JSONResp.mediaObjects
					JDEMO is oJDEMediaObject
					JDEMO.moStructure		= pMOStructure
					JDEMO.moKey			= pMOKey
					JDEMO.moSequence		= obj.sequence
<... Do bunch of enrichment processing here on the retrieved media object and finaly add it into the return list...>
				Success = True				
			CASE 444,500:
				JSONError = RESTResp.Content
				ErrMsg:AddToList(pErrLst,soErrorMessage.EM_ERROR,"HTTP REST",JSONError.message..Value+" ["+JSONError.type..Value+"]","Exception: "+JSONError.exception..Value+CR+JSONError.userDefinedErrorText..Value)		
				ErrMsg:AddToList(pErrLst,soErrorMessage.EM_ERROR,"HTTP REST","An error was encountered while trying to login to JDE.",RESTResp.StatusCode+": "+RESTResp.DescriptionStatusCode)		
		ErrMsg:AddToList(pErrLst,soErrorMessage.EM_ERROR,"HTTP REST","An error was encountered while trying to login to JDE.",ErrorInfo(errCode)+": "+ErrorInfo(errMessage))		
	//Return Result
	RESULT (Success, JSONResp, WXJDEMediaObjectList)
	<COMPILE IF ConfigurationType<>Android>
	RESULT (False, Null, WXJDEMediaObjectList)


Peter H.
Re: [WX22] WebDev - restResponse - I give up
March 13, 2021 12:35AM
Thanks Peter

That all looks pretty clear.

Currently I'm stuck with V22. Things like the JSON variable type are not there until V24.

As the actual REST requests/responses are only a smallish part of my project and quite easy to implement with cURL - looks like my best move is to move on and get back to this whenever I can upgrade to V26.

Your sample is pretty much what I want except I am expecting a JSON response in addition to a 400 Response which I just don't see in any format.

Anyway - working without the latest WX may be just adding to my grief as its difficult to know if there is an issue with V22 that has subsequently been resolved.

Thank you very much for your example and suggestions. I will update this link down the track whenever I can upgrade and resolve this issue.

Best Regards

Re: [WX22] WebDev - restResponse - I give up
March 13, 2021 10:49AM
Hi Derek,

I have no experience using REST but it's not much different from the http request I use for web api's.
For V22 you can adapt Peter's example by simply using a variant to build the request and do a VariantToJSON to convert it.
For the reponse you do the opposite: JSONToVariant on the result string

Best regards,
Re: [WX22] WebDev - restResponse - I give up
April 17, 2021 09:49AM
Hi, Derek.
I have created and intensively use REST web services.
1. Created with Windev / Webdev
2. JSON response from the WWW (time.is, [worldtimeapi.org], ...)

REST service is a nice solution and I use it in mobile applications to download / display data from the server.
It is also possible to send data back (with pictures or not) and UPDATE the database on the server via web services.

IF you still have questions, I will try to answer and help.

Best regards!

Edited 1 time(s). Last edit at 04/17/2021 09:52AM by IsmirB.

Your Email:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.