You are not logged in.
Pages: 1
I have a project that uses an interfaced based service.
Until recently the service was running smoothly, using a version of the mORMot libraries from several months ago. However when I upgraded to a recent version of the mORMot libraries (I've tried a few versions) I started getting the following error:
TInterfacedObjectFakeClient.FakeCall(IMM_MonitorService_Log.Log) failed: '{ - "errorCode":406, - "errorText":"(sicClientDriven) execution failed (probably due to bad input parameters) for IMM_MonitorService_XXX.Log" - }'
I investigated and found that the new version of the libraries is sending JSON from the client to the server with no quotes around the keys. For example:
ClassName : "TMonitorService_XXX"
instead of
"ClassName" : "TMonitorService_XXX"
and it seems the server is rejecting this, producing the error above.
The JSON being sent from the client was generated by the framework as part of the automatic serialisation of a TObjectList decedant, which is first argument of the Log method on the IMM_MonitorService_XXX service.
My first and most important question is obviously "How do I fix this please?".
I have dug deeply into the code, and cant find any option on the client side that gives me a choice about how the JSON is generated. It seems that for sicClientDriven style services, twoForceJSONExtended is hard wired, and short of modifying the library code (which will break at the next update) I cant find a way to override that back to twoForceJSONStandard (which I think would put quotes around the keys).
My second question is almost as obvious: "Why is the client generating JSON that the server cant parse?"
I have followed the execution path in the server as follows:
TServiceFactoryServer.ExecuteMethod
TServiceMethodExecute.ExecuteJson
JSONToObject
JSONObject
TJSONSerializerRegisteredClass.Find
JSONRetrieveStringField - Which ONLY works for "quoted" JSON strings (e.g. line: if P^<>'"' then exit;)
My third question is "Why is no one else finding the same problem?
From this I must conclude that I am stupid, and that I'm missing something really obvious. I wish I knew what it was.
Could you help me please?
Offline
We did not see the error on our side, because we are using T*ObjArray storage of Object instances, instead of TObjectList, or variant / TDocVariant for schemaless structures.
Ensure the client is sending an UserAgent.
See TSQLRestServerURIContext.ClientKind in mORMot.pas.
Also try http://synopse.info/fossil/info/836e4a7a3a if your client is a Delphi mORMot client.
Offline
Thanks ab.
Your latest modification fixed it.
Offline
Pages: 1