Board index » delphi » Delphi 7 - SOAP, and SSL

Delphi 7 - SOAP, and SSL


2008-07-19 02:15:48 PM
delphi67
Hi all. I am a long time Delphi user but self taught so I know just
enought to get me by but not much more.
I have been using XML over http for a while with no problems but now I
need to communicate with a web service using SOAP.
The problem I get is that the web server sends back an error to IE
saying a certificate is required.
This is even if I just try to access the WSDL file with an IE web
browser.
Pressing 'cancel' when IE pops up the certificate selection window
lets me proceed and I get the WSDL file displayed in IE.
If I try to access the file with Firefox or Opera I get no problems at
all, I just get the WSDL file.
I have tried the WebServices HTTPRio and as far as I can tell this
uses windows IE for communication because I get a message like
'certificate required' and the app stops dead with an exception.
If I just put the WSDL file location into the WSDLLocation and try to
select the 'Service' or 'Port' drop-down box I get the 'Choose a
Digital Certificate' pop-up box but clicking OK or cancel does not let
me proceed, I get an exception.
If I download the WSDL file and upload it to another ssl server I can
access it without a problem so I know the problem comes from the soap
server throwing back a 'cert required' in the first attempt at ssl
coneection but I dont know how to get around it in my app. (is not my
server and many other people access the soap but I am guessing not
with IE)
After spending nearly 8 hours on this, modifying the source as per:
bdnqc.borland.com/wc/qcmain.aspx
I have realised that the problem is the way IE first tries to
establish an ssl connection so I am guessing its a problem above what
delphi and rio can access.
So my nest step was to try INDY and see if I could avoid using IE, I
don't know much about it but it seems like using INDY does not use
windows IE because I installed OpenSSL and managed to successfully
access the WSDL file via ssl perfectly using INDY IdHTTP and
IdSSLIOHandlerSocketOpenSSL.
Like I said, I am a 'hobby' programmer so I am feeling around in the
dark here !
I cant say how glad I was to finally access the WDSL file on this
weird ssl server with Delphi !!
Now I thought I was getting close but I find I cannot use this
connection with any SOAP component I have in Delphi-7 Enterprise.
I did see a lot of talk about Indy and Indy SOAP thats why I tried it
but I find that the Indy-SOAP will not install for me.
I dont know much about installing packages but following the
instructions for installing Indy-Soap gives me errrors , it cannot
find 'Indy60' and searching my computer I find it does not exist ,
even on google I get few results. And I see that IndySoap was done
back in 2003 and was not tested on Delphi 7 but I found via google that
someone else had installed it on D7e without a problem :-(
I have now spent around 15 hours on this and feel I am very close but
have found that I am getting errors that are way over my head.
It seems I either need:
1) To get IE to connect to this ssl first time without throwing an
error, or
2) Get a SOAP component installed that uses the IdHTTP connection
(which can talk to the server on ssl), or
3) Somehow link the HTTPRIO soap component to use the IdHTTP
component.
I have sent a message to the people who run the server telling them
that they are throwing a cert-required header back at IE (and maybe
all browsers but the other browsers get past it without a problem)
I really hope anybody can throw any ideas back here in the group, all
suggestions would be welcome.
Regards
Scott
 
 

Re:Delphi 7 - SOAP, and SSL

Hi again, well I have been working on this for a few more hours and
have a workaround for it.
I doubt it will help anyone as no one seemed o be getting the same
error as I was, I put it down to the server.
I didn't realise I could get under the hood of the IE requests but in
SOAPHTTPTrans you can, (I know, I am the last to know that but as I
said before I am just a hacker in the old sense of the word)
I changed the line:
if (LastError = ERROR_INTERNET_INVALID_CA) then
to
if (LastError = ERROR_INTERNET_INVALID_CA) or (LastError =
ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED) then
This now gets me through that error that is returned the first time
around and all goes well.
After 2 days working on it SOAP has left a bad taste in my mouth but I
am sure it is all dead-easy from now on.. right? :-)
Regards
Scott
 

Re:Delphi 7 - SOAP, and SSL

I forgot to say: Don't do this mod if you you ever need to connect to
a server that does need a certificate, this mod stops you being able
to selet one.
This is only to tackle the problem where a server requests a
certificate in the first try but doesn't really need one.
Maybe you can put a copy of this modified .pas in your app directory
to avoid modifying all future apps, I don't know if that works or not.
Regards
Scott