Dav*_*use 8 delphi soap web-services httpwebrequest
简介:如何在Delphi Soap Server应用程序中访问原始的TWebRequest对象?
我的Web服务ITest使用以下方法发布服务CallMe:
ITest = interface(IInvokable)
['{AA226176-FFAD-488F-8768-99E706450F31}']
function CallMe: string; stdcall;
end;
...
initialization
InvRegistry.RegisterInterface(TypeInfo(ITest));
Run Code Online (Sandbox Code Playgroud)
该接口在类中实现:
TTest = class(TInvokableClass, ITest)
public
function CallMe: string; stdcall;
end;
...
initialization
InvRegistry.RegisterInvokableClass(TTest, TestFactory);
Run Code Online (Sandbox Code Playgroud)
如何访问TWebRequest此方法实现中的原始对象?例如,如果我想检查设置了哪些cookie,或者在请求中读取其他属性:
function TTest.CallMe: string;
begin
// how to access TWebRequest object
...
end;
Run Code Online (Sandbox Code Playgroud)
uses
System.SysUtils,
Web.HTTPApp,
Soap.WebBrokerSOAP;
function TTest.CallMe: string;
var
WebDispatcher: IWebDispatcherAccess;
begin
Result := '';
if Supports(GetSOAPWebModule, IWebDispatcherAccess, WebDispatcher) then
Result := Format('You are calling me from: %s', [WebDispatcher.Request.RemoteIP]);
end;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1168 次 |
| 最近记录: |