Page 1 of 1

help with web methods

Posted: Friday 15th May 2020 3:04pm
by salihburhan
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=\"\">" &
"<s:Body xmlns:xsi=\"\" xmlns:xsd=\"\">" &
"<IsEInvoiceUser xmlns=\"\">" &
"<userInfo Username=\"Uyumsoft\" Password=\"Uyumsoft\"/>" &
"<vknTckn> 9000068418 </vknTckn>" &
"<alias/></IsEInvoiceUser>" &
"</s:Body>" &

$cu.URL = " ... ntegration"
$cu.User = "Uyumsoft"
$cu.Password = "Uyumsoft"
$cu.Post("application/json", $ww)
$wRes = $cu.Peek()
Message($wRes, "OK")

Re: help with web methods

Posted: Sunday 17th May 2020 3:07pm
by cogier
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'.

Re: help with web methods

Posted: Friday 29th May 2020 9:00am
by salihburhan
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 = " ... nvoiceList" '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")

Re: help with web methods

Posted: Friday 29th May 2020 2:51pm
by cogier
What OS are you using and how did you install Gambas?

Re: help with web methods

Posted: Saturday 30th May 2020 9:43am
by salihburhan
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.

Re: help with web methods

Posted: Saturday 30th May 2020 10:39am
by salihburhan
Worked fine with debian bullseye just now. Exactly the same code. I am confused.