I have an XData server with JWT that works flawlessly with the
XDataclient when they both run on my machine.
For testing purposes I copied the XDataserver with the database and the client to an external Windows 2012 R2 server. First I tried to run client and server together on this machine and I keep getting this error:
Status
code: 500 Error Code: InOutError Invalid file name - %s
I then
tried to connect with the client from my machine to the server on
the external machine over the internet: same problem.
I narrowed the problem down to the moment I first use an objectmanager. I do this:
1. plain connection from the client to the server to get a JWT. This works ok.
2. JWT arrives and is correct (the same on both sides).
3. JWT Bearer header added.
ClientData.ClientConnectie.Client.HttpClient.OnSendingRequest :=
procedure(Req: THttpRequest)
begin
Req.Headers.SetValue('Authorization', 'Bearer ' +
cJWT);
end;
4. Request information about the database from the client:
ClientData.ClientConnectie.InitDatabaseInfo;
5. Function in the Servicepart of the XData server:
function TMyServerService.GetDatabaseInfo:
TList<TDatabaseInfo>;
var
Statement : IDBStatement;
DBStmt : IDBDatasetStatement;
OM : TObjectManager;
Dataset : TDataset;
cQuery : string;
DatabaseInfo: TDatabaseInfo;
begin
result := TList<TDatabaseInfo>.Create;
OM := TXDataOperationContext.Current.GetManager;
The error occurs in the last statement.
MadExcept gives this information:
exception number : 1
exception class : EXDataOperationRequestException
exception message : XData server request error. Uri: http://127.0.0.1:2021/myserver/functies/GetDatabaseInfo Status code: 500 Error Code: InOutError Invalid file name - %s.
main thread ($1490):
00a6daa7 +4d7 MyClient.exe XData.Client 513 +111 TXDataClient.GetServiceInterface$ActRec.$0$Body
004e3669 +039 MyClient.exe System.Rtti 11597 +2 TVirtualInterface.RawCallback
004e332f +027 MyClient.exe System.Rtti 11564 +0 TVirtualInterface.Create[1]$ActRec.$0$Body
004e3112 +076 MyClient.exe System.Rtti 11154 +4 TMethodImplementation.Intercept
004e2c9f +00b MyClient.exe System.Rtti 10908 +24 RawIntercept
00b5e473 +023 MyClient.exe UnClientConnectieIMP 374 +4 TClientConnectie.InitDatabaseInfo
This all works fine on my local machine and requesting the JWT works fine also. I just don't know what to look for.