unit OneClickSoapHelpers;
interface
uses Classes, InvokeRegistry, OneClickForApp, IdHashMessageDigest, idHash, XMLIntf;
type
TOneClickHeader =
class(TSoapHeader)
private
FPartner_ID :
string;
FRequest_TimeStamp :
string;
FKey_Phase : integer;
FPartner_Signature :
string;
FPartner_Key :
string;
procedure CalcSignature;
public
function ObjectToSOAP(RootNode: IXMLNode; ParentNode: IXMLNode;
const ObjConverter: IObjConverter;
const NodeName:
string;
const NodeNamespace:
string;
const ChildNamespace:
string;
ObjConvOpts: TObjectConvertOptions;
out RefID:
string): IXMLNode;
override;
property Partner_Key :
string read FPartner_Key
write FPartner_Key;
published
property Partner_Id :
string Index (1)
read FPartner_Id
write FPartner_Id;
property Request_TimeStamp :
string Index (1)
read FRequest_TimeStamp
write FRequest_TimeStamp;
property Key_Phase : integer
Index (1)
read FKey_Phase
write FKey_Phase;
property Partner_Signature :
string Index (1)
read FPartner_Signature
write FPartner_Signature;
end;
onec =
class(TOneClickHeader);
implementation
uses sysutils, strutils, Rio;
{ TOneClickHeader }
procedure TOneClickHeader.CalcSignature;
var
idmd5 : TIdHashMessageDigest5;
ACode :
string;
begin
ACode := trim(Partner_id)+'
::'+
trim(Request_TimeStamp)+'
::'+
IntToStr(Key_Phase)+'
::'+
FPartner_Key;
idmd5 := TIdHashMessageDigest5.Create;
try
FPartner_Signature := LowerCase(LeftStr(idmd5.HashStringAsHex(ACode),8));
finally
idmd5.Free;
end;
end;
function TOneClickHeader.ObjectToSOAP(RootNode, ParentNode: IXMLNode;
const ObjConverter: IObjConverter;
const NodeName, NodeNamespace,
ChildNamespace:
string; ObjConvOpts: TObjectConvertOptions;
out RefID:
string): IXMLNode;
begin
Result := ParentNode.AddChild('
PARTNER_ID');
Result.Text := FPartner_Id;
Result := ParentNode.AddChild('
REQUEST_TIMESTAMP');
Result.Text := FRequest_TimeStamp;
Result := ParentNode.AddChild('
KEY_PHASE');
Result.Text := IntToStr(FKey_Phase);
Result := ParentNode.AddChild('
PARTNER_SIGNATURE');
CalcSignature;
Result.Text := FPartner_Signature;
end;
initialization
InvRegistry.RegisterHeaderClass(TypeInfo(OneClickForAppPortType), onec, '
onec', '
');
end.