httpios vs leg vxmldialog

Version 1
    This document was generated from CDN thread

    Created by: Lisandro Quinteros on 22-05-2013 11:31:05 AM
    Hi, still working with the Public Holiday date script  (http://developer.cisco.com/web/vgapi/forums/-/message_boards/message/14328210) I have now need to install that script on 300 gateways so I must load it from http and load variables from a web otherwhise I would have to reload 300 script every time a public holiday date change. The script just need to read the date when the call is made and send it to a web site and this website checks if it's a working day or not (it has an array inside the website).. and just return a 0 or a 1.. and then the script just play differents prompt for working or non-workingday.   I have been reading several post and programming guide and I coudn't figure out which is the difference between making.. ex. ::httpios::geturl $URL -command or leg vxmldialog   for my pourpose is the same? Server side script is the same for any of this options ?   Thanks..        

    Subject: RE: httpios vs leg vxmldialog
    Replied by: Yaw-Ming Chen on 22-05-2013 12:34:58 PM
    Are you using VXML ? I think for you ::httpios::geturl is right one to use

    Subject: RE: httpios vs leg vxmldialog
    Replied by: Lisandro Quinteros on 22-05-2013 01:30:02 PM
    Thanks ill try now... Another question..I already have 2 AA tcl. one for  for non-working day .. and the second one tcl its for working days and it has 2 levels aa (one prompt.. collect digit.. a second promp with collect digit again)...
    Could I try to make a third tcl ... that check if its working day or not.. 
    if not... use handoff to call first tcl script
    if not... use handoff to call the second tcl script
    Becouse I discover handoff while reading programming guide and seems to be good for me.
    thanks.

    Subject: RE: httpios vs leg vxmldialog
    Replied by: Yaw-Ming Chen on 22-05-2013 02:47:17 PM
    Yes you can use handoff but why you need to separate working and non-working day into two scripts ?

    Subject: RE: httpios vs leg vxmldialog
    Replied by: Lisandro Quinteros on 22-05-2013 07:54:10 PM
    Good question, I'll put them both in same tcl..
    If I want to receive a 1 or a 0 from server side script...
    I will got it with: set res [http::data $token]  ??
    under the Request Result ?
    Thanks.. 

    Subject: RE: httpios vs leg vxmldialog
    Replied by: Yaw-Ming Chen on 22-05-2013 08:16:50 PM
    That's the idea.

    Subject: RE: httpios vs leg vxmldialog
    Replied by: Lisandro Quinteros on 23-05-2013 01:05:12 PM
    Just loaded like web...
    sh call app voice sum
    web                       Tcl Script      http://10.16.4.43/lisa/html.tcl
     
    dial-peer voice 100 pots
     description *** PSTN Dial Peer ***
     service web
      incoming called-number .
     port 0/1/0
    !
     
    loading the app..
     
    *May 23 18:11:04.751: //-1//HIFS:/hifs_http_cb: hifs http read succeeded. size=1467, url=http://10.16.4.43/lisa/html.tcl
    *May 23 18:11:04.751: //-1//HIFS:/hifs_http_cb: hifs ifs file read succeeded. size=1467, url=http://10.16.4.43/lisa/html.tcl
    *May 23 18:11:04.751: //-1//HIFS:/hifs_free_idata: hifs_free_idata: 0x48509054
    *May 23 18:11:04.751: //-1//HIFS:/hifs_hold_idata: hifs_hold_idata: 0x48509054
    *May 23 18:11:04.763: //-1//TCL :EE472F7CF4000:/tcl_PutsObjCmd: its in
    *May 23 18:11:04.763: 
    .................................
    Thanks

    Subject: RE: httpios vs leg vxmldialog
    Replied by: Lisandro Quinteros on 23-05-2013 12:44:40 PM
    After looking in diferrent post and mixing codes I got this:
     
    When I load the application it read it success, but when I make a call got: %CALL_CONTROL-6-APP_NOT_FOUND: Application html4 in dial-peer 100 not found.  Handing callid 31 to the alternate app .
    I check name of service on dial peer its ok.
     
    proc init { } {
     
     
     
         #global token
     
        
     
         set event [infotag get evt_event]
     
        puts "entro"
     
        
     
    }
     
     
    proc act_GetHTTP { } {
     
    global hoy
    set hoy "25052013"
     
       #httpios::config -accept "text/plain"
     
        set url "http://10.16.4.43/lisa/test.php?fecha=$hoy"
     
        puts "Before httpios::geturl"   
     
        httpios::geturl "$url" -command act_RequestResult -timeout 1
     
        puts "After httpios::geturl"
     
     
     
     
     
    }
     
     
     
     
     
    proc act_RequestResult {token} {
     
    global res
    global WebReturn1
        #global token  
     
     if {[::httpios::status $token] == "ok"} {
          set WebReturn1 [string trim [::httpios::data $token]]
       } else {
          set WebReturn1 0
          set res 0 
          
       }
     
        set res [http::data $token]
     
       
     
        puts "Capture Result: $res"
        puts "Capture Result: $WebReturn1"
     
    }
     
     
     
    proc act_Cleanup { } {
     
     
     
        set evt_name [infotag get evt_event]
     
        call close
     
    }
     
     
     
    package require httpios 1.0
     
     
     
    init
     
    #----------------------------------
     
    #   State Machine
     
    #----------------------------------
     
    set TopFSM(any_state,ev_disconnected)         "act_Cleanup, same_state"
     
    set TopFSM(any_state,ev_destroy_done)         "act_Cleanup, same_state"
     
    set TopFSM(CALL_INIT,ev_setup_indication)    "act_GetHTTP, same_state"
     
    set TopFSM(any_state,ev_any_event) "act_LogState, same_state"
     
    fsm define TopFSM CALL_INIT
     
    -------------------------------------------------

    Subject: RE: httpios vs leg vxmldialog
    Replied by: Yaw-Ming Chen on 23-05-2013 12:53:34 PM
    do "sh call app voice sum" see if you see your application "html4"

    Subject: RE: httpios vs leg vxmldialog
    Replied by: Yaw-Ming Chen on 23-05-2013 01:23:53 PM
    You have application "web" why here said html4 not found ?
    got: %CALL_CONTROL-6-APP_NOT_FOUND: Application html4 in dial-peer 100 not found.  Handing callid 31 to the alternate app .

    Do it again enable deb voip app tcl and deb voip app scr.
    "call appl voice load web" then amke a call
    and show what you have  incluing dial-peer
    Thanks !
     
     
     

    Subject: RE: httpios vs leg vxmldialog
    Replied by: Lisandro Quinteros on 23-05-2013 02:34:20 PM
    Thanks Yaw that was becouse I reaload it again with other name..
    The error now is..: %CALL_CONTROL-6-APP_NOT_FOUND: Application web in dial-peer 100 not found.  Handing callid 45 to the alternate app .

    With debug I got the error what really my fault
    I forgot to put # on the last line of the code.....   IT was " -------------------------------------------------" without # 
    Seems its working and getting the response of web server...
    If want to handoff this call and let the other tcl to take it.. the other tcl called ex. aa.tcl
    handoff appl leg_incoming AA -s “I send you result=$res”
    Did I need to connect/proccess any leg before handoff couse I don't have any leg I guess..
    Or I could send it as it is now ? When the other app recevied the call it has to connect the leg or it received already connected? when I handoff and status of hand is off should I disconnect the call from first TCL ?
    Maybe I should open a new post for handoff
     

    Subject: RE: httpios vs leg vxmldialog
    Replied by: Yaw-Ming Chen on 23-05-2013 02:47:17 PM
    It's getting complicate. You may want to consider oper  a SR with CDN support.
    http://developer.cisco.com/web/join-the-network/support-only

    One of the good moment to do handoff is when you recieve call setup doen event
    You can do " call close" as soons as you do handoff appl leg_incoming AA -s “I send you result=$res”
     

    Subject: RE: httpios vs leg vxmldialog
    Replied by: Lisandro Quinteros on 24-05-2013 10:01:23 AM
    First time I heard about SR with CND support.. It's a good alternative...
     
    I got a little issue now..I get server reponse like this:
    set resp [::httpios::data $token]
    When transaction its ok I get a 0 or a 1..
    But when for example conection to server fail (I intencionally delete server side file to test)..
    I got nothing on Resp variable.. when I did puts $resp Just got a blank space..
    How could I make to take an accion when that happend.. Is there a way to now resoponse fail ? or to check if (resp == null ) or something like that?
    Becouse when I delete the server side script the 
    set status [::httpios::status $token]  Still got an "ok" as response..
    thanks

    Subject: RE: httpios vs leg vxmldialog
    Replied by: Yaw-Ming Chen on 24-05-2013 10:42:29 AM
    When we use "httpios::geturl" we are deal with standard tcl http built in package so it will be pretty the same as we deal with http::geturl, http::data... etc. You should refer to standard Tcl manual to see usually how we handle this. But from your descption I will check if ($resp == "")
    thanks

    Subject: RE: httpios vs leg vxmldialog
    Replied by: Lisandro Quinteros on 24-05-2013 11:15:33 AM
    Thanks again Yaw-Ming .. I am a starter tcl developer and your work here make it easier...I have been reading a few Cisco CME scripts you modified and learning to use handoff from there.. 
    Thanks for your help as always..
     

    Subject: RE: httpios vs leg vxmldialog
    Replied by: Lisandro Quinteros on 24-05-2013 12:44:39 PM
    Lost again..
    I thought when I make 
    httpios::geturl "$url" -command act_RequestResult 
    Then ResquestResult do all defined inside that procedure and after finishing It return to the next line after httpios::geturl "$url" -command act_RequestResult...
    But Its seems proc act_GetHTTP { } {  continue working while act_RequestResult its running..
    Is there a way to stop act_GetHTTP while the server request its running.. ??
    Thanks
     
     

    Subject: RE: httpios vs leg vxmldialog
    Replied by: Lisandro Quinteros on 24-05-2013 01:21:40 PM
    Forgot to put why I ask that...
    It run the command httpios::geturl "$url" -command act_RequestResult   
    And automatically try to make the next line which is the handoff...
    It don't give time to act_RequestResult  to ask the webserver and return and save the returning value to $resp variable..
     
    The error:
     
    /6//AFW_:/AFW_FSM_Drive: Tcl_Eval to drive FSM inside Tcl modulespace. code=1 code=ERROR
    *May 24 18:21:59.711: TCL script failure 
            Result:
                             can't read "resp": no such variable
    *May 24 18:21:59.711:   TCL script failure errorInfo:
                            can't read "resp": no such variable
        while executing
    "handoff appl leg_incoming preatendedor "$resp"
     
    and when I check It run the command httpios::geturl "$url" -command act_RequestResult   automatically 

    Subject: RE: httpios vs leg vxmldialog
    Replied by: Yaw-Ming Chen on 24-05-2013 01:28:13 PM
    You should initialize "resp". aslo check what you want to handoff before doing

    Subject: RE: httpios vs leg vxmldialog
    Replied by: Lisandro Quinteros on 24-05-2013 01:33:25 PM
    I got it initialized under act_RequestResult
    But It do the handoff before It goes to de server and got the response.
     
     
    proc act_GetHTTP { } {
     
    global hoy
    set hoy "25052013"
     
       #httpios::config -accept "text/plain"
     
        set url "http://10.16.4.96/lisa/test.php?hoy=26052013"
     
        puts "Before httpios::geturl"   
     
        httpios::geturl "$url" -command act_RequestResult -timeout 650
     
        puts "After httpios::geturl"
         leg setupack leg_incoming
        leg proceeding leg_incoming
        leg connect leg_incoming
        handoff appl leg_incoming preatendedor "$resp"
        
        }
     
     
     
    proc act_RequestResult {token} {
     
    global WebReturn1
    global status
    #global token
    global resp  
     
    set resp 0
    set status [::httpios::status $token]
    puts "Callback Status: $status"
    if {[::httpios::status $token] == "ok"} {
    set resp [::httpios::data $token]
    if { $resp == "" } {
       set resp 7
    puts "Sin Respuesta desde el Server:"
    puts "Respuesta:  $resp"
       } else {
    set WebReturn1 1
    puts "Conexion con Server:  $WebReturn1"
    puts "Respuesta:  $resp"
              }
    } else {
    puts "Error en Callback Status"
    puts "Error Callback Status: $status"
    puts "Sin Respuesta desde el Server:"
    puts "Conexion con Server:  $WebReturn1"
          set WebReturn1 0
          set resp 0 
    puts "Tomo como si no fuera feriado: $resp"
     
          
       }
     
    Thanks.. 
     

    Subject: RE: httpios vs leg vxmldialog
    Replied by: Yaw-Ming Chen on 24-05-2013 02:13:59 PM
    Init it when script got triggered.

    Subject: RE: httpios vs leg vxmldialog
    Replied by: Lisandro Quinteros on 24-05-2013 02:34:58 PM
    Same error.. the when I set another variable inf the handoff .. example 
    set flag 0
    handoff appl leg_incoming preatendedor "$flag"
    It works ok. And from puts I could see the lineal running of the code its..
    First COMPLETE ALL THIS STEPS::::::
       puts "Before httpios::geturl"    
        httpios::geturl "$url" -command act_RequestResult -timeout 650 
        puts "After httpios::geturl"
         leg setupack leg_incoming
        leg proceeding leg_incoming
        leg connect leg_incoming
        handoff appl leg_incoming preatendedor "$flag"
    AND WHEN ALL IS COMPLETE IT DO WHAT IS  in write under proc act_RequestResult {token} {
    So Why the tcl complete the whole  proc act_GetHTTP { } {         before  start running     proc act_RequestResult {token} {
    Thanks..

    Subject: RE: httpios vs leg vxmldialog
    Replied by: Yaw-Ming Chen on 24-05-2013 02:49:47 PM
    That why I said you need to refer standard manual
     
    If the -command option is specified, then the HTTP operation is done in the background. ::http::geturl returns immediately after generating the HTTP request and the callback is invoked when the transaction completes.
     
    http::wait is not supported in this IVR so what you can do is stop donig thing after http::geturl
    and put them in act_RequestResult

    Subject: RE: httpios vs leg vxmldialog
    Replied by: Lisandro Quinteros on 24-05-2013 02:59:07 PM
    I have read the standart manual 3 or 4 time the same -command explanation and just now understand the meaning..
    I also tried the http:wait httpios::wait and always received invalid command...You confirme that is not supported ... I have also tried to do handoff inside act_ResquestResult but it don't let me.. I'll try a while and let you know..
    Thanks..

    Subject: RE: httpios vs leg vxmldialog
    Replied by: Lisandro Quinteros on 24-05-2013 03:51:03 PM
    Si hablo español...
    Sldos

    Subject: RE: httpios vs leg vxmldialog
    Replied by: Yaw-Ming Chen on 24-05-2013 04:03:13 PM
    Que está disponible

    Subject: RE: httpios vs leg vxmldialog
    Replied by: Adolfo Arizpe on 24-05-2013 03:47:03 PM
    (hablas español?)

    Subject: RE: httpios vs leg vxmldialog
    Replied by: Adolfo Arizpe on 24-05-2013 03:52:38 PM
    Yaw-Ming Chen:
    That why I said you need to refer standard manual
     
    If the -command option is specified, then the HTTP operation is done in the background. ::http::geturl returns immediately after generating the HTTP request and the callback is invoked when the transaction completes.
     

    Is the -command option available for all IOS versions? IIRC, I couldn't make it work on my install which runs IOS v 12.4
     

    Subject: RE: httpios vs leg vxmldialog
    Replied by: Adolfo Arizpe on 24-05-2013 03:53:42 PM
    yo uso ese método y he batallado un poco con él.
    Si quieres podemos platicarlo en por IRC o algo. A lo mejor los dos nos beneficiamos de aprenderle bien.

    Subject: RE: httpios vs leg vxmldialog
    Replied by: Lisandro Quinteros on 27-05-2013 09:55:07 AM
    Its working for me now seems -command its mandatory but I could collect digit or play audio with no problem.
    I Could handoff correctly Just need to lean how to get the variables I send  with handoff. 
    Thanks
    Adolfo.
    Dime como quieres que nos contactemos así lo seguimos. 
     
    Muchas gracias.. 
    Sldos 

    Subject: RE: httpios vs leg vxmldialog
    Replied by: Adolfo Arizpe on 27-05-2013 03:14:44 PM
    en el canal de IRC #tclapi de freenode

    Subject: RE: httpios vs leg vxmldialog
    Replied by: Raghavendra Gutty Veeranagappa on 28-05-2013 12:36:17 AM
    Hi
    you can get handoff string as below example, for more information refer TCL IVR programming guide.
     
    set iid newapp
    set sid customer
    set anum 123456
    handoff appl leg_incoming $iid -s “Here is a call: service=$sid; account number=$anum”


    set handoffString [infotag get evt_handoff_string]
     
    Thanks,
    Raghavendra

    Subject: RE: httpios vs leg vxmldialog
    Replied by: Lisandro Quinteros on 28-05-2013 03:55:13 PM
    Thanks for the reply..
    I was trying with....
     
    set handoffString [infotag get evt_handoff_argstring]
    with no success..
    Thanks ill try it now..

    Subject: RE: httpios vs leg vxmldialog
    Replied by: Yaw-Ming Chen on 28-05-2013 04:11:41 PM
    use

    [infotag get evt_handoff_string]
    or
    [infotag get evt_handoff argstring]  <--- space not "_"

    Subject: RE: httpios vs leg vxmldialog
    Replied by: Lisandro Quinteros on 28-05-2013 10:15:03 PM
    It's programmers guido wrong? • The application instance that receives the call leg can retrieve the argument string by using the evt_handoff_argstring information tag.

    I was trying with "_"
    thanks for your help.

    Subject: RE: httpios vs leg vxmldialog
    Replied by: Yaw-Ming Chen on 28-05-2013 10:24:15 PM
    It's a typo in that part. 
    page 4-9 -- "evt_handoff argstring" has right info