使用带有身份验证的 Web 服务总是给出消息 Authentication required
我尝试在 Delphi 2010 中使用消费一项 Web 服务。 此 Web 服务位于端口 8000 上并进行身份验证。
我实现了
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;
,但仍然有消息“需要身份验证”。
我做错了什么吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于基本身份验证,这应该有效:
Basic Authentication in Delphi 7 SOAP
如上所述在这篇文章中,较新版本的Delphi也允许使用
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
如果仍然不起作用,您可以尝试不同的客户端(.Net 或 Java),并借助本地代理(Fiddler 或 Don's Proxy)或嗅探器 (WireShark),找出相关的差异。
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.