Basically i have this xData-Server-Method (defined as [httpGet]
in the interface) which is fetching some rows from a table and i´m turning the result to JSON
with TDatasetToJSONBridge
. This works fine for itself i can request this via browser or postman. I get the JSON
as i want.
function TTestService.GetPGMSampleData: TJSONObject;
var
lJSONBridge: TDatasetToJSONBridge;
begin
lJSONBridge := TDatasetToJSONBridge.Create;
try
if not MyFDConnection.Connected then
MyFDConnection.Connected := True;
MyFDQuery.SQL.Text := 'select * from MyTable';
MyFDQuery.Active := True;
lJSONBridge.Dataset := MyFDQuery;
lJSONBridge.IncludeNulls := False;
Result := TJSONObject.Create;
Result.AddPair('DATA', lJSONBridge.Produce as TJSONValue);
finally
MyFDQuery.Active := False;
lJSONBridge.Free;
end;
end;
My problem is establishing a connection with a WEB CORE Bootstrap Client with the following code from the samples:
procedure TForm1.WebButton1Click(Sender: TObject);
begin
XDataWebConnection1.URL := 'http://localhost:2001/tms/xdata/TestService/GetSampleData';
try
await(XDataWebConnection1.OpenAsync);
WriteLn('XData server connected succesfully!');
except
on Error: Exception do
ShowMessage('XData server connection failed with error: ' + Error.Message);
end;
end;
The TXDataWebConnection
seems to require a Model for the URL:
The Server function i have in mind wouldn´t always deliver the same Columns all the time so the model could change from request to request.
Is there a way to provide this model for a specified SQL? Or do you see any other way how i can make this work?