Calling XData service operation error

Hello!

I have a WebCore app that calls an XData service operation. XData is working OK, I tested it via Swagger.

In the webCore app I have a connection and a TXDataWebClient. The connection connects correctly

When executing this (after a button click, the connection is already active:

clientOpenDoor.RawInvoke('IDoorService.CheckPin', [1, 4]);

I get this error:

Uncaught ReferenceError: Result is not defined
    at Object.TValue_ToString (Bcl.Rtti.Common.pas:69)
    at Object.Create$2 (Bcl.Rtti.Common.pas:62)
    at Object.c.$create (rtl.js:323)
    at Object.TValue_AsString (Bcl.Rtti.Common.pas:109)
    at Object.TryValueToUrl (XData.Types.Converters.pas:435)
    at Object.ValueToUrl (XData.Model.Classes.pas:949)
    at Object.BindValueToUrl (XData.Bind.Converter.pas:17)
    at Object.BuildQueryString (XData.Web.Client.pas:1140)
    at Object.Execute (XData.Web.Client.pas:1240)
    at Object.InternalRawInvoke (XData.Web.Client.pas:643)

Nothing is sent, the error seems to happen before any network activity (at least as I can see in the browser console).

Service operation contract

unit DoorServiceInterface;

interface

uses
  System.Classes, Generics.Collections, XData.Service.Common, Aurelius.Mapping.Attributes;

type
  [ServiceContract]
  IDoorService = interface(IInvokable)
    ['{8A8D8359-9D20-4FDA-9B7E-A622C9F990EA}']
    [HttpGet]
    function CheckPin(Door: integer; Pin: string): boolean;
  end;

implementation

initialization
  RegisterServiceType(TypeInfo(IDoorService));

end.

I'm stuck, any suggestion would be appreciated. :slight_smile:

If you need any additional code or nformation, I would be happy to provide it.

The second parameter in CheckPin is a string type, have you tried call it like this:

clientOpenDoor.RawInvoke('IDoorService.CheckPin', [1, '4']);

?

Thank you, that was the mistake. Now works like a charm :)

1 Like

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.