Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Web Service with HTTP Basic Authentication Scheme

1,979 views
Skip to first unread message

Jair Karim Tinoco

unread,
Mar 21, 2007, 9:58:23 PM3/21/07
to
Hi,
I need to secure my web services with HTTP BASIC Authentication Schema, this
requires a HTTP header to be added to the HTTP unsecure headers,something
like this:

-------------------------------------------------------------
GET /private/index.html HTTP/1.0
Host: localhost
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
-------------------------------------------------------------

I think that this stuff is part of WinInet and Delphi SOAP Runtime is
independent from the communication method.

How can i append this header to my SOAP calls?
Thanks in Advance!!

Jair Karim

Jean-Marie Babet

unread,
Mar 22, 2007, 2:40:33 PM3/22/07
to
Hello Jair,

All you have to do is handle the OnBeforePost event on the
HTTPRIO.HTTPWebNode component and use InternetSetOption. Here's an example
from a sample that talks to MapPoint (MapPoint.NET uses 'digest'
authentication - a variant of 'basic' authentication):


procedure TTestMapPointRender.HTTPRIO1HTTPWebNode1BeforePost(
const HTTPReqResp: THTTPReqResp; Data: Pointer);
var
UserName: string;
PassWord: string;
begin
UserName := GetWSToken('MapPoint', 'UserName');
Password := GetWSToken('MapPoint', 'Password');
if not InternetSetOption(Data,
INTERNET_OPTION_USERNAME,
PChar(UserName),
Length(UserName)) then
raiseException(SysErrorMessage(GetLastError));

if not InternetSetOption(Data,
INTERNET_OPTION_PASSWORD,
PChar(Password),
Length (Password)) then
raiseException(SysErrorMessage(GetLastError));
end;


Cheers,


Bruneau.


Graham Harris

unread,
Mar 23, 2007, 6:11:22 AM3/23/07
to
Hello Bruneau,

With MapPoint.NET you can also do the following:

RenderServiceRequest := TdaHTTPRIO.Create(Self);
RenderServiceRequest.HTTPWebNode.UserName := Username;
RenderServiceRequest.HTTPWebNode.Password := Password;

Graham Harris


Jean-Marie Babet

unread,
Mar 23, 2007, 4:50:29 PM3/23/07
to
Thanks for the info. It must have been something that was added sometime
after D7. Originally the THTTPReqResp.UserName/Password were only used for
'Proxy' support. However, there were requests to have UserName/Password be
used for authentication if a 'Proxy' is not specified. I was away from SOAP
in D2005/D2006, I suspect the support was added and I was still using the
previous approach.

Thanks again!

Bruneau.

"Graham Harris" <n...@bmsgharr.globalnet.co.uk> wrote in message
news:7c6eb6621626e8...@newsgroups.borland.com...

Jair Karim Tinoco

unread,
Mar 23, 2007, 10:18:59 PM3/23/07
to
Thanks!!, your help will be very useful.

Jair Karim

"Jean-Marie Babet" <bba...@borland.com> escribió en el mensaje de noticias
news:46043d94$1...@newsgroups.borland.com...

0 new messages