Android Question How to read a local server web page

Alberto Michelis

Well-Known Member
Licensed User
Longtime User
How to read a local server web page
(using B4A Version 4 beta 1) registered version

if I use a port...

URL = "http://192.168.1.104:88/xmloc?F=Sxml&S=L&M=PES&Z=1"

Java Error:
java.lang.IllegalArgumentException: Illegal character in scheme at index 0: 192.168.1.104:88/xmloc?F=Sxml&S=L&M=PES&Z=1

or
URL = "192.168.1.104:88/xmloc?F=Sxml&S=L&M=PES&Z=1"

Java Error:
java.lang.IllegalArgumentException: Illegal character in scheme at index 0: 192.168.1.104:88/xmloc?F=Sxml&S=L&M=PES&Z=1

Using no port:

URL = "http://192.168.1.104/xmloc?F=Sxml&S=L&M=PES&Z=1"
or
URL = "192.168.1.104/xmloc?F=Sxml&S=L&M=PES&Z=1"

The JobDone gives the following error:

Job.ErrorMessage=
java.lang.IllegalStateException: Target host must not be null, or set in parameters. scheme=null, host=null, path=192.168.1.104/xmloc

If I use an external IP like

URL = "http://200.68.94.242/xoc?F=A&T=ERAR&M=PES"

all is ok

Thanks
 

Alberto Michelis

Well-Known Member
Licensed User
Longtime User
If you use URL = "http://192.168.1.102/xmloc?F=Sxml&S=L&M=PES&Z=1" the job error is "not found"

If you use URL = "192.168.1.102/xmloc?F=Sxml&S=L&M=PES&Z=1" the job error iis
"java.lang.IllegalStateException: Target host must not be null, or set in parameters. scheme=null, host=null, path=192.168.1.102/xmloc"


Sub Globals
Dim ListView1 As ListView
Dim Title, Link, pubDate As String
Dim URL As String
URL = "192.168.1.102/xmloc?F=Sxml&S=L&M=PES&Z=1"
'URL = "http://200.68.94.242/xmloc?F=Sxml&S=L&M=PES&Z=1&ES=APBR,ERAR" '<<<<<<<<this is an external server and it works ok
End Sub

Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
parser.Initialize
End If
ListView1.Initialize("ListView1")
Activity.AddView(ListView1, 0, 0, 100%x, 100%y)
ListView1.SingleLineLayout.ItemHeight = 60dip
HttpJob1.Initialize("InsertNew1", Me)
HttpJob1.download(URL)
End Sub

Sub JobDone(Job As HttpJob)
Log("***JObDone")
If Job.Success = True Then
Log("lectura web OK")
Log(Job.GetString)
parser.Parse(Job.GetInputStream, "Parser")
Else
Log("error")
Log(Job.ErrorMessage) '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<from here comes the error message
End If

End Sub
 
Upvote 0

Alberto Michelis

Well-Known Member
Licensed User
Longtime User
Even from the same PC that hots the server or the smartphone theres no problem at all.
IE and Firefox works ok. If you type http:// leading the IP both explorers delete it and reads from the clean IP.

Another problem is that you cannot read from a port. If I use:

URL = "192.168.1.102:88/xmloc?F=Sxml&S=L&M=PES&Z=1"
See the :88 port

I get a java exception.
java.lang.IllegalArgumentException: Illegal character in scheme at index 0: 192.168.1.102:88/xmloc?F=Sxml&S=L&M=PES&Z=1

It is very important the ability to read from a port other than 80.

Thanks
 
Upvote 0

fixit30

Active Member
Licensed User
Longtime User
Ok, so if you modify your code to:

B4X:
Sub Globals
     Dim ListView1 As ListView
     Dim Title, Link, pubDate As String
     Dim URL As String
     URL = "http://192.168.1.102:88/xmloc?F=Sxml&S=L&M=PES&Z=1"
End Sub

Sub Activity_Create(FirstTime As Boolean)
     If FirstTime Then
          parser.Initialize
     End If
     ListView1.Initialize("ListView1")
     Activity.AddView(ListView1, 0, 0, 100%x, 100%y)
     ListView1.SingleLineLayout.ItemHeight = 60dip
     HttpJob1.Initialize("InsertNew1", Me)
     HttpJob1.download(URL)
End Sub


What happens?
 
Upvote 0

Alberto Michelis

Well-Known Member
Licensed User
Longtime User
THis is the code I'm using and what happens is what I post in my lasts replys

I get a java exception.
java.lang.IllegalArgumentException: Illegal character in scheme at index 0: 192.168.1.102:88/xmloc?F=Sxml&S=L&M=PES&Z=1
 
Upvote 0

Alberto Michelis

Well-Known Member
Licensed User
Longtime User
Ok, give up, if you where reading my post may be you react in another way.
I dont want to bother you so... give up.

I AM USING HTTP://
I AM USING HTTP://
I AM USING HTTP://

With or without it I got erros.
Thanks for nothig!
 
Upvote 0

barx

Well-Known Member
Licensed User
Longtime User
have you tried starting with just

"http://ipaddress:port" to see if that gets any errors

At least it will narrow down if the querystring is the issue
 
Upvote 0
Top