Web Connection
Rest service - where do i set the data path
Gravatar is a globally recognized avatar based on your email address. Rest service - where do i set the data path
  VFPJCOOK
  All
  Nov 11, 2022 @ 11:19am

I have ONE VFP/VFE app using a native VFP database engine (call it myapp). I have multiple companies/installations using myapp. Multiple instances of myapp are running on a single cloud server, so: c:\company1\myapp is home dir c:\company1\myapp\data is data dir for company1's installation of myapp c:\company2\myapp is home dir c:\company2\myapp\data is data dir for company2's installation of myapp etc Each instance of myapp is completely independent of another i.e. Company1's myapp does not know that Company2's myapp exists.

I have developed a website (nothing to do with FoxPro) that needs to pull data from and post data to, Company1's and/or Company2's system. The website will make calls to a WC REST service to accomplish that.

I am developing the WC REST service. Somewhere in the WC REST service I will need to point to Company1's system or Company2's system. I am trying to determine the appropriate place to do that.

wwServer has: OnInit() server specific configuration OnLoad() app specific configuration

wwProcess has: OnProcessInit() runs just prior to each endpoint's method in wwProcess

Assuming the website can provide some piece of information that will tell me which company's system it needs access to, it sounds like I would point to the appropriate company's system in the wwProcess::OnProcessInit() method. When I say "point to", basically I mean set the VFP data path.

Does that sound correct?

Thanks, John

Gravatar is a globally recognized avatar based on your email address. re: Rest service - where do i set the data path
  Rick Strahl
  VFPJCOOK
  Nov 11, 2022 @ 12:48pm

There are a few ways that you can handle this:

  • Use explicit, parameterized paths for everything customer specific
  • SET PATH for each request (tricky)

Explicit Paths

The first can be a lot of work, if you don't use business objects, but otherwise you should be able to set the path at the business object (or framework) level for subsequent data access. If you do it explcitly, you just have to prefix any files referenced explicitly:

lcFolder = lcCustomerSpecificPath && from whereever you get this
lcCustTable = ADDBS(lcFolder,"CustomerData")

select * from (lcCustTable)  

*** or
USE (lcCustTable) in 0

Make sure you parameterize your paths in some way that is consistent - you don't want to hard code anything and have easy access to the path since you'll need it a lot!

SET PATH

You can also SET PATH on every request that comes. Essentially in OnProcessInit() you can re-write the entire FoxPro path to the 'default path' the application expects plus your custom path.

It's important you put your complete path handling into that code in case a request fails to reset it - better to make sure you have the correct path at the beginning of each request (in OnProcessInit()).

FUNCTION OnProcessInit()

*** Base path. Best to parameterize
SET PATH TO (this.oServer.cAppBasePath)

*** Or hard coded
* SET PATH TO "\myAppFolder;\globalData;\wconnect\classes;\wconnect"

lcTenant = "customerId"  && however you figure out your customer's tenant

*** Add tenant specific path
SET PATH TO "\data\" + lcTenant ADDITIVE

ENDFUNC

+++Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Rest service - where do i set the data path
  VFPJCOOK
  Rick Strahl
  Nov 18, 2022 @ 02:44pm

Thanks Rick. OK, I believe I understand the best place to set pathing.

I am going to ask a question that may not make any sense at all but here goes:

Years ago, I made my Soap based ASP.Net Web Service (the VFP part), a VFE project. It gets compiled into a MTDLL. IIS runs ITFWebService.asmx which if I understand correctly, calls the methods in ITFWeb.DLL. Those methods are OLE PUBLIC because the VFE application object is marked OLE PUBLIC.

For my WC REST service, can you tell me exactly what IIS is running?

Thanks, John

© 1996-2022