4

I try to use consume one web service with Delphi 2010. This web service is on port 8000 with authentication.

I implement the

function TForm4.EncodeLoginPW(const ALogin, APW: string): string;
begin
  Result := EncdDecd.EncodeString(ALogin + ':' + APW); // EncdDecd is not documented in 
end;


procedure TForm4.HTTPRIO1HTTPWebNode1BeforePost(const HTTPReqResp: THTTPReqResp;
  Data: Pointer);
var
  s: string;
begin
  s := 'Authorization: Basic ' + EncodeLoginPW(UserName, Password);
  if not HttpAddRequestHeaders(Data, PChar(s), Length(s), HTTP_ADDREQ_FLAG_ADD) then
    ShowMessage('HttpAddRequestHeaders' + SysErrorMessage(GetLastError()));
end;

but I have still the message "Authentication required".

Do I make something wrong ?

Hugues Van Landeghem
  • 6,755
  • 3
  • 34
  • 59

2 Answers2

2

For Basic Authentication this should work:

Basic Authentication in Delphi 7 SOAP

As explained in this post, newer versions of Delphi also allow to use

HTTPRio.HTTPWebNode.UserName := Username;
HTTPRio.HTTPWebNode.Password := Password;
mjn
  • 36,362
  • 28
  • 176
  • 378
0

If it still does not work, you can try a different client (.Net or Java), and compare the HTTP traffic with the help of a local proxy (Fiddler or Don's Proxy) or a sniffer (WireShark), to find the relevant differences.

mjn
  • 36,362
  • 28
  • 176
  • 378