Jump to content

ertank

Members
  • Content Count

    246
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by ertank

  1. ertank

    Install failed older sdk

    Hi, I did find a solution but I cannot remember what was it now. You can try updating libraries to defaults
  2. Hello, I am using Delphi 11.3. Using the stock WSDL Importer tool and https://pb.diyalogo.com.tr/PostboxService.svc URL produce below remarks in the unit which does not compile // Cannot unwrap: // - More than one strictly out element was found I would like to learn if it is possible to generate unit usable with Delphi. If yes, how can I do that? Any help is appreciated. Thanks & Regards, Ertan
  3. ertank

    Help needed for importing a WSDL

    Using suggested modification and unit compiles. I will see if it works once I receive working username and password. Thank you.
  4. Hello, I need to convert a C# project into Delphi. This project is using a C++ DLL and passing a struct named Members to the DLL. I could not make same size record in Delphi. There is a 4 byte difference and Delphi is smaller. The Members struct has more than 80 string variables, one enum type and three other structs. These three other struct sizes are exactly match to Delphi conversions. They all have StructLayout as Sequential defined. But, Members struct has no StructLayout at all. Actually, it was defined as Sequential before but now that code is remarked. There are only MarshalAs for strings like below [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] public string StartRNo; I searched on the web and I think I should convert above to Delphi as following StartRNo: Array[0..31] of AnsiChar; This Delphi definition give me exact size for three other structs. They have only string variables. DLL function calls are CharSet.Ansi for all, but the only one using the Members struct is defined as CharSet.Unicode. If I am to use Char instead of AnsiChar on Delphi side for strings (just for the Members record), difference is a lot more like double. I am unable to figure why there is a 4 byte difference and how to make both C# Members struct and Delphi record identical. Any help is appreciated. Thanks & Regards, Ertan
  5. ertank

    C# struct to Delphi conversion help

    Even if I make it identical C# enum with Delphi enum, There is still one byte difference in total struct vs record comparison. I check even the last item offset in C# struct matches to Delphi and this last item size also matches on both C# and Delphi. It must be that C# has one byte more at the very bottom of its struct. @FPiette advise to add it at the end of Delphi record as a dummy variable and I can do that. I wonder if I absolutely need it? If I do need it, I wonder if there is another way of handling that in newer Delphi versions like a compiler directive {$MINENUMSIZE 4}? Thanks.
  6. ertank

    C# struct to Delphi conversion help

    I used x86 target on C# project and Delphi side is also 32bit application. Using your offset function revealed some differences. C# struct "Members" has following remarked offsets (Layout is indeed commented in the project code. I removed remark for testing and this didn't change total struct size) //[StructLayout(LayoutKind.Sequential)] public struct Members { public Tags ResponsedTag; // Offset 0 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] public string StartRNo; // Offset 4 // continues and ends as following public GrupDF02 groupDF02; public GrupDF41 groupDF41; public GrupDF6F groupDF6F; } However, Delphi record has following offsets. I intentionally didn't use packed record as I am completely unsure of the C# side. TMembers = record ResponsedTag: TTags; // Offset 0 StartRNo: Array[0..31] of AnsiChar; // Offset 1 // continues and ends as following groupDF02: TGrupDF02; groupDF41: TGrupDF41; groupDF6F: TGrupDF6F; end; Tags is an enum and takes up 4 bytes in C# but 1 byte in Delphi. That explains 3 bytes difference. I'm not sure about the reason of this difference. These last three item's sizes on C# and Delphi are the same. When I compare the very last item "groupDF6F" offsets, the difference is still 3 bytes. So, I could not find a reason for total difference of 4 bytes. I don't know how I can modify Delphi to match C# just for this enum difference. I could not find where this remaining 1 byte difference is coming from.
  7. ertank

    Problem with JSON library "SuperObjects"

    I do not know about Superobjects but Delphi standard json library can do following uses System.JSON, System.Generics.Collections; procedure TForm1.Button1Click(Sender: TObject); const JsonText = '{ "splash.annually": "normal" }'; var Json: TJSONValue; begin Json := TJSONObject.ParseJSONValue(JsonText, False, False); if Json <> nil then begin if Json.FindValue('["splash.annually"]') <> nil then begin ShowMessage(Json.FindValue('["splash.annually"]').AsType<string>); end; Json.Free(); end; end;
  8. ertank

    Importing WSDL

    You should report this error. Delphi 11.3 also has it.
  9. It does not work for me. I've very likely bitten by this bug numerous times but I didn't know the reason until now.
  10. Hello, I am trying to figure out a way to use two Veriban SOAP web services in a single project. These web services both are named same as IIntegrationService in imported WSDL units. http://efaturatransfertest.veriban.com.tr/IntegrationService.svc?wsdl http://earsivtransfertest.veriban.com.tr/IntegrationService.svc?wsdl For anyone interested, Veriban publicly make it available test user and password. Same for both webservices above. Username: TESTER@VRBN Password: Vtest*2020* If I build two separate VCL applications each using one of these services WSDL imported unit, everything is fine and works. But, If I rename WSDL imported units like VeribanEInvoiceIntegrationService.pas and VeribanEArchiveInvoiceIntegrationService.pas and put these files in uses section of a single VCL project. Login method runs fine for both of them. But VeribanEArchiveInvoiceIntegrationService.pas one gives me access violation for below method. My final goal is to use these services both in a single Windows Service project which currently gets same AV exception. It did not help to have wrapper classes for each service in a separate unit. http://earsivtransfertest.veriban.com.tr/IntegrationService.svc method GetSalesInvoiceUUIDListWithCustomerWithDate I make sure that I refer to each unit interface when casting THTTPRIO as below var RIO: THTTPRIO; WS: VeribanEArchiveInvoiceIntegrationService.IIntegrationService; LResponse: VeribanEArchiveInvoiceIntegrationService.ArrayOfString; begin ... WS := (RIO as VeribanEArchiveInvoiceIntegrationService.IIntegrationService); ... LResponse := WS.GetSalesInvoiceUUIDListWithCustomerWithDate(FSessionCode, LStartDate, LEndDate); // AV here My questions are: - Is there anything that I am missing which leads to AV? - Is it possible to use both of these services in a single project? Thanks & Regards, Ertan P.S. I attached AV call stack just in case.
  11. Yes, I now see that both web services are defined using the same GUID by WSDL importer. Their methods are different, things they do are different but both has identical name and GUIDs. After manually changing one of them to use a different GUID everything worked just fine in a single project. Thank you. P.S. I already build two separate DLLs and released them. They are working OK. But this GUID is something I will check for the future.
  12. I do not see that GUID information in WSDL or in imported unit. Do you know where can I find it?
  13. Hello, I am using v8.71 of ICS. There is a device connecting to my application and sending some data. So, I basically wait for a connection and communicate with that device both ways. Occationally, TWSocketClient.OnDataAvailable event triggers even if there is no data ( aka GetRcvdCount = -1) I just wonder if this is normal and what might be possible reasons? Thanks & Regards, Ertan
  14. Hello, There are some chain requests triggered from clients. Some requests among them takes time processing on the server side. I should send a response to client fast. Server side operations are not relevant to the response. Since, MARS is handling each request in a separate thread, I also created a custom thread for this time consuming operation and process it. My problem is, database context is removed as soon as response is sent and its thread is destroyed. Any further database operations from that point in my custom thread results in access violation. Is there a way that I can get a database connection from MARS database pool for my own custom threads independent of requests? Thanks & Regards, Ertan
  15. Hello, I have a company that would like to send me some data over a webhook. They want me to provide them access information for an x-api-key header. I know that MARS uses Authorization header for secure access. I am not sure if it is possible to support x-api-key header for a specific use case. Any help is appreciated. Thanks & Regards, Ertan
  16. ertank

    Handling webhooks using MARS

    Hi, I didn't know about HeaderParam attribute. [POST, Path('test')] function Test([HeaderParam('x-api-key')] const ApiKey: string; [BodyParam] const Body: string): string; Using above, I can check about ApiKey value in the function and use EMARSHttpException for returning a 404 error if necessary. I was searching a way to block a request with wrong x-api-key header value even before function code execution, but above approach is a solution, too. Thanks & Regards, Ertan
  17. ertank

    Handling webhooks using MARS

    Hi, If possible, I do not want to use existing "Authorization" header. I would like to allow access or block access depending on "x-api-key" header on each request. - x-api-key header missing: Block the request using 404 - x-api-key header exists: Check in a method that it is correct. Allow only if correct, else block the request using 404 Very basic example would be: Incoming request Header: x-api-key: my_own_key_data Incoming request Body: {"data":"Various json data. To be read as whole in a string"} Attached you can find is a sample postman request. Thanks & Regards, Ertan webhook_test.postman_collection.json
  18. Hello, MARS file serve samples are based on fixed static data (ContentTypes demo). I have several endpoints serving dynamic data in ZIP files. When upload finishes on the server side, remaining temporary files are kept on disk. This become a problem on server systems in time. I would like to learn if it is possible to have MARS delete them automatically at the end of the communication. I will write my own thread but asking before just in case. Thanks & Regards, Ertan
  19. Hello Andrea, I did already coded a thread for that purpose which seems to work fine for the time being. I will also check AfterInvoke. Thanks.
  20. What you are looking for is "Inter Process Communication" aka IPC. For more details you can look here I used Cromis for named pipes. There is built in encryption support in that library, if you may need such functionality.
  21. ertank

    Mac address on Android 6.0 or above

    Hello, As of Android 6.0 we cannot read mac address using an app as indicated in here: https://developer.android.com/about/versions/marshmallow/android-6.0-changes.html#behavior-hardware-id It seems some people have success reading it on network interfaces. I have seen some java code that I cannot translate and test on an Android 7.0 device. An example with several code alternatives: https://stackoverflow.com/questions/33159224/getting-mac-address-in-android-6-0 1- If anybody can share some working code that would be appreciated. 2- I have no information on how reliable device unique id on Android devices. I have that Chinese made hand held barcode terminal running modified Android OS. I cannot be sure if unique device id is actually globally unique independent of modifications to Android OS. Any information on that or links to read is appreciated. Thanks & regards, Ertan
  22. ertank

    DL a file from the web

    There maybe other codes shorter. Below should work on FMX and VCL for versions that has NetHTTPClient support. procedure TForm1.Button1Click(Sender: TObject); var MS: TMemoryStream; Response: IHTTPResponse; begin MS := TMemoryStream.Create(); try try Response := NetHTTPClient1.Get('my_url', MS); if (Response.StatusCode < 200) or (Response.StatusCode > 299) then begin raise Exception.Create('Throw an exception or log response. Something is wrong'); end; except on E: Exception do begin raise Exception.Create('Throw the exception or log it'); end; end; //Do what you need to do with the memory stream finally MS.Free(); end; end; I placed a component on the form itself for above example. If you need to create TNetHTTPClient instance by code, you will need following units in your uses uses System.Net.URLClient, System.Net.HttpClient, System.Net.HttpClientComponent; That code (having changed necessary parts) supposed to work on Windows, Linux, MacOS as it is without you to install any external libraries like OpenSSL libraries. If you get rid of error handling, you'll end up with a shorter version. This is something not suggested as you would know. I do not understand why you are after "shortest" code though.
  23. ertank

    Parse Json again, complicated

    Hello, Your "complete" json is not valid. You should edit your post and fix it. There are more than one way to solve this. Below is an example with a lot of error checks. type TAnimal = record id: Integer; name: string; end; TAnimalList = TArray<TAnimal>; //----------------------------------- implementation //----------------------------------- uses System.JSON, System.Generics.Collections; const JsonString = '{"result":[{"animals":[{"id":1,"name":"pig"}]}]}'; function ParseAnimalsJson(const Json: string; out AnimalList: TAnimalList): Boolean; var LTestJsonValue: TJSONValue; LJson: TJSONValue; LJsonArrayResult: TJSONArray; LJsonArrayAnimals: TJSONArray; I: Integer; begin LTestJsonValue := TJSONObject.ParseJSONValue(Json, False, False); if LTestJsonValue = nil then begin Exit(False); end; try LJson := LTestJsonValue.FindValue('result'); if LJson = nil then Exit(False); if not (LJson is TJSONArray) then Exit(False); LJsonArrayResult := LJson as TJSONArray; if LJsonArrayResult.Count = 0 then Exit(False); LJson := LJsonArrayResult[0].FindValue('animals'); if LJson = nil then Exit(False); if not (LJson is TJSONArray) then Exit(False); LJsonArrayAnimals := LJson as TJSONArray; SetLength(AnimalList, LJsonArrayAnimals.Count); for I := 0 to LJsonArrayAnimals.Count-1 do begin LJson := LJsonArrayAnimals[I].FindValue('id'); if LJson = nil then Exit(False); AnimalList[I].id := LJson.AsType<Integer>; LJson := LJsonArrayAnimals[I].FindValue('name'); if LJson = nil then Exit(False); AnimalList[I].name := LJson.AsType<string>; end; finally LTestJsonValue.Free(); end; Result := True; end; procedure TForm1.Button1Click(Sender: TObject); var List: TAnimalList; begin if ParseAnimalsJson(JsonString, List) then begin ShowMessage('Parse completed'); end else begin ShowMessage('Parse failed!'); end; end;
  24. Hello, There is a project that I have problem loading with Delphi 10.4.2. Main form is not loaded and Structure has below error line in it E2029 Declaration expected but end of file found at line 1 (1:1) I checked the DFM and PAS files using text editor and also hex editor. Both seems fine to me. Only thing is PAS file is UTF8 with BOM and that is not a problem at all. BOM bytes are also correct (ef bb bf). Unit file begins as following second line with a remark DFM file begins as following Project is from a private subversion repository. I checkout that repository as fresh in another directory and I still could not open it. But, another computer with Delphi 10.3.3 can load the project and its main form just fine. DFM size is 3,544,092 bytes PAS size is 414,839 bytes I didn't hear any limit about dfm/unit size. Providing these information just in case. My internet searches lead to actually corrupt files having similar errors and line number is not one. Wanted to ask in here with the hope that I am not the only person and there is a way to solve the problem. Thanks & Regards, Ertan
  25. ertank

    Cannot open project main form

    Once line endings are fixed, project opened just fine. Seems Delphi 10.3.3 breaks them. Maybe when file is UTF8 encoded...
×