- This topic has 2 replies, 2 voices, and was last updated 6 years, 11 months ago by .
Viewing 1 reply thread
Viewing 1 reply thread
- You must be logged in to reply to this topic.
Hi,
First of all happy 2019!
For one reason or another the body parameter in the following method is not marshalled into the TSomeTest object.
[kbmMW_Method]
[kbmMW_Rest(‘method:post, path:”some-test”‘)]
function AddSomeTest([kbmMW_Rest(‘value:”body”‘)] const ATest: TSomeTest): string;
The TSomeTest looks like this:
[kbmMW_Root(‘some_test’, [mwrfIncludeOnlyTagged])]
TSomeTest = class
private
FMyName: string;
FMyAge: integer;
public
[kbmMW_Attribute(‘my_name’)]
property MyName: string read FMyName write FMyName;
[kbmMW_Attribute(‘my_age’)]
property MyAge: integer read FMyAge write FMyAge;
end;
I have added the following code in the initialization section
TkbmMWRTTI.EnableRTTI([TSalesInvoice, TSalesInvoiceRead, TSomeTest]);
kbmMWRegisterKnownClasses([TSalesInvoice, TSalesInvoiceRead, TSomeTest]);
When I make a http post request with Fiddler I get an invalid type cast exception.
I found out that I do have access to the body parameter, so I think that some goes wrong with marshalling. If I just marshal/unmarshal with TkbmMWJSONMarshal(m).ValueFromString etc. it does work fine.
Any suggestion what might be the cause of this exception?
I am using kbmmw 5.0.6.20
Thanks in advance.
p.s. the subject line input has a white font on a white background here in Firefox and Chrome
I looks like the mime type var never makes it to the UmarshalBody method in kbmMWSmartServiceUtils.
My http header looks like this:
User-Agent: Fiddler
Mime-Type: application/json
Host: 192.168.0.56
Content-Length: 39
Am I doing something wrong or is this a bug?
Hi,
You will definitely want to use latest versions for these features, as they continue to improve.
It should work in 5.07, and it is definitely working in the 5.07.10 update that I will be releasing shortly.
// This method gets a person in the body and echoes it back again.
// Since we want the provided value echoed right back we dont want
// the framework to free the argument automatically.
// The result is freed when needed.
[kbmMW_Method(‘EchoPerson’)]
[kbmMW_Rest(‘method:post, path: “echoPerson”‘)]
function EchoPerson([kbmMW_Rest(‘value: “body”, free:false’)] const APerson:TPerson):TPerson;