Hello,
I like to send the data from a TxDataWebDataSet in a Service to the xDataServer.
JSVal: JSValue;
begin
JSVal:=DataSet_NewCompany.CurrentData;
TVc_XDataWebClient.RawInvoke('ITV_CreateNewCustService.Insert_Company_Test',[JSVal], @OnResponse);
The Service Implemenation looks like:
unit TV_CreateNewCustServiceImplementation;
interface
uses
XData.Server.Module,
XData.Service.Common,
TV_CreateNewCustService,
System.JSON,
System.SysUtils,
WEBLib.Dialogs,
FireDAC.Comp.Client,
VCL.Dialogs,
xData.Web.Client,
JS;
type
[ServiceImplementation]
TTV_CreateNewCustService = class(TInterfacedObject, ITV_CreateNewCustService)
private
function Insert_Company_Test(JSVal: JSValue): integer;
end;
implementation
uses TTV_ConnectModuleUnit;
function TTV_CreateNewCustService.Insert_Company_Test(JSVal: JSValue): integer;
var Query: TFDQuery;
JSObj: TJSObject;
begin
JSObj:=TJSJSON.parseObject(JS.toString(JSVal));
Query:= TFDQuery.Create(nil);
Query.Connection:=MySQL.MySQL_Cnnctn;
Try
Result:=0;
Query.SQL.Clear;
Query.SQL.Add('insert into company '+
'(company_name, anschrift_1, anschrift_2, plz, ort, telefon_ohne_dw, durchwahl, ust_id, sprache_id, land_id) '+
'values '+
'(:company_name, :anschrift_1, :anschrift_2, :plz, :ort, :telefon_ohne_dw, :durchwahl, :ust_id, :sprache_id, :land_id); '+
'select last_insert_id() as ID ');
Query.ParamByName('company_name').AsString:= string(JSObj['company_name']);
Query.ParamByName('anschrift_1').AsString:= string(JSObj['anschrift_1']);
Query.ParamByName('anschrift_2').AsString:= string(JSObj['anschrift_2']);
Query.ParamByName('plz').AsString:= string(JSObj['plz']);
Query.ParamByName('ort').AsString:= string(JSObj['ort']);
Query.ParamByName('telefon_ohne_dw').AsString:= string(JSObj['telefon_ohne_dw']);
Query.ParamByName('durchwahl').AsString:= string(JSObj['durchwahl']);
Query.ParamByName('ust_id').AsString:= string(JSObj['ust_id']);
Query.ParamByName('sprache_id').AsInteger:= integer(JSObj['sprache_id']);
Query.ParamByName('land_id').AsInteger:= integer(JSObj['land_id']);
Query.Open;
Result:= Query.FieldByName('id').AsInteger;
Finally
Query.Free;
End;
But when I try to compile the serverapp I get the message:
Erste Gelegenheit für Exception bei $756146D2. Exception-Klasse EUnsupportedActionParamType mit Meldung 'Cannot define action "Insert_Company_Test": Invalid type "JSValue" for param "JSVal"'. Prozess TheVisit_Server.exe (8960)
I am looking for a possiblity to send the parameters for the service in an oject or value. Is that possible on that way?
Many thanks
Patrick