REST Migration from CF 11 to Lucee

We are currently running CF 11 on Windows Server 2016 & IIS. We are looking to migrate to Lucee.

Nearly everything is fine except the REST services.

We setup our REST mappings in the Lucee admin as per how they were in CF11.

Is there additional setup documented somewhere that needs following for Lucee, IIS and REST fresh install?

When calling the REST URL it just gives a 404. When calling https://my-domain/rest it shows the REST services that have been setup as excpected.

We keep the folder outside the root of the web directory.

The URL will be something like https://my-domain/rest/mapping/cfc_name/rest_path_var

Does the IIS Connector need additional setup or is there extra config changes required for IIS. I cannot seem to find any documentation for it.

Is there a big difference in the way it works compared to CF 11?

Im hoping that there is a bit of documentation somewhere that I have missed that gives an idea on what needs to be done

Can you check in your lucee install directory for a file called conf/web.xml, which is a big XML file and you should check that an servlet entry like the one below is there and not commented out.

  <servlet>
    <servlet-name>RESTServlet</servlet-name>    
    <servlet-class>lucee.loader.servlet.RestServlet</servlet-class>
    <load-on-startup>3</load-on-startup>
  </servlet> 

You can then go to the lucee administrator and create the mappings as required:
http://my-domain/lucee/admin/web.cfm?action=resources.rest

So for example, for “virtual” you could put “mapping” and for physical that would map to your folder outside your root directory.

Then check it with the local port of lucee (which should be 8888 to ignore IIS) and if that works, then try it with IIS .

If that DOESN’T work (and I am no expert at IIS here) but what you would need to do is tell it that all requests to /rest are handled by the same handler that does .cfm and .cfc (request handlers? can’t remember the name off hand)

HTH

Thanks for the reply.

The servlet is not commented out but does have load-on-startup set to 2.

The mapping I have already added, and if I tick the “list services” option it does show when going to http://my-domain/rest. I have confirmed file paths. The mapping is the same as the CF 11 one I had.

If I eliminate IIS and use the Tomcat port on the following url - http://my-domain:8888/rest/mapping/cfc_name/rest_path_var

Page …/…/…/…/…/null [C:\null] not found

Ok, a reboot of the server and this issue goes away and the rest service request appears to work fine now when called on the local tomcat instance.

So this leaves IIS. Is there additional configuration / connector changes that need to do done to get the REST services to work?

If I add a handler in for BonCode to deal with /rest/* then the list services page works. The URL doesnt. It just gives the following error:

no rest service for [/mapping] found

I have found adding the following Handler to IIS allows for the REST Services to respond correctly:

image

Just hope that it doesn’t have adverse effects else where. On initial viewing, everything appears to be working everywhere else.

Did I miss some documentation for this?

Hi @twela,

Here I given simple REST services

Need to enable Rest servelt mapping

Go to Admin -> Archives & Resources -> Rest

  • Enable the check box List services

  • Add the mapping like below:

Example:

Vitrual Path: /testRestService

Physical: E:\projects\Lucee_Core_Dev\Rest\

Check: Default

Create CFC here
E:\projects\Lucee_Core_Dev\Rest\Hello.cfc

Copy the below code & paste it in Hello.cfc

<cfcomponent rest="true" restpath="/hello"> 
    <cffunction name="myHello" access="remote" returnType="String" httpMethod="get" restPath="/world">
        <cfset res="Hello World">
        <cfreturn res>
    </cffunction>
</cfcomponent>

Hit the URL like:
http://localhost:8888/rest/testRestService/hello/world

It return Hello World

1 Like

At the moment the Request Path is handling EVERYTHING through Lucee, I would change it (if you can?) to something like /rest/*

I did try /rest/* originally, along with just /rest/my_mapping/* but these had no effect. It only worked when I passed everything (*) through.

I have no issue with passing it all through as its all CFML that we produce it in. Although I was concerned about static files such as css/js etc.

These all seem to work fine though.

I have been assuming I am just missing some obvious documentation if this doesnt work “out the box”. I assume others must be using IIS along with Lucee and REST services.

Both Windows Server 2016 and Lucee / IIS are a fresh install.