RAD Studio 10.4.1 is now available! Learn more. Looking for discounts? Visit our Special Offers page!
News

Basic Authentication in Delphi 7 SOAP

Author: Tóth Erik

Back after a break. It’s been quite a while since I wrote, so I’ll cut to the chase. Question on newsgroups: How do I set username/password for Basic Authentication on SOAP.

Issues: The HTTPRio.HTTPWebNode.UserName and .Password properties are used only in situations where theres a proxy. But let’s assume you wanted to use these for basic authentication. You’re going to have to set an event handler for HttpRio.HttpWebNode.OnBeforePost. You get a Data parameter here, and this is the HRequest used for sending the data.

All you now have to do is write something like this in the event handler:


if not InternetSetOption(Data,
INTERNET_OPTION_USERNAME,
PChar(HTTPRIO1.HTTPWebNode.UserName),
Length(HTTPRIO1.HTTPWebNode.UserName)) then
ShowMessage(SysErrorMessage(GetLastError));

if not InternetSetOption(Data,
INTERNET_OPTION_PASSWORD,
PChar(HTTPRIO1.HTTPWebNode.Password),
Length (HTTPRIO1.HTTPWebNode.Password)) then
ShowMessage(SysErrorMessage(GetLastError));

You can of course set any other password you want. Note: You need to add WinInet and SOAPHttpTrans to your uses clause.


Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

Related posts
C++

What's New in the GetIt Package Manager - June 2020

C++

RAD Studio 10.4 Now Available, Learn More

C++NewsRAD Studio

Open for Business with 10.4! - May 2020 GM Update

C++DelphiNews

Embarcadero Open Source Project Sponsorship

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES