Welcome! Log In Create A New Profile

Advanced

Java and WebServices No#2

Posted by SteveSitas 
Java and WebServices No#2
October 12, 2021 08:39PM
Hi,
After contacting PCSoft, it seems like Java apps (in WX26) do not support all of WXs WebService functionality.
Some of the documentation is incorrect _AND_ Java apps are even behind Linux WX apps in supporting WebServices.

My main problem is that the httpRequest VARIABLE is NOT available in WD Java apps - so how(?) do I translate the following WINDEV 26 Windows code to something that works with the old plain HTTPRequest FUNCTION (available for Java):

cMyRequest is restRequest
cMyRequest..URL = myURL
cMyRequest..Method = httpGet
cMyRequest..Header["user-id"] = p_sUser
cMyRequest..Header["password-Key"] = p_sPassword
cMyResponse is restResponse = RESTSend(cMyRequest)

to something that uses ONLY the HTTPRequest FUNCTION ...

My difficulties are with passing the headers with the HTTPRequest FUNCTION

Regards
Steven Sitas
Argus
Re: Java and WebServices No#2
October 13, 2021 03:13AM
that's an easy one

that is the syntax from the help:

<Result> = HTTPRequest(<URL to contact> [, <User agent> [, <Additional HTTP header> [, <Message to send> [, <Message type> [, <Username> [, <Password>]]]]]])

headers are passed as a string in the 3rd parameter...

The ONLY trick is that each line has to be sparated from the next one by a CR, INCLUDING THE LAST ONE (ie you need a string ending with a CR)

So, in your example:
asMyHeaders is ansi string="user-id = "+p_sUser+cr+"password-Key="+ p_sPassword+cr

and you put asMyHeaders as 3rd parameter
Re: Java and WebServices No#2
October 13, 2021 11:05AM
Hi Argus,

I will check to see if the CR trick makes it work ..
thanks

Regards
Steven Sitas
Author:

Your Email:


Subject:


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.
Message: