I'm testing a XData Service. I have the following code on a button click. Ths first time I click I get a Exception "TXDataWebConnection is not connected", later calls works ok. If I Set .Connected := false on method OnResult, I get intermitent exceptions->Exception, Ok, Exception, Ok....
try
XDataWebConnection1.URL := 'http://localhost/INTEC/ICSAT/xdata';
XDataWebConnection1.Connected := true;
XDataWebClient1.RawInvoke('IICSATService.EchoString', [sTemp], @OnResult);
except on E:Exception do
WebMemo2.Text := E.Message;
end;
I had fixed with the following code, but getting a Uncaught (in promise) TypeError.
try
try
Conn := TXDataWebConnection.Create(nil);
Conn.URL := 'http://localhost/INTEC/ICSAT/xdata';
Conn.OnRequest := XDataWebConnection1Request;
Client := TXDataWebClient.Create(nil);
Client.Connection := Conn;
await(Conn.OpenAsync);
Response := await(Client.RawInvokeAsync('IICSATService.EchoString', [sTemp]));
sTemp := string(TJSObject(Response.Result)['value']);
WebMemo2.Text := sTemp;
javascriptobject := TJSJSON.parse(sTemp);
Duca := TDUCA(javascriptobject);
Duca.Free;
except on E:Exception do
WebMemo2.Text := E.Message;
end;
finally
Client.Free;
Conn.Free;<--- Error
end;
Uncaught (in promise) TypeError: obj.$destroy is not a function
freeLoc rtl.js:448
TestXDataService Forms.Main.pas:244
WebButton1Click Forms.Main.pas:266
cb rtl.js:240
Click WEBLib.Controls.pas:1747
HandleDoClick WEBLib.Controls.pas:3744
cb rtl.js:236
What is XDataWebConnection1Request doing?
Is this still relying on Conn to be accessible as you might be destroying it here before this event handler is called?