help with web methods

Post

Posted
Rating:
#1 (In Topic #411)
Trainee
salihburhan is in the usergroup ‘Trainee’
I need to integrate a web service into my desktop application..
I tried to use httpclient of curl, but could not. I have no idea what I am doing.. 8)
If anyone has a sample code for me to debug, I'd be most grateful.
All I need to do is use some methods on the remote server.

Here is how I failed (the objective is to run IsEInvoiceUser on the server):

  $ww = "<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">" &
        "<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">" &
        "<IsEInvoiceUser xmlns="http://tempuri.org/">" &
        "<userInfo Username="Uyumsoft" Password="Uyumsoft"/>" &
        "<vknTckn> 9000068418 </vknTckn>" &
        "<alias/></IsEInvoiceUser>" &
        "</s:Body>" &
        "</s:Envelope>"
  
  $cu.URL = "http://efatura-test.uyumsoft.com.tr/services/BasicIntegration"
  $cu.User = "Uyumsoft"
  $cu.Password = "Uyumsoft"
  $cu.Begin()
  $cu.Post("application/json", $ww)
  $wRes = $cu.Peek()
  Message($wRes, "OK")
  $cu.Close()
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Guru
cogier is in the usergroup ‘Guru’
cogier is in the usergroup ‘GambOS Contributor’
I am not sure if this will help but please have a look. I have written code to access web based APIs. My program 'Your_Location' is one. It is on the Gambas Farm or available here. Look at the 'Web.Class'.
Online now: No Back to the top

Post

Posted
Rating:
#3
Trainee
salihburhan is in the usergroup ‘Trainee’
Thanks for the reply..
OK. Trying out your code, I get segmentation fault.. (I get it all the time in new OS installations since 2020)  :(
It used to be because of qt. Solved it by removing qt from the code. This time, I am using gtk3.
Here is the code.. (This code is the whole program)..





' Gambas class file


Public Sub Button1_Click()

  Dim hClient As HttpClient                                                     'To create a HTTP Client
  Dim sResult As String
  
  hClient = New HttpClient As "hClient"                                         'Create a HTTP Client
  With hClient                                                                  'With the Client..
    .URL = "http://efatura-test.uyumsoft.com.tr/services/BasicIntegration/IIntegration/GetInboxInvoiceList"      'Set up the URL
    .Async = False                                                              'No Asynchronous transmission?
    .TimeOut = 60                                                               'Don't hang around waiting for more than 60 seconds
    .User = "Uyumsoft"
    .Password = "Uyumsoft"
    .get                                                                        'Get the data
  End With
  If Lof(hClient) Then sResult = Read #hClient, Lof(hClient)
  Message(sResult, "Tamam")
End
Online now: No Back to the top

Post

Posted
Rating:
#4
Avatar
Guru
cogier is in the usergroup ‘Guru’
cogier is in the usergroup ‘GambOS Contributor’
What OS are you using and how did you install Gambas?
Online now: No Back to the top

Post

Posted
Rating:
#5
Trainee
salihburhan is in the usergroup ‘Trainee’
 Debian 10.4, installed it with apt.

The segmentation fault came up in three different computers (a few moths ago) with our erp after an os update. All with debian, one with fedora.
With debian, it happened when I installed testing (11). I solved it by switching from qt to gtk3.
This one, your code, I was using 10.4.

I believe this peculiar to me. Maybe it is connected to a bug I have discovered in the gambas IDE.
During coding, when I use this character (such as message("","")): "
Sometimes the IDE crashes while I type (for about more than a year at least). This was a most frequent issue, not a once in while thing.
So I write it somewhere else and cut / paste the text inside the "". As long as I do this: Message("","") first, then paste the text no problems either running, or coding..

It might be that this has something to do with the Turkish layout (not os language) I am using and somehow, also connected to this segmentation fault business.

Any ideas would be appreciated.
Online now: No Back to the top

Post

Posted
Rating:
#6
Trainee
salihburhan is in the usergroup ‘Trainee’
 edit.
Worked fine with debian bullseye just now. Exactly the same code. I am confused.
Online now: No Back to the top
1 guest and 0 members have just viewed this.