RESTful Services

Topics: Developer Forum, Project Management Forum, User Forum
Aug 19, 2013 at 4:36 AM
Hi All,

I'm working on a project at the moment using AVFP as a RESTful Server.

I'm interested to hear from anybody else that is doing the same and how things are going.

Following on from the excellent work already done, I'm actually working on what is really a RESTful extension which I have chosen to call "RESTful_Extensibility". Its's based on the idea of developers being able to create and hook in their own customisable RESTful handler(s) and use them as alternatives, if they so wish, to the "RestHelper" class that is already built in to the ActiveVFP.dll (v:6.03+).

I'm a bit of a way off from poperly submitting this as a new proposed feature/add-in and in the meantime would like to exchange ideas with others as I go along.

BTW, this is being driven by my desire to design RESTful services similar to the way Twitter does - please see:

Looking forward to hearing from you all.

Best regards,
Aug 19, 2013 at 4:48 AM
My experience is with and PULLIng information from FoxPro tables. In summary I
create code that ends up spitting out a rest data set.

url/controller/keyfield --

is then called from within Appery and I then map individual items into either an Array element or 1 answer.

I followed the customer prg rest example.

One thing I've noticed is its way easier with tools like appery if I have 1 Answer back, or very few with everything stored in one place.

Which causes me problems ... because I often find myself stuffing answers into the 1st record of a result that actually came
from calculating transactions.

This entire Dance is needed because in appery you map out your Mobile app to a rest service and if you have more than one it because
more difficult because you have so many different drag and drop mappings to make.

its hard to explain what is happening. Obviously if I was a javascript programmer I would have an easier time.

It is working, I am getting data back and populating the mobile screens. I haven't touched the SEND data from the mobile device back -- Update piece because
of all the bugs with the rest service just getting data.
Aug 19, 2013 at 11:34 AM
Thank you, Simon.
Aug 19, 2013 at 5:02 PM
Hi Simon

I am doing PDFs at this time and it's been going great till now. If it works that well at any clients site, then I am sure I'll be starting another small module in 'MVC' type design. It would be great if you share your problems (and solutions to them) for new AVFP develops like me.
Aug 20, 2013 at 10:00 AM

Love to hear how it's going. Are you looking to build an extension or possibly to ensure the current REST handler in ActiveVFP?

While right now most of my work is using plain AVFP, I'm doing some work in the hopes of moving to a pure REST approach. It makes it easier for other devs who may be more familiar with the Twitter, etc approach you described above.

BigDreamer, are you using the Appery Builder or more of their back-end?
Sep 23, 2013 at 8:36 PM
Hi guys,

I'm very sorry for the delayed response - please don't think me rude.

To be honest, the reason why I haven't replied until now is because things have gone so well.
I've been very busy with a project for one of my customers implementing RESTful services with AVFP.

I initially thought that it would take me a long time to convince them that they could do the things they wanted better with RESTful like services. In the end though, I only had to produce a couple of prototypes to convince them it was the best way to do things. They quickly gave me the go ahead and I've been doing it for them ever since.

I've also got a customer that is asking me to build some mobile apps for use in their warehouse. I'm more than likely going to be using Alpha Anywhere to build the front end and hopefully mostly now AVFP RESTful services to do the rest.

Maybe a bit more on this a little later on...

All the best,
Oct 2, 2013 at 2:47 PM
Regarding AVFP REST in C/S (SQL Server)

1) To reduce ‘port exhaustion’ due to spamming attack, we need to open DB connection only once per page. The best way to handle this in non-REST implementation is to open the connection in the header section and close it in the footer section of AVFP page ( or just before oresponse.redirect() etc). This works just fine.

In REST implementations, we can do the same in the init() and Destroy() events of the Controller.
However, the RestController class does not implement these methods which are causing problems in my external debugger.
It would do no harm to existing installations if these two methods are implemented in RestController class.

2) To repeat my previous comments on this, we need to reference resources with full paths to avoid making environment assumptions.

e.g. replace

oJason = NewObject(‘jason’,’json.prg’)



3) I’ve recently started playing with AVFP ‘REST’.
I did not think it was possible but I am happy to report that I was able to call a Sample.AVFP page, both directly (i.e. non-Rest) and also from the controller. We just need to fill-in the missing oProp values in the Controller’s ‘action’. I doubt I'll do that in development but I am impressed by this flexibility.

For Example.

PROCEDURE listAction
*Set Step On
cHTML = ""
  • SET PROC to substr(oProp.AppStartPath,1,AT([],oProp.AppStartPath,2))+'prg\AVFPutilities' ADDITIVE && moved to Init(). Released in Destroy()
  • Load missing values of oProp
    oProp.Ext = IIF(EMPTY(oProp.Ext),".avfp",oProp.Ext)
cHTML= oHTML.mergescript(FILETOSTR(substr(oProp.AppStartPath,1,AT([],oProp.AppStartPath,2))+'Sample'+oProp.Ext))

Oct 3, 2013 at 1:54 PM
List of differences in oProp values when a page is called directly or when it is called from the controller. This relates to point 3 of my previous email.

Name : oProp.Ext
Direct : AVFP
REST : blank

Name : oProp.HTMLPATH
Direct : m:\ActiveVFP603\
REST : blank

Direct : Sample.avfp
REST : main.prg

oProp.RUNNINGPRG difference becomes significant if it's used in error handler/message, since it's the same for all controllers.
Oct 8, 2013 at 3:27 PM
This would be of interest to those decorating html elements of AVFP pages with jQuery. I found nothing in google for this problem and it's not very intuitive.

With the latest CDN version of Jquery mobile i.e. 1.3.2, you need to convert the following code

<input name="B1" type="button" value="Customers" data-role="button" onclick="window.location='URL.avfp'">

<a name="B1" type="button" data-role="button" href="URL.avfp">Customers</a>

...when the URL.avfp happens to be a 'dialog' page.

Otherwise, the 'close' button in this dialog page will not work. If may also create problems in the 'panels' of subsequent avfp pages i.e. panels may auto open when the page in loaded.


<input type="radio" ...... onclick="window.location='URL.avfp'">

still works fine.
Oct 8, 2013 at 10:09 PM
Hi Titu1

New user here, so, first of all thak you & all forum users for bringing great assistance, and specially to the developper's team.

Just did a few testing over RESTful, and noticed something similar to what you are describing. (slow image loading and js files),, then decided to move the full test tree

to a new folder and place the dummy.avfp file in it., that solved the issue , did not test the replacement fox code part on the page ( mostly ajax requests and html/js

/images) but extremely fast, maybe more than the normal avfp behaivour.( if possible) :)

(note: remember to convert css, js folders into aplication and call the avfp file frrom the restful-prg matching the new path)

I will do some more testing on (default paths,calls, code-replacement, or dbf reading during the next days.

Oct 16, 2013 at 12:59 PM
UPDATE: if anyone is experiencing issues like the one I described, then an upgrade from .NET 2.0 to .NET 4.0 ro 4.5 should solve that.

joke : [ is the first time ( in nearly 2.059 weeks in front of a keyboard) that something fixed by a simple update makes me sad ]