I am admittedly a hacker…but I love coding, and learning. I am frustrated with mappings…I seem unable to learn how those work, and I spend hours trying to figure them out. Here is a case in point.
I am planning to use IIS to host a rest api. I have built the rest api on localhost (my development environment). I created a script to complete the mapping in Lucee (api). After calling that script, the restAPI is created with the proper mapping in Lucee and works great, when I call the api at:
I decided to deploy to IIS, and to host the api on a subdomain, which I set up as a separate IIS website. I can run the script noted above, and the mapping is created in Lucee, but I am unable to access the rest service from that site, or from any other site (including the default site) in IIS. None of the following work:
How do I tell IIS that Lucee has a rest mapping? I tried adding a “virtual directory” in IIS to the new site with the same value (rest), but that didn’t work (note, my IIS hosts multiple sites). I did lots of googling, and tried this (step 6 in particular, with an IIS restart):
But no joy - I get an IIS 403 (don’t have access) or 404 (resource not found) error. I am sure this is very easy, but I just don’t understand how the web server (IIS in this case) and lucee “relate” to each other on mappings. I can’t seem to find a clear article or video that explains this.
Boncode (appears in the default list of IIS handlers for cfc, and cfm)
Uses built in CF Rest, so the “mapping” reported under “Rest” in lucee web administrator is “api” and to access that the path is “localhost:8080/rest/api/…” I configured this following in part instructions here (A simple app using Angular and Coldfusion REST API - YouTube) though I have also set the “api” manually in lucee, as set out here (RESTful Server - Part 1 - YouTube). Either way, the rest/api is running on my lucee/IIS environment (or at least is registered in lucee).
Perhaps my misunderstanding of what a “mapping” is IS the issue. I am not sure how to tell IIS that the “rest” service with the mapping above (in lucee) exists? To call the api, I would like to pass an URL string…how do I tell the web server (IIS) that “rest” is a service available from lucee using that URL string? Neither “rest” nor “api” are “real” or even “virtual” directories to windows/IIS, so an URL string with a subdomain that includes “/rest/api” is meaningless to IIS? How can I tell IIS that “/rest” exists, and that “/api” exists within “/rest” consistent with my configuration in Lucee?
standard lucee installer. Note, I have other CF applications running successfully on IIS
Got it. I’m not going to be much help if your issue lies in the built in REST. I hate it and it’s generally crap IMO. I’m biased, but I’d suggest you look into ColdBox REST in the future
Ok, so right there I can tell what one of your issues probably is. Unless you’ve configured a wildcard mapping, Boncode is ONLY going to proxy requests ending with .cfm or .cfc to Lucee as you can see in your handler mappings. You need to create a mapping in IIS that tells it to send /rest/* requests to Lucee. I’m not sure if /rest/* is the correct path or not. You may need to do a * mapping, but you have to tell it NOT to check for the path to be real. That will get your requests flowing to Lucee. You can copy one of the existing boncode mappings to create the new one.
And finally, you need to check in your web.xml and see if the /rest servlet mapping is uncommented so Lucee’s REST servlet is grabbing the traffic. But this step comes after you’ve got IIS passing the traffic. In fact, I’d test hitting Lucee’s HTTP port directly first to see if it works, then add IIS/Boncode in the mix.
Thanks - getting closer. I had added the new Boncode handler, and I can get the rest service working on the lucee port. I understand now I don’t need to create the mapping in IIS, other than through the handler. Just need to tweak the path in the handler…