Android Question HttpUtils2 / XMLRPC

Discussion in 'Android Questions' started by MarcoRome, Jul 17, 2015.

  1. MarcoRome

    MarcoRome Expert Licensed User

    Hi all. I try traslate this code in pyton:

    Code:
    DEV_KEY = 'RwYtcwQz85DUpn6FPQCU7ImB2MBM8Dfl'

    s1 = 
    Server('http://muovi.roma.it/ws/xml/autenticazione/1')
    s2 = Server('http://muovi.roma.it/ws/xml/paline/7')

    token = s1.autenticazione.Accedi(DEV_KEY, 
    '')

    res = s2.paline.Previsioni(token, 
    '70101', 'it')
    pprint(res)
    i have in main this code:

    Code:
    Dim bus As busromaclass
    bus.Initialize(
    "RwYtcwQz85DUpn6FPQCU7ImB2MBM8Dfl")
    and in my class busromaclass i have this code:

    Code:
    Public Sub Initialize(password As String)
         
    Dim job1 As HttpJob
        job1.Initialize(
    "MyJob", Me)
        job1.Download(
    "http://muovi.roma.it/ws/xml/autenticazione/1")
        job1.GetRequest.SetHeader(
    "autenticazione.Accedi"Array As String(password, ""))
        job1.GetRequest.SetHeader(
    "Content-Type""application/json")
        job1.GetRequest.SetContentEncoding(
    "text/plain")

    End Sub

    Private Sub JobDone(job As HttpJob)

        
    If job.Success Then
            
    Dim res As String
            res = job.GetString
            
    Log("Response from server: " & res)
        
    Else
            
    ToastMessageShow("Error: " & job.ErrorMessage, True)
        
    End If
        job.Release
    End Sub
    No errors, Sub Initialize work without problem but finish there.
    He does not come in JobDone.
    ( In attachment source )
    Any idea ?
    Thank you all
    Marco
     

    Attached Files:

    Last edited: Jul 17, 2015
    ArminKH likes this.
  2. ArminKH

    ArminKH Well-Known Member

    jobdone raised for me without any error and all things are perfect
    what u mean?
    upload_2015-7-19_0-10-14.png
     
    MarcoRome likes this.
  3. MarcoRome

    MarcoRome Expert Licensed User

    already... i dont know for now. But i think that i wrong. I hope that one master response. I continue to study for solution
     
    ArminKH likes this.
  4. ArminKH

    ArminKH Well-Known Member

    maybe you need to update your libraries
    upload_2015-7-19_0-13-28.png
     
  5. MarcoRome

    MarcoRome Expert Licensed User

    okHttp 1.00 --> V1.00 - Adds support for digest authentication.
    I dont think that is this
     
    ArminKH likes this.
  6. Erel

    Erel Administrator Staff Member Licensed User

    See this warning:

    [​IMG]
     
  7. MarcoRome

    MarcoRome Expert Licensed User

    Thank you Erel for your response.
    Yes i see already, but i dont see another way.
    I will like understand as this code can traslate in B4A.
     
  8. DonManfred

    DonManfred Expert Licensed User

    You you have any developer-documentation about their protocol? In english?
    I dont know python
     
  9. MarcoRome

    MarcoRome Expert Licensed User

    Hi dear DonMandred dont exist in english. But i traslate for you.


    Code:
    Python
    The following example shows how 
    to authenticate with the API Getting around Rome (you must have a key developer), and invoke a method. You can simply paste the code below into a Python shell, after the necessary amendments to variable DEV_KEY.
    try:
      # 
    2 Python import
      from xmlrpclib import 
    Server
    except ImportError:
      # 
    3 Python import
      from xmlrpc.client import 
    Server

    from pprint import pprint

    DEV_KEY = 
    'Insert your key'

    s1 = 
    Server ('http://muovi.roma.it/ws/xml/autenticazione/1')
    s2 = Server ('http://muovi.roma.it/ws/xml/paline/7')

    token = s1.autenticazione.Accedi (DEV_KEY, 
    '')

    res = s2.paline.Previsioni (token, 
    '70101', 'en')
    pprint (res)

    Other languages
    The use of the API 
    in other languages is similar to the case of Python. You need to download a library XML-RPC for its language and to study the documentation.
    Developers are invited 
    to share code samples in different programming languages.
    The Key is: RwYtcwQz85DUpn6FPQCU7ImB2MBM8Dfl

    Now i'm already try with THIS LIBRARY and work only if you have 1 parameter:

    Code:
    Sub Globals
        
    'These global variables will be redeclared each time the activity is created.
        'These variables can only be accessed from this module.
        Dim XMLRPC1 As XMLRPC
        
    Dim XMLRPC2 As XMLRPC

    End Sub

    Sub Activity_Create(FirstTime As Boolean)
        
    If FirstTime Then
            XMLRPC1.Initialize(
    "XMLRPC1")
            XMLRPC2.Initialize(
    "XMLRPC2")
        
    End If
    'Get Token
    XMLRPC1.initXMLRPCClient("http://muovi.roma.it/ws/xml/autenticazione/1")
    Dim vedi As String = XMLRPC1.objectCall2("autenticazione.Accedi","QCOT7MBQwaC8dQI3BcVEC58kTCeriOOi","")
    Log(vedi) '<---- Return Token

    'Get Palina Value
    XMLRPC2.initXMLRPCClient("http://muovi.roma.it/ws/xml/paline/7")
    Dim previsioni As Object  = XMLRPC2.objectCall3("paline.Previsioni",vedi,70101,"")
    Log(previsioni) ' i wait that here return value
    The first result is ok (XMLRPC1 ), come back token without problem.
    The second result (XMLRPC2 ) dont work
    in Log Previsioni i have this result:
    {id_richiesta=11d4dc1182cc01abde46f3a23c362914, risposta={primi_per_palina=[Ljava.lang.Object;@41b52ac0, arrivi=[Ljava.lang.Object;@41b50fd0, nome=LGT GIANICOLENSE/REGINA COELI, collocazione=LTV GIANICOLENSE, 70 M. PRIMA SBOCCO PONTE MAZZINI}}

    in another cases Erel response that is possible connect with web service with Http Library
    example HERE

    But i dont undestand ....
     
Loading...