Android Tutorial HttpUtils - Android web services are now simple!

Status
Not open for further replies.

pluton

Active Member
Licensed User
Longtime User
This is the problem. Regular global variables are tied to the activity life cycle.
parser should be a process global variable.

Another solution is to remove If FirstTime condition and initialize the parser every time the activity is created.

I have picked the solution N° 2 :sign0156:

I removed If First time condition
Thanks Erel
 

cengolo

Member
Licensed User
Longtime User
problem with httputils

a newbie here.
i tried to run the httputils example. download the file and when i trid to compile, i get the error (in httputils module i think)

Compiling code. Error
Error parsing program.
Error description: Sub is not a valid identifier.

any help will be much appreciated.

cenk
 

pluton

Active Member
Licensed User
Longtime User

I just download it to test it and it is working fine.
Compile OK and started in emulator.
Here is screenshot:

 

kormos

Member
Licensed User
Longtime User
I would like to have some help about this library. I am an ASP.NET programmer and I have made a web service. I try to use it through basic4android but for some reason I can not make it work. I would like to have some help if it is possible. I want to call a web method using the following parameters:

Web Service URL : http://localhost:999/Contacts.asmx
Web Method : Contacts_Select
Parameter : ContactID

Can someone tell me how to access this web method using a POST request from the web service and store the output of the web method in a string variable.

Thanks in advance.
 

peacemaker

Expert
Licensed User
Longtime User
Erel,

I guess, it's useful, if to make so:

 

peacemaker

Expert
Licensed User
Longtime User
I see, but:
1) I found that if a notebook with B4A and a running emulator has been hibernated, and later got working again - the emulator has not an internet connection (until restart, maybe another way to restore ?).
And the HTTPUtils service returns "Error. %URL%", but it's just into the log - parent sub that started HTTPUtils - knows nothing about this problem.
Such code addition helps to check each URL and inform the user about it.


2) Second question: sometimes there is a situation when "Already working. Request ignored (%req_name%)" status does not stop at all. For example, if to start HTTPUtils again during XML parsing. It's not correct, yes, but i guess, better to have some finishing, sometime.
 

vukanilod

Member
Licensed User
Longtime User
Is it possible to use httputils to get data from mysql database?
I'm having troubles with ExecuteRemoteQuery because it is working asynchronously so I can't tell if data has been retrieved from my sql or not...

Tnx
 

netchicken

Active Member
Licensed User
Longtime User
I am not too sure what I am doing here, but here goes, I am trying to extract the two numbers (92) that come in this line of html code below using Erels example from the first post.

<span itemprop="ratingValue" id="all-critics-meter" class="meter certified numeric ">92</span>

So I made the class

class = "class=" & QUOTE & "meter certified numeric " & QUOTE & ">" 'find the code before the number

and a pattern
pattern = "[0-9][0-9]" 'get the next two numbers after the class code

But it gives an error on the next bit Cannot assign void value. that I suspect shows the pattern isn't matching in lblcode.Text = links.Add(m.Group(1))

(I know that if it loops it will overwrite the lblcode.Text entry but there is only 1 entry in the code with that class.)

B4X:
 If line.IndexOf(class) > -1 Then 'if the class exists
         Dim link As String
         Dim m As Matcher
         m = Regex.Matcher(pattern, line)
         If m.Find Then
         '   links.Add(m.Group(1)) 'add the image link
         lblcode.Text = links.Add(m.Group(1))
         End If

How does it know that the next 2 fields after the class hold the pattern data? It seemed to know that in the example.

Is there a simpler way to extract out the data from between the tags?
<span itemprop="ratingValue" id="all-critics-meter" class="meter certified numeric ">??</span>

Eventually I will need to extract a block of text of indeterminate length from the code that is between

<p id="movieSynopsis" class="movie_synopsis" itemprop="description"> ???? </span>

There must be a simpler way to do it

Thanks for your ideas
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…