Hi. I am using a service to transmit a stream to the server. The "Sum" function is executed correctly, but the SendImg function returns the error:
Could not find JSON converter for type "NativeUint".
Could not find JSON converter for type "NativeUint".
Can someone tell me I'm doing wrong? The TStream type is permitted according to the documentation:
http://www.tmssoftware.biz/business/xdata/doc/web/supported_types.html
http://www.tmssoftware.biz/business/xdata/doc/web/supported_types.html
Server code:
unit ServerApi;
interface
uses RemoteDB.Drivers.Interfaces
, Sparkle.HttpSys.Server
, XData.Service.Common
, IServiceImage
, Classes
;
const
cServerApi = 'http://+:2001/mksoft/api/';
type
[ServiceImplementation]
TMkServiceImage = class (TInterfacedObject, IMkServiceImage)
procedure SendImage (AStream: TStream);
function Suma (a,b:integer): integer;
end;
function StartServerApi (AConnection: IDBConnection) : THttpSysServer;
implementation
uses XData.Server.Module
, XData.Aurelius.Model
, FW.Log
;
{ TMkServiceImage }
procedure TMkServiceImage.SendImage(AStream: TStream);
begin
Log.LogMessage('Stream %d',[Astream.Size]);
end;
function TMkServiceImage.Suma(a, b: integer): integer;
begin
Result := a + b;
end;
function StartServerApi (AConnection: IDBConnection) : THttpSysServer;
var
Module: TXDataServerModule;
begin
Result := THttpSysServer.Create;
Module := TXDataServerModule.Create(cServerApi,AConnection,TXDataAureliusModel.Get('mkimage'));
Result.AddModule(Module);
Result.Start;
end;
initialization
RegisterServiceType(TMkServiceImage);
end.
Client Code:
procedure TFSetTDci.SendImage(Sender: TObject);
var
lClient: TXDataClient;
lService: IMkServiceImage;
lStream: TStream;
i: integer;
begin
// Login;
lClient := TXDataClient.Create (TXDataAureliusModel.Get('mkimage'));
lClient.Uri := 'http://localhost:2001/mksoft/api';
lService := lClient.Service <IMkServiceImage>;
i := lService.Suma(5,8);
Log.LogMessage('Suma %d',); // 13!!! OK
lStream := TFileStream.Create (pFichero,fmOpenRead);
try
lService.SendImage(lStream);
finally
lStream.Free;
end;
end;