Android Question How to read a local server web page

Discussion in 'Android Questions' started by Alberto Michelis, May 23, 2015.

  1. Alberto Michelis

    Alberto Michelis Active Member Licensed 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
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    It should start with http://. Can you post the code that raises the "target host must not be null" error?
     
  3. Alberto Michelis

    Alberto Michelis Active Member Licensed 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
     
  4. fixit30

    fixit30 Active Member Licensed User

  5. Alberto Michelis

    Alberto Michelis Active Member Licensed 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
     
  6. fixit30

    fixit30 Active Member Licensed User

    AS Erel stated above, the URL MUST start with http://

    If you navigate to http://192.168.1.102:88/xmloc?F=Sxml&S=L&M=PES&Z=1 from the Mobile device browser does is succeed?

    If not, I suspect an issue with the server configuration or Firewall.

    I use non standard ports with HttpUtils2 all of the time so I know it is possible.
     
    DonManfred likes this.
  7. Alberto Michelis

    Alberto Michelis Active Member Licensed User

  8. fixit30

    fixit30 Active Member Licensed User

    Ok, so if you modify your code to:

    Code:
    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, 00100%x100%y)
         ListView1.SingleLineLayout.ItemHeight = 
    60dip
         HttpJob1.Initialize(
    "InsertNew1", Me)
         HttpJob1.download(URL)
    End Sub

    What happens?
     
  9. Alberto Michelis

    Alberto Michelis Active Member Licensed 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
     
  10. fixit30

    fixit30 Active Member Licensed User

    I give up! :rolleyes:

    For the last time....

    The URL must start with http://
     
  11. Alberto Michelis

    Alberto Michelis Active Member Licensed 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!
     
  12. barx

    barx Well-Known Member Licensed 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
     
  13. picenainformatica

    picenainformatica Active Member Licensed User

    Xmloc is a folder or a file?
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice