#1 Re: mORMot 1 » BUG: 406 when passing GUID as parameter in the SOAP func call » 2016-09-27 11:32:36

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

#2 Re: mORMot 1 » BUG: 406 when passing GUID as parameter in the SOAP func call » 2016-09-26 13:05:33

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!

#3 mORMot 1 » BUG: 406 when passing GUID as parameter in the SOAP func call » 2016-09-26 03:54:36

aakdj3sh
Replies: 5

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!

Board footer

Powered by FluxBB