Connecting the Client to DataSnap Server

From Appmethod Topics
Jump to: navigation, search

Go Up to DataSnap Client Application


The following table lists the driver properties and their meanings:

Property Description
BufferKBSize Provides the maximum size of the packet that can be exchanged between the client and the server. The current value, 32, is recommended for the TCP/IP based protocol for optimal communication time.
CommunicationProtocol Accepts TCP/IP or HTTP, based on the transport type the server has.
ConnectTimeout Provides the expected connection time, in milliseconds. The connection time is defined as the interval between when the communication is initiated and the server socket is initially opened.
DSAuthPassword Currently used for HTTP authentication. The server is expected to have an authentication manager component linked to it that will process this value.
DSAuthUser Currently used for HTTP authentication. The server is expected to have an authentication manager component linked to it that will process this value in conjunction with the password provided. We recommend that both fields be filled or not.
HostName Machine name (or IP address) where the server runs.
PassWord Database user password for the case the server is expected to open a database connection and funnel client's database requests through it. If there is no server connection required, do not fill this property.
Port Provides the port value where the server listens for DataSnap connections. The value should match the one defined at the transport component on the server side.
ServerConnection Holds the name of the server connection that will provide the credentials for a database connection to be opened by the server. The server will act as a proxy for all database-specific client requests. Example: DSAdmin.GetConnection("ASACONNECTION").
URLPath Matches the context where the HTTP transport-based server listens for requests.
UserName Provides the user name to be used for the server connection. UserName is recommended to be empty if there is no server connection required.
DelegateName Optional. Stores the name of the delegate connection.
DelegateConnection Optional. Stores the name of the delegate driver. Delegate drivers provide an extra layer between the application and the actual driver. They are useful for connection pooling, driver profiling, tracing, auditing, and so on.


Note: It is important to have the connection in a context that allows the filters to be instantiated if such filters are defined at the server side. The unit that registers the filters must do that before a filtered connection is created.



TDSRestConnection

The TDSRestConnection component can be dropped from Tool Palette into a form or you can use it explicitly in your code. Turn off the connection property Login Prompt to prevent an authentication message window from appearing when you try to connect to a DataSnap server.

The following table lists the connection properties that need to be changed when you create a DataSnap Client Application:

Property Description
Host Machine name (or IP address) where the server runs.
Password Database user password for the case the server is expected to open a database connection and funnel client's database requests through it. If there is no server connection required, do not fill this property.
Port Provides the port value where the server listens for DataSnap connections. The value should match the one defined at the transport component on the server side.
Protocol Accepts HTTP or HTTPS, based on the transport type the server has.
UserName Provides the user name to be used for the server connection. UserName is recommended to be empty if there is no server connection required.

Note: If the HTTP protocol is to be used at run time, the DSHTTPLayer unit needs to be added to the uses list in the client application.

REST

Specific server methods can be accessed through the REST protocol. That can be achieved from web-based client applications based on JavaScript code, or native, using the DSHTTP unit.

Here is a code snippet of a native method that sends a GET command through the REST server service.

 procedure TForm1.SendGetRequest(var response: string; out responseCode: Integer);
 var
   http: TDSHTTP;

 begin
   http := TDSHTTP.Create;

   try
     response := http.Get(edtUri.Text);
   except
     response := http.ResponseText;
   end;
   responseCode := http.ResponseCode;

   http.Free;
 end;

See Also