This past week one of our future customers have been trying to integrate with our web services without success; all the support process has been a bit complicated for several factors: first of all was they were the first customer integrating with us who did it using Delphi and our support department couldn’t benefit of previous knowledge. Another one was that they don’t have employees who can read nor speak other language than French, so we should make use of the Google Translator English – French – English and lot of imagination, but this was not a problem, I always say that when two parts want to communicate the communication is always possible.
The thing is that one week is a lot of time to finish the integration (we had customers integrating in a couple of hours), so we wanted to provide to our customer a solution in order he can start working with us a soon as possible. Today we decided to try to write some sample code for him, even if our developers are all .NET developers.
When I knew that they were using Delphi I felt a bit melancholic, I started working as a Delphi developer in the ’98 building some CGI with version 3.0 … I’ve tried to resist but I couldn’t avoid it … yes, I know … don’t say anything … I wanted to see what is the current look of Delphi and try to write the code myself.
Following the suggestions of our customer I’ve visited the page CodeGear looking for the Turbo Delphi 6.0. The installation already pissed me off, has anybody seen the list of prerequisites? I can understand some things like the Microsoft .NET Framework, IE6 (this is also questionable …), MSXML, but why should I install the Microsoft .NET SDK (Software Development Kit) v1.1? and Visual J#? there must be a confusion … I mean, I want to develop with Delphi not with .NET … maybe my subconscious has betrayed me and I downloaded Turbo Delphi for .NET … but it was not the case, so again I ask myself: Visual J#? Well doesn’t matter, there must be a good reason for it and anyway I have Visual J# installed.
The first impression after open the IDE is that is quite similar to Visual Studio, the distribution of the windows are almost the same, I have the equivalent to IntelliSense, refactor…all seems very straightforward and I don’t need to read too much code to get an idea of the syntax. It’s time to consume webservices.
After look through almost all the menus and options I find the WSDL importer and after run it I get a kind of proxy with all the necessary classes imported. I get surprised because some types are not used directly but wrapped in structures, like decimal or datetime, everything works fine for simple services but there is one a bit more complex that doesn’t want to work. At this point I need to look in the documentation and my first disappointment appears, I cannot find anything that gives me a clue about what can be the cause. I add a trace module in the webservice to see what I receive from Delphi and there are some weird things like a value 1.0 converted to 56XXXXX.25 (I don’t remember the exact amount).
After lot of different tests I take a break with SOAP and I try another approach: use a simple POST request. I look for a class similar to the HttpWebRequest and after some “googling” (I couldn’t find anything on the documentation and I really miss the MSDN), I see that exists a component that I can drag and drop on a form, but this component doesn’t appear on the Toolbox. For a while I thought the component is a third party library not included with my version of Delphi, but then I see it’s part of Indy, which I remember a radio button asking for version 9 or 10 when I was installing. So I know I have the class, I only need to find in which namespace it is to declare the variable. With .NET I don’t have problems for this, I know where are lot of classes and I find quite intuitive the organization in namespaces, where can be this? Net, Networking, Web … where is the “Resolve” feature? … The unit I needed to add is the IdHTTP, I found it in the IndyProject, where I can see all the documentation regarding the classes used for HTTP requests, there are no search option or samples, but I have lot of patience.
The class I used has a “Request” property where I can set all the headers for the http request, it makes sense until I get my first exception: something like “Host empty”… how is that possible if I’ve just set the “Host” property? I rewrite the code in another way, at the end I don’t need to set most of the headers, since they are already defaulted. A new problem comes out when I try to connect through HTTPS instead of HTTP, it seems I need to set a different IOHandler. This is extremely cool since in the hypothetical case I want to build my own handler to manage the SSL connections I can do it without build a different class to perform an HTTP post (I pretended to be ironic). I find in the IndyProject a SSL Handler which I think I read is an implementation of an open source library, the first try doesn’t work and throws a very intuitive Read time out exception, I say intuitive because was nothing related to it…I’m not going to extend this post much more because the amount of complains grows exponentially, the important is that at the end it was working.
At the end I saw Delphi 6.0, I know this is not the last version, but really I don’t want to see it again for a long time, I took me one day to figure out how to consume web services via HTTPS using soap and post requests. I recognize that after all this time working with .NET my brain is totally focused to what I know, but even if I criticize MSDN because doesn’t have as much samples as it could have and some of them doesn’t work, being honest the documentation I found about Delphi is very very poor comparing to what you can find in the MSDN about C# and I don’t want to talk about lot of other important things about .NET.
Really, the only thing for which I would recommend to work with Delphi now is to migrate it to C#. Of course this is just a personal opinion and I’m sorry if I offended anybody, but for me there is no comparison possible.