Hi Rick, I have been wrestling with adding an API rest service to an existing project as a process class. My main project exists in c:\webconnectionprojects\publishing and works fine, I get all the results I would expect. I've even published the site to a Vultr cloud server (great tip, thank-you), registered the nameservers, created an A record, and presto, site accessible from anywhere (and blazing fast when I run it in COM mode). If I create a new project with just the REST service it works perfectly when I call it either using IIS Express or WebConnectionServer. I've written a very simple function which I can call using the scriptmap I set up in the project. However, if I add a REST api process to the existing Publishing project I cannot seem to access the virtual directory, even though I see it as a subdirectory in Windows file explorer. I've tried localhost:5200/name_of_subfolder/name_of process.scriptmap_extension and the same except :7200 The "main" page of the publishing app shows up, but the rest service cannot be reached via local host no matter what I do. I am obviously missing something, since the REST service runs perfectly under its own project. What should I change? Also, how do I see the settings I used when originally setting up either a new project or a new process class? Thanks

However, if I add a REST api process to the existing Publishing project I cannot seem to access the virtual directory, even though I see it as a subdirectory in Windows file explorer
Not sure what this means.
If you're adding a new process class you really shouldn't be using a new virtual directory (and in fact that no longer works with non-ISAPI extensions). In fact I just looked at the New Process Wizard, and removed the Create Virtual feature from it because that no longer makes sense.
The way this is supposed to work (using the Create Process Wizard):
- It adds new process class
- It assigns a new Script Map
- Each script map link maps to its specific Process class
- One Web Site/Virtual
- One Web Connection Server (Exe)
The new scriptmap routes to the new process class in the same virtual folder or Web Site. The extension is used to differentiate between the two separate processes.
If you need completely separate virtuals/sites, then you should create a new server.
In short:
- Use a new Process if you want multiple sub-modules in a single EXE
- Use a new Project/Server if you want separate Web sites/Virtuals
+++ Rick ---
Okay, I think I've got it. I'll give that a go, and thanks again.
Hi Rick, I've brought the sample Publishing site live by going through the steps in your 2022 blog entry on deploying. It has worked like a charm. I have got my API site working on my production environment and want to publish it, using the same domain name as the Publishing test site but using the api site instead. Is it simply a matter of running the build.bat on the API site and copying it to the Vultr server (c:\webconnectionprojects\citapi\web) and changing the physical path from c:\webconnectionprojects\publishing\web to c:\webconnectionprojects\citapi\web in IIS Manager?

I have got my API site working on my production environment and want to publish it, using the same domain name as the Publishing test site but using the api site instead.
I have no idea what this means...
You either:
Run your main app and service on the same server instance and same domain
Easiest. This way you have a single Web Connection server with two separate process classes and script maps, and a single Web site. You make all calls on the same domain (so you need to CORS for cross-site API calls) and make callbacks into the same domain.
If possible this is the way to have the easiest deployment and build setup.You set up two domains (ie.
yourdomain.com
andapi.yourdomain.com
) and deploy the API separately
This is obviously more work because you end up with two applications, two sets of COM instances, two Web sites to manage etc. You can potentially also do that without the second domain and use a virtual below the main domain, but setting up a separate domain is just as easy and ensures you're running in a simpler off-root environment that likely matches closer to what you're doing in development with the dev servers.
Choose this option if the applications are truly separate and don't share common functionality or you absolutely have to separate the domains.
Be aware running the same COM server on multiple sites is difficult to get right and not recommended. If you're building multiple COM servers, make sure to never copy a project without changing the COM ids. Otherwise you end up with two COM servers with the same ClassIds which will give you endless grief. If you create two projects always create a new project and either re-build and auto-import or copy the project content into the new project explicitly.
+++ Rick ---
Hi Rick, I have tried several times, going through the steps exactly as laid out in the tutorials to add a REST process class to an existing webconnection project. The wizard indicates the process class has been created, yet when I try to access the api class (which works perfectly when in its own project) I get an "unhandled" error back from my call to the service. The reason I have asked about simply replacing the existing project (the non-API rest one) with the REST one is because I only need the API Rest site up and running. I'll reword my question. 1) I have an existing Web Connection Project running which I do not need and want to replace with the API site, using the same domain name, just pointing IIS manager to the new web connection project folder. Can this be done? I am not looking to have two sites running, only one. I'm seriously stuck, and would really appreciate some pointers. Thanks again.
If you want to have one site running you need to have it all in a single server instance.
You can create a virtual, but that effectively behaves like another site in how IIS looks at it.
Are you:
- Making sure you create the script map when you run the Wizard?
- Using the script map for your API calls?
You can check if the Wizard works:
- Open YourAppMain.prg
- Go find the Process() method
- Look for your extension in the list
- Check and make sure the process class exists
- Make sure the methods you're calling are going to the right process
You can set a breakpoint in the Process()
method and step through to see what's going on.
+++ Rick ---
Hi Rick, Scratch my last post, I figured out what I've been doing wrong. I had added the REST process class to the project and then rebuilt the project in Foxpro. What I hadn't done was recompile the project into an EXE/COM. I figured by using SET DEVELOPMENT ON I didn't need to recompile in order to test, but after I did recompile the REST processes ran successfully when I called them using the scriptmap extension. Now I'm wondering how I update the existing production site. Is it simply a matter of replacing the old EXE on the production server, with the new one from my development environment?
Hi Rick, Sorry about that, I do indeed read the documentation (a lot, it's really well-written), just getting ahead of myself. After reviewing the documentation, I believe I have to go into the .ini file and add my REST scriptmap (which is "cit"). I then run .\Publishing.EXE CONFIG (I kept the same app/project name as in your Deploying blog article). Then I "upload" and then "update". I've been doing this for forty-plus years and still get a bit jumpy when I bring something new live. I appreciate your knowledge and help, thank-you.
You're talking about different things:
- First Time Deploying
- Updating
First time deploy you use Build process to get all stuff up there and get it going.
Once you've deployed you likely only update the EXE and any script files (if any) and for that you use the update operations.
If your server is already running (ie. the original one that you're now adding the second process to) you're in effect updating the server.
+++ Rick ---
What is the best way for me to add the "cit" scriptmap extension to the server? is it by editing c:\webconnectionprojects\publishing\web\web.config and editing this line: add key="WebSocketProcessScriptmap" value="pb,cit" / original was add key="WebSocketProcessScriptmap" value="pb" or do I add an additional line: add key="WebSocketProcessScriptmap" value="cit" Also, to recompile the project EXE does it matter if I use:
- DO BLD_Publishing or b) BUILD EXE Publishing FROM Publishing.pjx