TXDataWebClient NOT implemented????

Hi,
We try to connect to a XData serice developed by us using an XDataWebClient in a WebCore TMS app.

After struggling with a lot tests and using your documentation (rawinvoke method) we discovered inside unit XData.Web.Client folowing code!

{ TXDataWebClient }

procedure TXDataWebClient.Delete(const EntitySet: string; Entity: TJSObject;
  const RequestId: string);
begin

end;

procedure TXDataWebClient.Get(const EntitySet: string; Id: JSValue;
  const RequestId: string);
begin

end;

procedure TXDataWebClient.Get(const EntitySet, QueryString: string; Id: JSValue;
  const RequestId: string);
begin

end;

procedure TXDataWebClient.List(const EntitySet, Query, RequestId: string);
begin

end;

procedure TXDataWebClient.Notification(AComponent: TComponent;
  Operation: TOperation);
begin
  inherited;
  if (Operation = opRemove) and (AComponent = FConnection) then
    Connection := nil;
end;

procedure TXDataWebClient.Post(const EntitySet: string; Entity: TJSObject;
  const RequestId: string);
begin

end;

procedure TXDataWebClient.Put(const EntitySet: string; Entity: TJSObject;
  const RequestId: string);
begin

end;

procedure TXDataWebClient.RawInvoke(const OperationId: string;
  Args: array of JSValue; const RequestId: string);
begin
end;

IS this a joke?
Practically you haven't implemented any of the methods we hoped we can use un web apps developed using your webcore components.
Please tell us what to do in order to consume our webservices (TMS servers) inside webcore apps.

I suspect you do not look at the right place for the code.
Do you look under folder \Core Source\XData ?

If you take a Ctrl-Click link in Delphi you will be taken to the Component Source folder and not the Core Source folder (Which gets compiled)

My TMS setup is looking for XData.Web.Client.pas under: D:\ddev_global\TMSSoftware\TMS XData\source\core
where D:\ddev_global\TMSSoftware\ is the TMS general path.

Apparently the right file should be under:
TMSSoftware\TMS WEB Core RSXE14\Core Source\XData\

for Delphi Alexandria?
What should I do to make it use this instead of XData path?
Shouldn't the TMS installer do this automatically?

And the installer registers the following paths in Library path:
d:\ddev_global\TMSSoftware\TMS WEB Core RSXE14
d:\ddev_global\TMSSoftware\TMS WEB Core RSXE14\Win32
d:\ddev_global\TMSSoftware\TMS WEB Core RSXE14\Component Library Source

Nothing else for WebCore. What should we do?

I think Win32 is possibly compiled from Core Source. Don't forget that the actual compiling isn't a normal Delphi compile but is built through Pas2JS, so this possibly has it's own paths set.

@Padureanu_Dor_Bujor what are the issues you are having? What errors are being raised?

When you compile a TMS WEB Core app with the pas2js compiler, the library path for this pas2js compiler configured under Tools, Options, TMS WEB is used.
And in this path should be \Core Source\XData

There is no error.
It simply doesn't work because it uses "fake" unit from ...\TMS XData\source\core instead of ...\TMS WEB Core RSXE14\Core Source\XData\ where indeed it is the actual implementation.
I added the path as Bruno said in the Library path for TMSWebCore but it still uses the XDATA path because it has precedence.

So, you have installed TMS XData also separately?

Thank you @brunofierens your reply.
I finally understand the way it works.

You use the functions declarations only units in order to allow XData to work and be compiled as standard VCL/FMX apps from Delphi.
In fact, at JS conversion step (compiling web app), for an Web Core App you replace the global Library path declarations with ones from TMS Web Tab, the JS right ones.

Thank you @Weetch_Russell too for explaining that. It took some time until I understood what you where saying.

It finally worked after adding the Core Source\XData\ path to TMS Web tab in Tools/Options.

We could successful connect to our XData service for authentication and retrieve the JWT Token we use for further calls.

But now we encounter a different problem regarding accessing the XData Service.
At WebFormCreate we use following code:

//  XDataWebConnectionAuth.URL     := 'http://localhost:2000/auth';
  XDataWebConnectionAuth.URL       := 'https://realserver.magister.ro/auth';
  XDataWebConnectionAuth.Connected := True;

When using local server everything works fine, but when we use the production https connected server it raises "Error connecting to XData server" error.

The service is in use and functions well with all VCL XData Clients, so I cannot suspect any https certificate problem.
In browser we found the following error:

Access to XMLHttpRequest at 'https://realserver.magister.ro/auth/$model' from origin 'http://localhost:8000' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains multiple values '*, *', but only one is allowed.strong text

Is there anything we should check or setup in order to allow accessing of this service from the web core app?

It looks like you should properly configure CORS in your server to allow requests from web applications running in other domains. Here is a small reference:

https://doc.tmssoftware.com/biz/xdata/guide/web.html#cors-issue

Thanks, but I already tried everything from that article.
Here is my code on the server module:

uses...  Sparkle.Middleware.Cors,  Sparkle.Comp.CorsMiddleware;

procedure TServerContainer.XDataServerModuleCreate(Sender: TObject; Module: TXDataServerModule);
begin
  Module.AddMiddleware(TCorsMiddleware.Create);
  Module.AddMiddleware(TCorsMiddleware.Create('smartcash.ro', 'GET,POST,DELETE,PUT'));
  Module.AddMiddleware(TCorsMiddleware.Create('my.smartcash.ro', 'GET,POST,DELETE,PUT'));
  Module.AddMiddleware(TCorsMiddleware.Create('localhost', 'GET,POST,DELETE,PUT'));
  Module.AccessControlAllowOrigin := '*';
end;

and we have the same reply

index.html:1 Access to XMLHttpRequest at 'https://argus.magister.ro/auth/$model' from origin 'http://localhost:8000' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains multiple values '*, *', but only one is allowed.

Is there anything we can do to disable CORS check?

Remove all lines and just add a single TCorsMiddleware instance.

Thanks @wlandgraf!
It worked ok.
Thank you all for your support.

1 Like