DataSnap 2010 HTTP support with an ISAPI dll

Posted by on in Blogs
With DataSnap in Delphi 2010, you can develop DataSnap clients and server that communicate over HTTP.  One way to implement the server is as an ISAPI dll.  I've been given permission to show this feature pre-release.  See for for more information about the upcoming release.

Click these links to skip ahead Configure IIS, Connect with Data Explorer, Ancestors and DataModules, ISAPI debugging

In the File/New… dialog, double click “DataSnap WebBroker Application”


Check “ISAPI/NSAPI Dynamic link Library”,  “Add Server Methods Class” and “Include sample methods”.

Select TPersistent as the ancestor class for the server methods.  I will say more about the ancestor choices later in this post.

Click OK to create a new project.


The new project has two units.  ServerMethodsUnit implements the server methods for this DataSnap server.  There is a single server method called EchoString with a string parameter (see my previous posts to learn more about server method parameter types).

The WebModule contains the components that make this ISAPI dll function as a DataSnap 2010 HTTP server. 


DSServer1 and DSServerClass are the same components used in stand alone TCP/IP DataSnap servers.   DSHTTPWebDispatcher is new to  DataSnap 2010.  It is responsible for managing ISAPI/WebBroker HTTP requests and responses on behalf of the DataSnap Server. 

Both DSHTTPWebDispatcher1 and DSServerClass1 components have their “Server” property set to “DSServer1”.  The DSServerClass1 component calls an event handler to get the type of the server methods class:

The wizard has generated a complete ISAPI application so no changes are required to the project source code, however I do need to configure IIS.  

Configure IIS

Here is how I configure IIS 6.0 on my Vista x32 system.

If you haven’t enabled IIS on your system then use “Programs and features”/”Turn Windows features on or off” to install.

Start Internet Information Services (IIS) Manager.

Expand Connections nodes, right click on “Default Web Site”, choose “Add Virtual Directory”.

Enter an alias of “DSProject” an a physical path of "c:\DSProject".

ISAPI must be enabled for this virtual directory.  Select the “DSProjects” Connections node.  Double click the “Handler Mappings” icon.  Click Actions/“Edit Handler Permissions…”.  Check “Execute”.

Directory browsing is convenient but not required.  Enable it for this example.  Select “DSProjects” Connections node.  Double click the “Directory Browsing” icon.  Click Actions/”Enable”.

Almost done configuring IIS.  Click on the root Connection node.  Double click the “ISAPI and CGI Restrictions” icon.  Click Actions/”Edit Feature Setting…”.  I have “Allow unspecified ISAPI modules” checked.  If you don’t check this then you will need to add to the list of ISAPI dlls recognized by IIS, after you have built your project. 

Now go back to Delphi 2010 and set the output directory to the virtual directory physical path c:\DSProject. 

Build the project.

Browse to http://localhost/DSProject and, if you have enabled directory browsing, you should see the ISAPI dll.  Click it.  You should see a page like this:

The following a wizard generated line of code provide the default content:


At this point it looks like our ISAPI dll is properly configured.  Now I can use the Data Explorer to test connectivity.

Connect with Data Explorer

I prefer to use the stand alone DataExplore.exe when testing connections rather than the RAD studio Data Explorer view, just in case there is a connection problem that causes the client to become unresponsive. 

Start DataExplorer.exe.  Right click the DataSnap node, choose add connection.  Enter “NewConnection”.  Click OK.

Expand the DataSnap node, right click “New Connection” and select “Modify Connection”.

Set Protocol to “http”, Host to “localhost”, Port to “80” and Path to “DsProject/Project1.dll”.

Click “Test Connection”.   Click OK. Click OK. 


Expand the NewConnection/Procedures node to see that EchoString is a server method.

To test, right click on the “EchoString” node and choose "View Parameters". Select the "Value" parameter and enter some text for the "Value" property. Right click and choose "Execute" (or click the the  image button in the upper left of the view parameters window).  

At this point I’ve created a server, configured it to run under IIS, and connected to it with DataExplorer.   The new DataSnap 2010 HTTP client features will need to be covered in another post.

I have two additional topics to cover.  First is this ancestor issue I mentioned near the beginning of this post.  Finally, I will add a few words about debugging.

Ancestors and DataModules

This example used TPersistent as the ancestor of our server method class.   The other choices, in the wizard, are TDataModule and TDSServerModule.  Use TDataModule when you want to use components in your server methods.  Use TDSServerModule when you want the equivalent of TRemoteDataModule.

When using TDataModule or TDSServerModule, there is an important requirement that only affects WebBroker applications.  Be sure that the there is only one module created during startup.  Use Project/View Source… to see this code.  The only module created here should be the WebModule. 

The project source should look like this:

Something like this will result in an exception with the message “Only one data module per application”.

ISAPI Debugging

In case your ISAPI dll isn’t working properly because of this or other issues, here is how I configure my project for debugging.

In project options, set Host application to the location of w3wp.exe and the Parameters to “-debug”.

You will need to stop IIS before debugging.  Use the IIS manager or [c:/]net stop w3svc.

When you run the application, you should see a prompt like this:

When you stop debugging, w3wp.exe will be shut down.   When you are done working on your project, restore IIS with [c:/]net start w3svc.


  • Guest
    Dan Palley Thursday, 20 August 2009

    Jim, we have existing datasnap servers (Delphi 2007) using a main RDM and child RDM's. Will we be able to rewrite these to use the new Datasnap features in Delphi 2010?

  • Guest
    Jim Tierney Friday, 21 August 2009

    This example, which demonstrate RDM in DataSnap 2009 server, may help you answer this question: DataSnap 2009 only supported TCP/IP. HTTP would be easy to add with Delphi 2010.

  • Guest
    Rene Pijnacker Saturday, 22 August 2009

    tnx for the configure tips for isapi in IIS. Can someone check and extend this for IIS 7.0 running in x64. Can't get the delphi 9.0 webserver dll's running (working ok on 32 bit Xp in IIS 6.0)

  • Guest
    wg l Saturday, 29 August 2009

    I prefer websnap more than intraweb ,but not found any improve in delphi2010.

  • Guest
    Peter Adrian Monday, 31 August 2009

    Does it work with C++Builder 2010?

  • Guest
    Jim Tierney Sunday, 6 September 2009

    Peter, C++ Builder 2010 provides support for client side development. A C++ client side class generator is new for 2010.

  • Guest
    Cestbienmoi Sunday, 22 November 2009

    Not really new.
    In Delphi 5 with MIDAS (old name of DataSnap), we use http(s) protocol to communicate (with HTTPSRVR.dll).
    The main problem was to add authentication level "transparently" but not very hard to do ;)

  • Guest
    wg Tuesday, 23 March 2010

    IIS7 report: 405 method not allow

  • Guest
    Durtaut Benoît Wednesday, 19 January 2011

    I have the same message on IIS7

  • Guest
    Durtaut Benoît Wednesday, 19 January 2011

    Someone can help me ?

  • Guest
    Vahan Yoghourdjian Tuesday, 15 March 2011

    1. I can't seem to find "ISAPI & CGI Restrictions" icon among my features in the IIS Manager.
    Am I missing anything? should I add it somehow?

    2. what's a dataExplorer? should I have it on my Windows 7? or is it a Windows Server application?

    3. where do I write "[c:/]net stop w3svc" and "[c:/]net start w3svc"???

    4. Any idea about a free/efficient Database System that I can use with my DataSnap application?

  • Guest
    Andres Arellano Wednesday, 25 May 2011

    When I test the connection using Data Explorer, send me the error 405 method not allowed on IIS7
    Could you help me please?

  • Guest
    mehmet oruç Wednesday, 27 July 2011

    when I test datasnap server/client (RDM , TDSServer , Tsqlconnection , IBconnection , dcomconnection.....) it runs on local machine properly. But on different PC , I get "access denied" error

  • Guest
    Lv Shisheng Tuesday, 27 December 2011

    Hello Jim:

    When I use C++ Builder XE following your article,it works correct in win7(32bit) ans IIS 7.0(32bit),and deployed in a machine.
    But when I deploy the same dll in Windows 2008(64bit) and IIS 7.0(without installed XE2),when I click the dll,it will show file download dialog.
    Can you help me?

  • Guest
    Jim Tierney Tuesday, 27 December 2011

    IIS doesn't recognize this as an ISAPI dll. Here is one way to enable ISAPI support IIS 7:
    - Start IIS Manager
    - Select the machine in the tree
    - Select the ISAPI and CGI restrictions icon
    - Choose the Open Feature... command
    - Choose Edit Feature Settings...
    - Check allow unspecified ISAPI modules

  • Guest
    Lv Shisheng Wednesday, 28 December 2011


    I reinstalled all components (such as asp) of IIS 7 in Windows 2008,and it works correct.

    When I browse the link ,it can show the response,but when I connected with XE2 Client,it show the error:
    Borland.Data.TDBXError:405 Method Not Allowed.
    The link is:

  • Guest
    magic mesh door size Tuesday, 18 December 2012

    magic mesh door size...

    Jim Tierney : DataSnap 2010 HTTP support with an ISAPI dll...

  • Guest
    HuanChen Sunday, 13 January 2013

    Hello Jim:

    When I deploy the dll on my machine,(win 7 64bit,iis 6),I can see the Datasnap Server in the web browser,but when I connect the DataSnap ,A error occured ,HTTP/1.1 405 Method Not Allowed.

  • Guest
    KOFFI Friday, 14 February 2014

    merci pour pour l'article. J'ai lu que Datasnap ne sera plus documenté. Qu allons nous faire.

  • Please login first in order for you to submit comments
  • Page :
  • 1

Check out more tips and tricks in this development video: