开发者

consuming web service with authentication allways give message Authentication required

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): strin开发者_如何学Gog;
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 ?


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;


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜