help with web methods

For questions about Gambas web tools.
Post Reply
salihburhan
Posts: 15
Joined: Thursday 24th October 2019 2:14pm

help with web methods

Post 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=\"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/ser ... ntegration"
$cu.User = "Uyumsoft"
$cu.Password = "Uyumsoft"
$cu.Begin()
$cu.Post("application/json", $ww)
$wRes = $cu.Peek()
Message($wRes, "OK")
$cu.Close()
User avatar
cogier
Site Admin
Posts: 1117
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: help with web methods

Post 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'.
salihburhan
Posts: 15
Joined: Thursday 24th October 2019 2:14pm

Re: help with web methods

Post 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 = "http://efatura-test.uyumsoft.com.tr/ser ... 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")
End
User avatar
cogier
Site Admin
Posts: 1117
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: help with web methods

Post by cogier »

What OS are you using and how did you install Gambas?
salihburhan
Posts: 15
Joined: Thursday 24th October 2019 2:14pm

Re: help with web methods

Post 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.
salihburhan
Posts: 15
Joined: Thursday 24th October 2019 2:14pm

Re: help with web methods

Post by salihburhan »

edit.
Worked fine with debian bullseye just now. Exactly the same code. I am confused.
Post Reply