Hi
I was trying to use Async Mode for RawInvokeAsync according to xData doc but it appears elements seem wrong into,
currently
procedure TForm2.WebButton1Click(Sender: TObject);
var
Response: TXDataClientResponse
GreetResult: string;
begin
Response := await(Client.RawInvokeAsync('IMyService.Greet', ['My name']);
GreetResult := string(TJSObject(Response.Result)['value']);
end;
Await return TJSValue not TXDataClientResponse and can consume TJSValue not TXDataClientResponse
I tried different type of variable without success.
... + missing ")" at end of line (looks like copy paste from end of night )
Please can you clarifiy how to use RawInvokeAsync in order to retrieve TJSArray or TJSObject from ?
thanks
wlandgraf
(Wagner Landgraf)
May 6, 2021, 2:30pm
3
Can you please provide a sample that reproduces the issue? On our side, it works fine. For example, this code works fine:
procedure TForm1.MathOperation;
var
A, B: Integer;
Response: TXDataClientResponse;
CalcResult: Integer;
begin
A := StrToInt(edA.Text);
B := StrToInt(edB.Text);
case cbOperation.ItemIndex of
0: Response := await(ClientOperation.RawInvokeAsync('IMusicService.Sum', [A, B]));
1: Response := await(ClientOperation.RawInvokeAsync('IMusicService.Multiply', [A, B]));
end;
CalcResult := JS.ToInteger(TJSObject(Response.Result)['value']);
edResult.Text := IntToStr(CalcResult);
end;
To invoke a service operation declared like this:
[ServiceContract]
IMusicService = interface(IInvokable)
['{B93840E5-AF86-432B-BF31-751E5ED80079}']
[HttpGet] function Sum(A, B: Integer): Integer;
function Multiply(A, B: Integer): Integer;
function CreateAlbum(Info: TCreateAlbumInfo): TAlbum;
[HttpGet] function AlbumsPerArtist: TList<TCriteriaResult>;
end;
hi Wagner
Note = client is a web app here
My service is exposed as (and work fine by SwaggerUI)
Type
TGps_coordonnates = Class
latitude : string;
longitude : string;
End;
[ServiceContract]
[Route('padmobile')]
IPadMobileService = interface(IInvokable)
['{C8F62138-FC92-4D5B-A8BE-09E37DAC2961}']
[HttpGet, Route('padmobile_cp2gps')]
function PadMobile_GPS_from_CP(CodePostal:string): TGps_coordonnates;
end;
In Web App I call it by
var
CP_Loc : String;
JS_PAD_GPS_Loc : TXDataClientResponse;
. . .
CP_Loc := WebPanel_SIMU_Details_GPSmode_CPEdit.Text;
JS_PAD_GPS_Loc := await(XDataWebClient_PAD.RawInvokeAsync('IPadMobileService.PadMobile_GPS_from_CP', [CP_Loc]));
during compilation I get an error "await only available in async procedure"
wlandgraf
(Wagner Landgraf)
May 6, 2021, 4:13pm
5
Well, the error message tell you how to proceed. Any call to await must be in an async method, so declare you method like
procedure CallPadMobileGPS; async;
And then put the await code inside such method.
Thanks Wagner that's work fine
system
(system)
Closed
May 6, 2021, 6:42pm
7
This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.