#1 2016-09-26 03:54:36

aakdj3sh
Member
Registered: 2016-09-26
Posts: 3

BUG: 406 when passing GUID as parameter in the SOAP func call

Hi,

I encountered an issue when the GUID parameter is not correctly parsed from JSON when invoking an interface method along with other parameters following it.

For example, define a method in the ICalculator interface (example -- 14 - Interface based services) that looks like this:

  ICalculator = interface(IInvokable)
    ['{9A60C8ED-CEB2-4E09-87D4-4A16F496E5FE}']
    function Add(n1,n2: integer): integer;

// Test method:
function Test(const g: TGUID; a, b: Integer)

  end;

...and then call the server from the client. It will result in HTTP 406 error.

I found deep in the server side, in the ExecuteJson () function, the GUID is treated as a record type, so the parser assumes it is wrapped as a record in the JSON string, but it actually is passed as a string parameter, i.e. JSON call will look like: Test["A58E3F41-5DD7-495F-93A2-6E6A03AD3219",1,2]. After the first parameter (GUID) is parsed, the remaining Par string that contains the 2 remaining parameters looks like: ",2]", so either second's parameter value "1" was dropped, or the parser was looking for {  } wrappers thinking that TGUID was a generic record.

Can you please issue a fix to this? It's easily reproducible.

Thanks!

Last edited by aakdj3sh (2016-09-26 04:06:46)

Offline

#2 2016-09-26 06:25:18

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: BUG: 406 when passing GUID as parameter in the SOAP func call

Parsing a record as a string is no problem for the custom JSON serialiazers.
You can parse anything with any custom JSON layout.

With latest version 1.18.3006 revision?
With which compiler?
On which platform?

Offline

#3 2016-09-26 13:05:33

aakdj3sh
Member
Registered: 2016-09-26
Posts: 3

Re: BUG: 406 when passing GUID as parameter in the SOAP func call

Hi,

Sorry I forgot to tell you about the environment. It's Delphi XE6  Windows 7 x64. I don't know where to find the revision #, but I downloaded the sources on August 8 (2 months ago).

I think everybody would expect mORMot to work out of the box for System types (GUID is one of them), without wasting creating custom parser for everything. It kills the purpose of using the mORMot in the first place.

The problem is not even in the JSON parser, but how the Interface-based function is invoked, i.e. its parameters are instantiated from JSON string. You can easily reproduce this problem even in your examples:

1. Open projects Project14Client.dpr  and  Project14ServerHttpWeak.dpr from your Samples folder

2. Change the interface of the ICalendar in the Project14Interface.pas file by adding a GUID parameter in the beginning of the parameter list:

  ICalculator = interface(IInvokable)
    ['{9A60C8ED-CEB2-4E09-87D4-4A16F496E5FE}']
    function Add(const AGUID: TGUID; n1,n2: integer): integer;
  end;

3. Change the ICalculator implementation in the Project14ServerHttpWeak:

type
  TServiceCalculator = class(TInterfacedObject, ICalculator)
  public
    function Add(const AGUID: TGUID; n1,n2: integer): integer;
  end;

function TServiceCalculator.Add(const AGUID: TGUID; n1, n2: integer): integer;
begin
  result := n1+n2;
end;

4. Run these samples. You will get the error message:

(sicShared) execution failed (probably due to bad input parameters) for Calculator.Add


Please take a look yourself and issue a fix to that.

Thanks!

Offline

#4 2016-09-26 15:08:17

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: BUG: 406 when passing GUID as parameter in the SOAP func call

Should be fixed by http://synopse.info/fossil/info/7a388f71bebbb85

Thanks for the report.

Offline

#5 2016-09-27 11:32:36

aakdj3sh
Member
Registered: 2016-09-26
Posts: 3

Re: BUG: 406 when passing GUID as parameter in the SOAP func call

Awesome, thanks for the quick turnaround. It works now!

Offline

#6 2016-10-01 16:16:20

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: BUG: 406 when passing GUID as parameter in the SOAP func call

I had to revert the patch and try another solution.
See http://synopse.info/fossil/info/48fca4fc4f06171e

Previous modification did break serialization under Delphi 2010+...

Offline

Board footer

Powered by FluxBB