Using Delphi 2005, I have created a test app (using a TForm) to test a SOAP API. Unfortunately this API has declared some enums (Application, System and Terminal) which are reserved by Delphi. I renamed the enums in the SOAP file (_Application, _Terminal and _System) and was able to write OnBeforeExecute and OnAfterExecute methods to replace these renamed enums with the original names before and after submitting.
I am now trying to incorporate this into my larger project and would like to capture all the code for this SOAP API in a class file (no form). With my tester app I added a THTTPRIO object to the form (from the Tool Palette) and could easily set the OnBeforeExecute and OnAfterExecute methods in the Object Inspector. Now using the class (a TComponent) I cannot add the THTTPRIO object using Tool Palette like I did with the form. I tried to create the THTTPRIO object via code but am getting some errors.
I get the error E2009 incompatible types: 'Parameter lists differ'
on FEPS_HTTPRIO.OnAfterExecute := HTTPRIOAfterExecute;
(see code below)
Why do I get the error on this but not on FEPS_HTTPRIO.OnBeforeExecute := HTTPRIOBeforeExecute;
and how can I implement these two methods within my class?
Here is how I created the THTTPRIO via code:
unit c_MoSh;
interface
uses classes, forms, Windows, SysUtils, c_MoShAPI, InvokeRegistry, controls;
Type
TMoSh = class(TComponent)
private
...
procedure HTTPRIOBeforeExecute(const MethodName: string;
var SOAPRequest: WideString);
procedure HTTPRIOAfterExecute(const MethodName: string;
var SOAPResponse: TStream);
...
constructor TMoSh.Create();
begin
FEPS_HTTPRIO := THTTPRIO.Create(self);
FEPS_HTTPRIO.OnBeforeExecute := HTTPRIOBeforeExecute;
FEPS_HTTPRIO.OnAfterExecute := HTTPRIOAfterExecute; <-- Error line
end;
procedure TMosquitoShield.HTTPRIOBeforeExecute(const MethodName: string;
var SOAPRequest: WideString);
var
tmpString: TStringList;
begin
try
SOAPRequest := StringReplace(SOAPRequest,'<ReversalType>_Application','<ReversalType>Application',[RfReplaceAll]);
SOAPRequest := StringReplace(SOAPRequest,'<ReversalType>_System','<ReversalType>System',[RfReplaceAll]);
SOAPRequest := StringReplace(SOAPRequest,'<CardholderPresentCode>NotPresent2','<CardholderPresentCode>NotPresent',[RfReplaceAll]);
SOAPRequest := StringReplace(SOAPRequest,'<DeviceInputCode>NotUsed3','<DeviceInputCode>NotUsed',[RfReplaceAll]);
except
on ER : ERemotableException do
ShowMessage(ER.ClassName + ' error raised, with message : ' + ER.FaultDetail + ' :: '
+ ER.Message);
on E : Exception do
ShowMessage(E.ClassName + ' error raised, with message : ' + E.Message);
end;
end;
procedure TMosquitoShield.HTTPRIOAfterExecute(const MethodName: string;
var SOAPResponse: TStream);
var
tmpString: TStringList;
begin
try
tmpString := TStringList.Create;
SOAPResponse.Position := 0;
tmpString.LoadFromStream(SOAPResponse);
tmpString.Text := StringReplace(tmpString.Text,'Application','_Application',[RfReplaceAll]);
tmpString.Text := StringReplace(tmpString.Text,'System','_System',[RfReplaceAll]);
tmpString.Text := StringReplace(tmpString.Text,'<PASSUpdaterOption>Null','<PASSUpdaterOption>Null2',[RfReplaceAll]);
tmpString.Text := StringReplace(tmpString.Text,'<TransactionSetupMethod>Null','<TransactionSetupMethod>Null3',[RfReplaceAll]);
tmpString.Text := StringReplace(tmpString.Text,'<Device>Null','<Device>Null4',[RfReplaceAll]);
tmpString.Text := StringReplace(tmpString.Text,'<ConsentCode>NotUsed','<ConsentCode>NotUsed2',[RfReplaceAll]);
tmpString.Text := StringReplace(tmpString.Text,'<DeviceInputCode>NotUsed','<DeviceInputCode>NotUsed3',[RfReplaceAll]);
SOAPResponse.Position := 0;
tmpString.SaveToStream(SOAPResponse);
except
on ER : ERemotableException do
ShowMessage(ER.ClassName + ' error raised, with message : ' + ER.FaultDetail + ' :: '
+ ER.Message);
on E : Exception do
ShowMessage(E.ClassName + ' error raised, with message : ' + E.Message);
end;
end;