2012-05-01 13 views
7

Riepilogo: Come si accede all'oggetto originale TWebRequest in un'applicazione server di sapone Delphi?Accesso all'oggetto TWebRequest originale in un server SOAP Delphi

Il mio servizio web pubblica un servizio ITest con un metodo CallMe:

ITest = interface(IInvokable) 
['{AA226176-FFAD-488F-8768-99E706450F31}'] 
    function CallMe: string; stdcall; 
end; 
... 
initialization 
InvRegistry.RegisterInterface(TypeInfo(ITest)); 

Questa interfaccia è implementata in una classe:

TTest = class(TInvokableClass, ITest) 
public 
    function CallMe: string; stdcall; 
end; 
... 
initialization 
InvRegistry.RegisterInvokableClass(TTest, TestFactory); 

Come si accede al TWebRequest oggetto originale all'interno della realizzazione di questo metodo? Per esempio. Se voglio controllare che i cookie sono stati fissati, o leggere le altre proprietà della richiesta:

function TTest.CallMe: string; 
begin 
    // how to access TWebRequest object 
    ... 
end; 

risposta

4
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; 
+0

Grande risposta - molte grazie :) –

Problemi correlati