No results from XData server

I created a very basic XData server connected to a MSSQL database. When I enter the url in a browser it will give me all the tables.
When I create a basic web core module and I execute the XDataConnection1.Loadmodel. Nothing happens. If I use your demo url it will return the model. The returned values in the browser look identical.
 This has me completely stumped... Even the showmessage does not happen...

code:
procedure TForm1.WebFormCreate(Sender: TObject);
begin
    XDataConnection1.URL := 'http://localhost:2001/webdata'; //'http://app.devgems.com/music';// 

    Try
        XDataConnection1.LoadModel;
    Except
        on E: exception do
            ShowMessage(E.Message);
    End;
end;

procedure TForm1.XDataConnection1ModelLoad(Sender: TObject);
var
    I: Integer;
    Names: TStrings;
    Container: TXDataEntityContainer;
begin
    ShowMessage('in loadModel');
    Names := cbEntitySets.Items;
    ShowMessage('Names defined');
    Container := XDataConnection1.Model.DefaultEntityContainer;
    ShowMessage(IntToStr(Container.EntitySets.Count));
    if Container <> nil then
        for I := 0 to Container.EntitySets.Count - 1 do
           

Please be aware that communications in web happens asynchronously. So wrapping LoadModel call in a try..except block won't do much. I suggest you open the browser console, then reload your page and check if there are any error messages there. 


Have you recompiled your XData server using the latest version (2.8)? That is required to work with TMS Web XData Client as it publishes the /$model endpoint which provides metadata information about the API, needed by the web client to work properly.

Thanks Wagner. If have just installed the latest versions. Will try again.

This is the error I get:

'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8000' is therefore not allowed access.

You should add this code to your server:



XDataServerModule.AccessControlAllowOrigin := '*';


That has security implications. More info here: https://www.tmssoftware.com/site/blog.asp?post=305

I was looking where to set this. Missed it completely...
Will have a look at the security and set accordingly.

Works now Thanks.