I am fairly new to Delphi & have to code a SOAP client. Importing the WSDL generates this code (which I obviously can't change as I obviously have to comply with the server side)
DataPart = class;
Message = class;
eMessage = class;
eventType = ( send, delete, etc );
DataPart = class(TRemotable)
private
FhasData: Boolean;
Fdata: TByteDynArray;
published
property hasData: Boolean read FhasData write FhasData;
property data: TByteDynArray read Fdata write Fdata;
end;
Message = class(TRemotable)
private
FMessageID: Int64;
Ftimestamp: TXSDateTime;
Fevent: eventType;
FmagicNumber: WideString;
FDataPart: DataPart;
published
property MessageID: Int64 read FMessageID write FMessageID;
property timestamp: TXSDateTime read Ftimestamp write Ftimestamp;
property event: eventType read Fevent write Fevent;
property magicNumber: WideString read FmagicNumber write FmagicNumber;
property DataPart: DataPart read FDataPart write FDataPart;
end;
eMessage = class(TRemotable)
private
FencryptedMessage: TByteDynArray;
Fdata: DataPart;
published
property encryptedMessage: TByteDynArray read FencryptedMessage write FencryptedMessage;
property data: DataPart read Fdata write Fdata;
end;
MyApplicationPortType = interface(IInvokable)
['{99767D33-6B4A-7547-4DAC-0608095CAC70}']
function sendMessage(const encryptedMessage: TByteDynArray; const data: DataPart): WideString; stdcall;
end;
Can anyone code me an example with dummy values that will call sendMessage() and not cause an access violation? I really don't know how to handle TByteDynArray
[Edit] as requested, here's my code, BUT - disclaimer - I had to hack it about a lot (reduce it) before posting, so it may not compile. Both parms to sendMessage() are non-null
var theMessageArray: TByteDynArray;
theResult : WideString;
messageData : TByteDynArray;
i : Integer;
begin
theMessage.messageID := theMessage.messageID + 1;
theMessage.timestamp := TXSDateTime.Create();
theMessage.timestamp.AsDateTime := Now();
theMessage.event := delete;
theMessage.magicNumber := 'magic # ' + IntToStr(theMessage.messageID);
SetLength(messageData, 1);
messageData[0] := 0;
theMessage.dataPart.hasData := True;
messageData := theMessage.dataPart.messageData;
SetLength(messageData, $1000 * dataSize);
for i := 0 to $1000 * dataSize - 1 do
messageData[i] := i and $FF;
theMessage.DataPart.messageData := messageData;
theMessageArray := TByteDynArray(theMessage);
theResult := (HTTPRIO1 as MyApplicationPortType).sendMessage(theMessageArray, theMessage.dataPart);