Internet Technologies:cxp

Web server-based CXP Foundation

Web server-based CXP can be compared to PHP or ASP.NET, where your scripts or binaries are executed on the web server. The benefit of this scenario is that your web application scales automatically and does not need to take care about delivering static HTML pages since this is done automatically by the web server. Only the requests to resources ending with .cxp are processed by the cxp-worker process. Of course, the drawback of this scenario is a setup and configuration management which is more complex; the web server, the FastCGI configuration and the web server-specific CXP configuration, all these areas must be managed by you for your application to work correctly.

The following illustration shows the flow of a web request with web server-based CXP:

1 Your browser or any other HTTP client, for example, an Xbase++ HttpClient object tries to access a resource via an URI. The client finds the host, in our case a web server and sends the HTTP request to this server.

2 The web server, usually a Microsoft IIS or Apache instance, receives the request and checks the URL to see if the requested resource is handled by CXP. This is done by simply checking the extension of the resource addressed in the URI. If the extension is .cxp, the web server routes the request to the FastCGI inter-process communication gateway.

3 The FastCGI gateway now forwards the request to either an existing cxp-worker process, or to a dedicated cxp-worker process which is spawned for handling the request. This behavior can be configured via the FastCGI configuration. CXP is able to operate both ways. It should be noted that a re-use of cxp-worker processes leads to an increased performance since repeated CXP page load operations do not occur anymore. You can also configure via the FastCGI configuration how many cxp-worker processes are allowed to run, and the timeout the web server waits for content from the cxp-worker until it returns with an HTTP error 500.

4 Finally, the cxp-worker process receives the request, checks if all resources and binaries are available and executes the :render() method of the CXP page.

5 If the resources are not available, the cxp-worker spawns the cxc-builder to transpile/compile and link the binaries of the CXP page. Note that in such cases, the loading of the CXP page binaries also leads to a :load() method invocation. If the .cxp file is not found and no binary is available, a HTTP status 404 is returned. If the .cxp file is missing but the binaries are available, the request is processed simply by executing the existing binary in the application's cxp-application folder. It is therefore legal to delete .cxp sources files after the binaries have been created.

6 After the cxp-worker has processed the request, it returns the generated content, the HTTP protocol status code as well as a status text to the FastCGI gateway, which in turn makes the data available to the web server.

The web server then as a last step delivers the HTTP response to the client which displays the view using the data received.

Configuration of web server-based CXP

The configuration of a web server for CXP is the same for all web servers supporting FastCGI, which is a prerequisite for using CXP in conjunction with a web server.

1 First, you need to install FastCGI for your web server.

2 Second, a handler must be set up for your website which routes all *.cxp requests (POST/GET/PUT/DELETE...) to the installed FastCGI gateway.

3 Ensure that the handler mapping points to the cxp-worker.exe in your \program files\alaska software\cxp20\bin directory.

4 Also check that .cxp is a supported MIME type of your web server.

In the event you are using Microsoft IIS, most of these steps are automatically performed for you by the Xbase++ installer. You only need to make sure that FastCGI is enabled within IIS prior to installing your Xbase++ MSI package. Only the Xbase+++ for Web product feature is required for using CXP. This will install the Compiled Xbase++ Pages as well as configure the IIS for CXP.

You can watch a video about "Compiled Xbase++ Pages installation and first steps" here: https://youtu.be/G3e_btI7oSU

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.