In Service Builder 9.7.115.1441, CodeGen generates his (Delphi) implementation:
function GetScenarioDocumentInstructions(const Scenario: Integer; const Document: ROUTF8String; const DocumentLanguage: Integer): ROUTF8String; virtual;
Note that the “UnitNumber” input parameter is missing.
When I do a CodeGen (C# for .NET) I get a correct function in implementation
public virtual string GetScenarioDocumentInstructions(int Scenario, string Document, int DocumentLanguage, string UnitNumber)
When I do a CodeGen (Delphi) with Service builder version 9.6.113.1419 I also get a correct function in implementation:
function GetScenarioDocumentInstructions(const Scenario: Integer; const Document: ROUTF8String; const DocumentLanguage: Integer; Const UnitNumber: ROUTF8String): ROUTF8String; virtual;
When I rename the result parameter to UnitNumber2, the function in the implementation file is created correctly. However, I can’t just rename this because this breaks functionality in our client apps.
Thanks, the Code Generation works as expected in 10.0.0.1521
But now I run into another problem (not present in v 9.7): when making a call from a browser I get a CORS error:
Access to XMLHttpRequest at ‘X’ from origin ‘Y’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
The component I use is a TROIndyHTTPServer and SendCrossOriginHeader is set to true
In fact, combined with version 9.7 the same project worked flawless.
I defined cors like this, but the error message “No ‘Access-Control-Allow-Origin’ header is present on the requested resource.” keeps popping up.
function TdmServer.svrHTTPSendCrossOriginHeaderEx(
var Cors: TROCorsStruct): Boolean;
begin
Cors.AllowedOrigin := ‘*’;
Cors.AllowedMethods := ‘GET, POST, PUT, MERGE, DELETE, HEAD, OPTIONS’;
Cors.AllowedHeaders := ‘Content-Type, User-Agent, Authorization, Access-Token, X-Requested-With’;
Cors.MaxAge := 86400;
end;
Perhaps it might help you, but when I compile the project with remoting SDK 9.6 or 9.7 there is no CORS problem, even without this SendCrossOriginHeaderEx event.
Did something change in version 10 that could impact CORS handling?
When I downgrade from version 10.0.0.1521 to 10.0.0.1457, my CORS problem dissapears.
This version doens’t have OnSendCrossOriginHeaderEx, but even with an empty OnSendCrossOriginHeader the header “Access-Control-Allow-Origin = *” is showing in the response (because of the SendCrossOriginHeader property set to true).
For now, I will stick with the 10.0.0.1457 version. This version does the expected.
But my initial problem, that CodeGen generates an incorrect implementation file when an input and output parameter have the same name (only in Delphi, in C# it is correct) isn’t solved in this version.
I installed the latest of RO Remoting SDK for .NET, version 10.0.0.1521
However, when I try to compile my project I get errors in the generated interface file:
[dcc32 Error] RAC_Intf.pas(12598): E2003 Undeclared identifier: ‘TROAsyncCallbackMethod’
That is because the versions of ServiceBuilder and RO should match.
By trial and error, I found that version 10.0.0.1495 solves both problems: CORS and CodeGen are OK now. Let’s hope I don’t need to upgrade soon