Delphi 2010 DataSnap Client with HTTPS - delphi

I have a DataSnap server written in Delphi XE3, deployed as an ISAPI module with SSL.
I'm writing a client application for this server, but it has to be written in Delphi 2010 for now. I'm having trouble connecting to the server through HTTPS. I have no trouble connecting to the server through HTTP.
I can write a client in XE3 that connects through HTTPS and succeeds, so I know the server is working fine.
The error I receive is:
Protocol HTTPS can be used after an adequate instance of TDBXCommunicationLayer is registered with TDBXCommunicationLayerFactory.
I've googled the solution to a problem like this and was instructed to add DSHTTPLayer to the uses clause of my unit, and that works for HTTP, but it's not working for HTTPS.
Any ideas out there? Thanks a lot for your time.

I ended up using TIdHTTP and TIdSSLIOHandlerSocketOpenSSL components to connect via HTTPS. I parsed the JSON with a TJSONParser. Delphi 2010 doesn't support HTTPS through the TDSRestConnection.

Related

IIS Hosted RAD Server sending request to another server

I have a rad server application hosted in IIS.
Client send requests to this rad server and server respond to it - all fine here.
but now, certain times, to cater the client's request, the rad server has to send request to another server. (for ex : jasper report server).
my problem is, when the client requests such a request, the rad server fails to execute the request to the jasper server, and in browser  when I test this request I get the response : Client : REST request failed: Error sending data: (12002). Ideally it should have downloaded a pdf and placed it in the documents folder. Such requests works perfectly when I run from RAD development server. But the RAD Server hosted in IIS fails to do this.
The endpoint is /GetReport which calls a function called DownloadReport (written in a datamodule) which will execute a TRestRequest.Execute which requests for the report from the jasper report server. But here, the .Execute wont just get executed at all no exception are thrown either inside DownloadReport method.
I turned off firewall in bother the systems. Is there something that I must configure in the RAD server application's INI so that the RAD server can communicate to another server ? or is there anything that I should configure in IIS ?
Can somebody help me to resolve this ?
I could solve this as follows :
The TRestRequest object which sends request to the Jasper Report Server should have its property SynchronizedEvents set to False. When ran from the RAD Development server, this property should be set to True.

Connecting between IIS Express and Jetty on Azure Cloud Service Virtual Machine

I have an Azure Cloud Service Virtual Machine with 2 server:
Java project using Jetty server at http://localhost:8999
ASP.NET MVC project using IIS Express at http://localhost
I am using Http request to make connection between 2 server.
In my VM, inside ASP.NET MVC project, I use http://localhost:8999 to get data from Jetty server. It works perfectly with short response time (from 100ms to 6000ms).
However, when I access the IIS Express via Internet using http://mydomain.cloudapp.net. It does not work anymore.
Then I change my config file in ASP.NET MVC project to use http://mydomain.cloudapp.net:8999. It works but with long response time (from 15s to 40s). This is because of my slow internet connection.
My question is:
If I access IIS Express via Internet, to avoid external internet connection, is there any solution which let IIS Express know that it's target is local?
Which means I can still use http://localhost:8999 in my config file in ASP.NET MVC project, and it still work if I access IIS Express via Internet not only via localhost.
The main question is how you connect between the two servers? From the client side (JavaScript) or the ServerSide (Controller action/private method).
From what you describe it seems that you make XMLHttpRequest (JavaScript, AJAX, jQuery, etc.) call from your client side directly to your Jetty Server. In order to avoid roundtrips, you have to change this and make XMLHttpRequest to Your Server (MVC), then on the MVC backend (Controller action, or private method, or Repository) make the Jetty server call and transparently return the answer to the calling client.
You can also try tweaking your Jetty Server settings to allow for longer script execution.

DataSnap REST server - enable HTTP KeepAlive

I'm using Delphi XE2 to build a DataSnap HTTP REST server to run as a service on Windows 2008. I read somewhere that by default the HTTP 'KeepAlive' is disabled for DataSnap server projects, if so can somebody help as to how to enable this. Thanks.
The Server has a property KeepAlive, which should be set to true.

How to make a simple proxy server?

I wanted to create a simple proxy to my localhost(xampp). I've looked into IdHTTPProxyServer but there is no available example of how to use it.
my intention is to monitor the Post/Get request of my application at runtime just like a debugger.
my application will Post/Get through localhost:8080 and then my proxy will be served as a bridge to localhost:80
any suggestion or example?
I am using D2009, D2010 must support Unicode.
Thank you in advance.
I know it's not Indy, but Synapse (I use it with Lazarus) has a Proxy Server Example included which should work on Delphi too. It worked well for me on FPC. The Demo is included in the Sources you get here:
http://www.ararat.cz/synapse/doku.php/download
You may use Overbyte ICS TCP/IP library, on the "user made" page you have a lot of proxy samples, one is tgphttpproxy.

How to send email via SSL and Indy in Delphi 7

I want to send email to Yahoo mail using Indy. But Yahoo uses 465 port with SSL connection. I don't know how to implement that in my program. I have read about TIdSSLIOHandlerSocketOpenSSL component on internet, but couldn't find such component in Delphi 7. Can anyone help?
I have found that Synapse library is much easier to use. Look at the code example I use: How To Use SMTP with TLS
In Delphi 6/7 the component was called TIdSSLIOHandlerSocket. This was Indy 8/9. It still uses Open SSL. I don't know why they changed the name in Indy 10.

Resources