Jump to content
mausmb

THTTPRIO BeforeExecute

Recommended Posts

Closed : bug in 10.3.2 (SugarLoaf is working )

 

 

Hi,

I have a problem with intercepting SOAP packages. I'm using WSDL importer and THTTPRIO OnBeforeExecute and OnAfterExecute event.


OnAfterExecute I get Soap response package without problem, but OnBeforeExecute Tstream (as String) is always empty. What I'm doing wrong ?


procedure TDummyBeforeEx.Beforexecute(const MethodName: string;
  SOAPRequest: TStream);
var
  sl : TStringList; 

// If I'm ussing Array of byte is the same empty result when  encoding to string 
  begin
  sl := TStringList.Create;
  SOAPRequest.Position := 0;
  try
    sl.LoadFromStream(SOAPRequest);
    if sl.Text='' then // Always empty !
       exit;
    sl.Text := StringReplace(sl.Text, '<soap:Body>', '<soap:Body>XXX', [rfReplaceAll]);
    sl.SaveToStream(SOAPRequest);
  finally
    sl.Free;
  end;
end;

function GetKasaSoap(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): KasaSoap;
const
  defSvc  = 'Kasa';
  defPrt  = 'KasaSoap';
var
  RIO: THTTPRIO;
begin
  Result := nil;
  if (Addr = '') then
  begin
    if UseWSDL then
      Addr := defWSDL
    else
      Addr := defURL;
  end;
  if HTTPRIO = nil then
    RIO := THTTPRIO.Create(nil)
  else
    RIO := HTTPRIO;
  try
    rio.OnAfterExecute:=TDummyAfterEx.AfterExecute; // working as aspected
    rio.OnBeforeExecute:=TDummyBeforeEx.Beforexecute;
    RIO.Converter.Options:=RIO.Converter.Options+[TSOAPConvertOption.soSendMultiRefObj,TSOAPConvertOption.soSendMultiRefArray];
//    RIO.HTTPWebNode.ConnectTimeout:=10;
//    RIO.HTTPWebNode.SendTimeout :=10;
//    RIO.HTTPWebNode.ReceiveTimeout:=10;
    Result := (RIO as KasaSoap);
    if UseWSDL then
    begin
      RIO.WSDLLocation := Addr;
      RIO.Service := defSvc;
      RIO.Port := defPrt;
    end else
      RIO.URL := Addr;
  finally
    if (Result = nil) and (HTTPRIO = nil) then
      RIO.Free;
  end;
end;


Regards,
M

Edited by mausmb
Closed : bug in 10.3.2 (SugarLoaf is working )

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×