SOAP Basic Authentication - D7
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.
3 Comments:
what you meant by you got Data parameter here ???
thanks
Data is the parameter sent in as part of the event handler. If you see the event handler created, you can see the Data parameter sent in.
This comment has been removed by a blog administrator.
Post a Comment
<< Home