moctes

Forum Replies Created

Viewing 12 reply threads
  • Author
    Posts
    • #57073
      moctes
      Participant

      After posting this I remembered that the Date(Time) type is a number, so for now I solved it like this:

      QueryMT.ExecSQL( Format(‘select * from expenses where myDateField >= %d’, [trunc(myDate)]) );

      Still if there is a better way to do it tips are welcome

    • #55861
      moctes
      Participant

      I couldn’t afford to wait too many days for a response, so I took another route to get rid of the CORS requirement, I’ll take a look at it as soon as time allows.

      Thank you anyway.

    • #55824
      moctes
      Participant

      I tried to correct the wording to my post to make it clearer but it seems that it is not allowed, I will rewrite it below:

      I’m struggling calling the webservices I have developed as smartservices, whenever I use some kind of authorization header (Basic, Bearer) from a request made from the browser ( using fetch API, axios, etc ) the browser sends a CORS PREFLIGHT REQUEST to the kbm server, and here is where the problem arises, I have traced down the request to TkbmMWCustomSmartService.ProcessRequest on kbmMWCustomSmartService.pas, as you can see it hast the following check:

      var
         flags:TkbmMWSmartServiceMethodFlags;
      begin
           if not FSupport.CallMethod(self,Func,'','',ClientIdent,Args,RequestStream,Result,flags,ResponseTransportStream.RTTIAttributes) then
              kbmMWRaiseException(KBMMW_ERR_SERVICENOTAVAIL,'Request not supported')
           else

      At this point the value of Func is OPTIONS and it is raising the exception.

      What can be done to support the CORS preflight request ?

      Edited: Redaction, I hope is better now

    • #55577
      moctes
      Participant

      Seem like declaring an alias class for hobbies solves the problem, something like:

      THobbies = TObjectList<THobby>;
      Then I can have in TMyResult :
      Hobbies: THobbies;

      Error gone :), I quickly applied the same strategy on the real code, but I’m getting this in the result when the objectlist is empty:
      "Hobbies":[true,0,0],

      and when I add data, seems to be duplicated, the element is part of the array but also appears as a nested array, so I’m changing all the TObjectlist fields to plain old arrays for now.

      Thank you all.

    • #55416
      moctes
      Participant

      Thank you Kim,

      I will give these posts a more careful read, I quickly searched in the posts you suggested and altogh I saw this:
      The moment you try to this call:

      http://localhost:1111/biolife/specieByCategory/Butterflyfish

      You will be requested for a login by the browser. If you provide the user name and password matching a user in the database having the role AdminRole, you will be shown the result of the request

      As it would be no browser involved, I could not find how to pass user name and password to the API services, may be as url parameters, i.e.

      Authentication
      http://localhost:1111/biolife/auth?username=DEMO&pass=demo

      Authorization
      http://localhost:1111/biolife/specieByCategory/Butterflyfish?token=accesstoken

      as a POST request with the data as JSON on the body ?
      POST http://localhost:1111/biolife/auth
      { "username": "DEMO", "password": "demo" }

      Maybe in some Header ?

      I have access to the source code of kbm of course, but a white paper, blog post or sample project showing how to achieve this would be great.

      Regards

      P.S, I don’t know if my question will be duplicated, I sent it before but I didn’t see it published

    • #55425
      moctes
      Participant

      Some how I missed this

      Currently kbmMW supports HTTP Basic authorization which is stored in the header

      That’s a show stopper for me, basic authentication is, well, basic, please forgive my previous posts (unapproved), I need to review what my options are and make a decision before any further development

    • #55304
      moctes
      Participant

      Thanks for answering,

      If I run the server and make some calls to services and then I stop the server, all is well, the problem occurs every time I run a batch of calls which are supposed to be made at the end of each day, but only if  I run them with a compiled 64 bits binary.

      I’m actually evaluating the task of porting the code to a more recent version of Delphi ( 10.3.3 for the tests) thats the only reason I bought again a license of kbmMW pro, the project is being currently running in production ( and has been for a few years ) compiled with an older version of kbm and Delphi XE whithout issues, in fact, I can run a fresh compiled exe with Delphi 10.3.3 compiled as 32 bits and the problem is not present.

      This is the pattern used from the client application:

      client := nil;
      Try
      client := TMyKbmClient.Create(FConfigServer);
      ResultServer := client.execute(
      ‘ModuleSVC’, ‘MyService’,
      [param1, param2, param3] );
      Finally
      FreeAndNil(client);
      End;

      where
      TMyKbmClient.Create(

      basically wraps a TkbmMWTCPIPIndyClientTransport & TkbmMWSimpleClient for doing calls to the server with Execute which does among other stuff the call to the server with a Request:

      FSimpleClient.Request(ModuleSVC,”,MyService, Args);

      The client application executes a batch of this calls to different server functions a number of times which can be between 250 to 400 service calls depending on the day of the month, configuration, etc., after the client has been closed, if I go to the server application and close it,  everything seems to end fine, we have a procedure to stop the server that runs before closing the application which looks like this:

      mwServer.OnGarbageCollection := nil;
      mwServer.Shutdown;
      repeat
      sleep(100);
      until (mwServer.ShuttingDown);
      mwServer.Active := False;

      The shutdown & repeat cycle was added recently  just to see if it helped solve the problem, but no, the above code runs fine no errors whatsoever

      It is not until (Delphi) destroys the auto created data module that contains the Server, Transport, ConnectionPool, PooledSession that the problema arises and only on the 64 bits binary.

      You missed this part of my original post:

      I extended my SAU for one year but it is not reflected on the portal
      To use the ORM and bindings one needs to have the enterprise version ?

       

      • This reply was modified 5 years, 7 months ago by moctes.
    • #55280
      moctes
      Participant

      Everything is alright ? This is worrying, it has been almost 5 days since I asked the question (and much more since my email), without any news so far.

      I hope it is because you are on vacation and not because you are sick or something like that, but you really should think about having at least one person who is aware of what is happening around here.

      I really need help with this and time flies, it would be great if I can have this resolved before the end of the year, if you need more information from me I am at your service.

      With best regards,
      Mocte

      • This reply was modified 5 years, 7 months ago by moctes.
    • #54998
      moctes
      Participant

      In the mean time I’m trying tos solve the issue, I downloaded previous versions so I can copy the missing files to the current and see if it them can be mixed with the latest without troubles, I downloadeded :

      5.09.0
      5.10.1
      5.10.2
      5.11.0
      5.12.1

      I didn’t install them in the IDE, I just did the extraction of the files, but there are no *RPC*.pas files in those versions either.

    • #54832
      moctes
      Participant

      Thank you ! 🙂

    • #54831
      moctes
      Participant

      Purchase made, I did my licence request on May 21, still waiting for approval.

      Would you mind checking it?

    • #54771
      moctes
      Participant

      Ok, my old https://portal.components4developers.com/ credentials doesn’t work anymore, I will bite the bullet and go for a pro License, I will try to make it work on Lazarus and if that is not possible I’ll have to discuss with my customer if he can give me access to a more recent Delphi or  we move out from pascal for this matter.

    • #54139
      moctes
      Participant

      Perfect, thank you Kim

    • #55504
      moctes
      Participant

      Ok, I did some exploration after reading some of those posts just for getting a rest server up and running, so now I want to use both approaches in the same project.

      Thank you Kim

Viewing 12 reply threads