Welcome! Log In Create A New Profile

Advanced

[WB26] - Calling a script/routine

Posted by JP 
JP
[WB26] - Calling a script/routine
July 28, 2021 03:51PM
Hi All

Just upgraded to WebDev 26. I have asked a similar question before but didn't get the chance to test. Now I need to know how to do it in WebDev 26 ..

I need to call a routine or script on my WebDev server and pass some parameters to it. A user will use my mobile app to submit some data to my server. How do I create a script in WebDev for the mobile app to call and how to get the parameters the user will send me?

I need something like:

[www.mywebserver.com]

Is it possible? If yes, how?

Thanks!
pao
Re: [WB26] - Calling a script/routine
July 28, 2021 04:13PM
You can create AWP pages for that and return the result you need as JSON or XML.
[doc.windev.com]

To get the parameters just use the PageParameter function
[doc.windev.com]

Or you can create one REST webservice
[doc.windev.com]

In the mobile project just call the awp pages the same way as you call any REST webservice, sample code (made by memory, not tested):
WS_RESULTADO is variant
var_p1 is int=9876
var_p2 is int=12345
http_req is httpRequest
http_req.URL="[your_server];
http_req.Method=httpPost
http_req.ContentType="text/plain"
http_req.TimeOut=600000
http_res is httpResponse
HTTPCreateForm("FORM_WS")
HTTPAddParameter("FORM_WS","p1",var_p1)
HTTPAddParameter("FORM_WS","p2",var_p2)
http_res=HTTPSendForm("FORM_WS",http_req)
IF http_res.StatusCode<>"200" THEN
IF http_res.StatusCode=0 THEN
Error("ERROR HTTPSendForm: ",ErrorInfo(errFullDetails))
RESULT False
ELSE
Error("ERROR HTTPSendForm: "+http_res.StatusCode +" "+http_res.Content)
RESULT False
END
END
WS_RESULTADO=JSONToVariant(http_res.Conten)
HTTPCancelForm("FORM_WS")

Regards

Paulo Oliveira



Edited 4 time(s). Last edit at 07/29/2021 09:55AM by pao.
Argus
Re: [WB26] - Calling a script/routine
July 28, 2021 04:26PM
if you want an example, you can look in wxreplication, as what you request and what Pao is describing is the transport mechanism used
JP
Re: [WB26] - Calling a script/routine
July 29, 2021 10:15AM
Hi Argus and Pao,

[UPDATED]

I created a page and set it as a Dynamic page - Generation in AWP mode without context.

It gets created on the server when I upload the website. However I have a question:

1) My website domain is, for example, www.my_project.com. As you know, when the WebDev site gets uploaded it creates a longer URL like this:

www.my_project.com/WD230AWP/WD230Awp.exe/CONNECT/my_project

Then I use the URL shortening technique using a default.htm and a frameset to just reference www.my_project.com . That works all fine.

Question: Is there a way to call the AWP page using www.my_project.com/some_page.awp and bypass the long WebDev URL? When I try it IIS comes back saying Error 404 - resource not found.


Thanks again,



Edited 6 time(s). Last edit at 07/29/2021 12:25PM by JP.
pao
Re: [WB26] - Calling a script/routine
July 29, 2021 12:52PM
Try using:
www.my_project.com/my_project_web/UK/your_awp_page.awp

Change the UK to whatever language you have defined in your project.

Regards

Paulo Oliveira
JP
Re: [WB26] - Calling a script/routine
July 29, 2021 02:05PM
Hi PAO

Yes, I have it working like that. Which is good enough for my purpose. I was just wondering if it could be shortened to just;

www.my_project.com/your_awp_page.awp

But yes, it does work as you suggest.

Thanks
JP
Re: [WB26] - Calling a script/routine
July 29, 2021 02:25PM
Argus, thanks for the help. I have it working. thumbs up

Ciao
Argus
Re: [WB26] - Calling a script/routine
July 30, 2021 02:32PM
it can be shorten using URL redirection settings on the web server (IIS, apache), but I don't see the point
JP
Re: [WB26] - Calling a script/routine
July 30, 2021 04:17PM
Argus

Yes, you right. Only our own mobile app will call the script so no one sees it anyway.

Thanks
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: