You are not logged in.
My client application works on the old version and it can't be updated.
My server application works on the current trunk version.
In mORMot.pas unit TServiceFactoryClient.InternalInvoke method, there is the validation:
JSONDecode (resp ['result', 'id'], Values, True);
if (Values [0] = nil) or (values [1] = nil) then begin
if aErrorMsg <> nil then
aErrorMsg ^: = 'Invalid returned JSON content';
exit;
end;
Where Value [1] is always nil. Preventing me from registering service.
Can i use client and server on different versions?
Offline
The Client in its older version was too much restrictive...
You can modify the following method as such (adding some comments):
procedure TSQLRestServerURIContext.ServiceResultEnd(WR: TTextWriter; ID: integer);
const JSONSEND_WITHID: array[boolean] of RawUTF8 = ('],"id":','},"id":');
JSONSEND_NOID: array[boolean] of AnsiChar = (']','}');
begin // InternalExecuteSOAByInterface has set ForceServiceResultAsJSONObject
// if ID=0 then
// WR.Add(JSONSEND_NOID[ForceServiceResultAsJSONObject]) else begin
WR.AddString(JSONSEND_WITHID[ForceServiceResultAsJSONObject]);
WR.Add(ID); // only used in sicClientDriven mode
// end;
WR.Add('}');
end;
It should add the "id":... field expected by the old client.
Nice hearing that there are some "old" versions of mORMot in the wild.
But it sounds like a bad idea to keep the client in an old version...
Offline
Thanks for the quick response.
His amendment partially solved my problems.
And I'm doing everything to update my client application. But for now it will be necessary.
In TServiceFactoryClient.Create method, we have this validation:
if '[' + ContractExpected + ']' <> RemoteContract then
raise EServiceException.CreateFmt (
I believe that to succeed, I have to change some more methods: ServiceResultStart, ServiceResultEnd, InternalExecuteSOAByInterface-> ServiceResult
Please see the below code and tell me what you think?
procedure TSQLRestServerURIContext.ServiceResultStart(WR: TTextWriter);
const JSONSTART: array[boolean] of RawUTF8 =
// ('{"result":[','{"result":{');
('{"result":[','{"result":[');
begin // InternalExecuteSOAByInterface has set ForceServiceResultAsJSONObject
WR.AddString(JSONSTART[ForceServiceResultAsJSONObject]);
end;
procedure TSQLRestServerURIContext.ServiceResultEnd(WR: TTextWriter; ID: integer);
const JSONSEND_WITHID: array[boolean] of RawUTF8 = ('],"id":','],"id":');
JSONSEND_NOID: array[boolean] of AnsiChar = (']',']');
//const JSONSEND_WITHID: array[boolean] of RawUTF8 = ('],"id":','},"id":');
// JSONSEND_NOID: array[boolean] of AnsiChar = (']','}');
begin // InternalExecuteSOAByInterface has set ForceServiceResultAsJSONObject
// if ID=0 then
// WR.Add(JSONSEND_NOID[ForceServiceResultAsJSONObject]) else begin
WR.AddString(JSONSEND_WITHID[ForceServiceResultAsJSONObject]);
WR.Add(ID); // only used in sicClientDriven mode
// end;
WR.Add('}');
end;
procedure TSQLRestServerURIContext.InternalExecuteSOAByInterface;
procedure ServiceResult(const Name,JSONValue: RawUTF8);
var WR: TTextWriter;
begin
WR := TJSONSerializer.CreateOwnedStream;
try
ServiceResultStart(WR);
// if ForceServiceResultAsJSONObject then
// WR.AddFieldName(Name);
WR.AddString(JSONValue);
ServiceResultEnd(WR,0);
Returns(WR.Text);
finally
WR.Free;
end;
end;
Sorry for my bad english
Offline
I do not remind well the previous format.
We expect both client and server to be on the same version, i.e. at least from "official" version (1.17 or 1.18)...
I'm afraid you will have to tune it....
Offline