Web forum is in read-only mode. Login as active registered customer for write access
  Forum Search   New Posts New Posts

UniDAC + XData get CoInitialize problem

 Post Reply Post Reply
Author
Sitthidumrong Worajedt View Drop Down
New Member
New Member
Avatar

Joined: 24 Jul 2019
Posts: 2
Post Options Post Options   Quote Sitthidumrong Worajedt Quote  Post ReplyReply Direct Link To This Post Topic: UniDAC + XData get CoInitialize problem
    Posted: 04 Sep 2019 at 7:21am
Hi there

I'm not sure how many people using UniDAC with XData. I'm trying to follow a video on TMS channel and trying to connect XData with SQL Server's Northwind DB.
  • Delphi Community 10.3.2, Also tested on Delphi 10.2.3 Enterprise. Same result
  • UniDAC Demo 8.0.1
  • SQL Server Express 2016 with Windows Authentication, open TCP/IP connection and port 1433
I can connect to database with UniConnection properly.
I can get the list of model classes via http://localhost:2001/tms/xdata
but I cannot get the data in each classes like http://localhost:2001/tms/xdata/customers







Back to Top
Sitthidumrong Worajedt View Drop Down
New Member
New Member
Avatar

Joined: 24 Jul 2019
Posts: 2
Post Options Post Options   Quote Sitthidumrong Worajedt Quote  Post ReplyReply Direct Link To This Post Posted: 04 Sep 2019 at 7:26am
Sorry for the images didn't show above.

Back to Top
Wagner R. Landgraf View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 2389
Post Options Post Options   Quote Wagner R. Landgraf Quote  Post ReplyReply Direct Link To This Post Posted: 04 Sep 2019 at 4:38pm
Hi, from your project, it looks like you are mixing two ways of creating a XData Server. You are using the legacy approach (where you have the TXDAtaServerModule being created manually from code) and then you dropped a TXDataServer component. The TXDataServer component you dropped is not being used, thus the code you added to its event is also not being used.
I'd suggest you create a new application using the "TMS XData VCL Server" wizard. That will properly setup the components in the way you need. It's actually much simpler than your code.
If you want to fix your existing code, then you should remove the TXDataServer component and add the middleware code to your TXDataServerModule directly in code, inside the StartServer procedure declared in unit Server:

  Module := TXDataServerModule.Create('http://+:2001/tms/xdata',
    TUniDacMSSQLConnection.CreatePool(20));

  Module.AddMiddleware(TAnonymousMiddleware.Create(
    procedure(Context: THttpServerContext; Next: THttpServerProc)
    begin
      CoInitializeEx(nil, COINIT_MULTITHREADED);
      try
        Next(Context);
      finally
        CoUninitialize;
      end;
    end));
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down