【发布时间】:2015-02-08 05:30:30
【问题描述】:
我想使用 Delphi XE6 创建一个Exchange Web Services (EWS) 客户端应用程序。
我正在使用带有 wsdl 的 THttpRio 组件。如何设置用户凭据?在其他语言中,THttpRio 组件的等效项具有 Credentials 属性 (example)。 但这在 Delphi 组件中是缺失的。
身份验证机制(除了模拟)不是 ews wsdl 的一部分。它是 SOAP 层的本机。
清单 1:
procedure TForm1.Button1Click( Sender: TObject);
var
lESB : ExchangeServicePortType;
request : GetServiceConfiguration;
Impersonation : ExchangeImpersonation;
RequestVersion: RequestServerVersion;
MailboxCulture1: MailboxCulture;
GetServiceConfigurationResult: GetServiceConfigurationResponse;
ServerVersion : ServerVersionInfo;
begin
lESB := HTTPRIO1 as ExchangeServicePortType;
request := GetServiceConfiguration.Create;
request.RequestedConfiguration := ArrayOfServiceConfigurationType.Create( 'UnifiedMessagingConfiguration');
Impersonation := ExchangeImpersonation.Create;
RequestVersion := RequestServerVersion.Create;
MailboxCulture1 := MailboxCulture.Create;
GetServiceConfigurationResult:= GetServiceConfigurationResponse.Create;
ServerVersion := ServerVersionInfo.Create;
try
lESB.GetServiceConfiguration(
request, Impersonation, RequestVersion, MailboxCulture1,
GetServiceConfigurationResult, ServerVersion)
finally
request.Free;
Impersonation.Free;
RequestVersion.Free;
MailboxCulture1.Free;
GetServiceConfigurationResult.Free;
ServerVersion.Free
end
end;
上面的清单 1 显示了一些示例代码,到目前为止我已经尝试过。该函数的目的是获取有关服务器的版本信息。 HTTPRIO1 是具有默认属性的 THTTPRIO 组件,并连接到 EWS 的标准 wsdl。这不起作用,因为未设置用户凭据。
如何设置用户凭据?
【问题讨论】:
-
我从来没有让这个在 Delphi 中工作,我最终制作了一个中间 .NET DLL,你可以很容易地使用它。
-
我强烈建议您使用 Indy 组件来使用 EWS wsdl,而不是使用 HttpRIO。
-
@RBA 你可以添加一些细节(也许作为一个完整的答案)? THttpRIO 没有基于 Indy 的插入式替换组件。 Indy (TIdHTTP) 可用于下载基于 Web 的 WSDL 资源,但这无助于解决实际的互操作问题。
-
您拥有
UserName/Password的THTTPRIO.HTTPWebNode(THTTPReqResp) 属性怎么样,还是我错过了什么? -
离题,但是您是如何设法导入 WSDL 的?
标签: delphi soap exchangewebservices