solucionado bug del mod -> Carles Aubia

mod_harbour es un módulo para Apache que permite correr tus PRGs directamente en la web!!!

solucionado bug del mod -> Carles Aubia

Postby wilsongamboa » Wed Nov 10, 2021 5:14 pm

Buenas tardes con todos
Gracias a la inestimable labor de nuestro GURU Charly se ha solucionado un bug en el Mod_Harbour con respecto al uso de CURL al llamar a un WebService Gracias Charly!!
Cabe mencionar que la falla se da cuando
- el Web Services esta programado en Mod_Harbour
- el programa que hace la consulta al web services esta tambien hecho en mod_harbour
alli se produce el error
Pero si el programa que hace la consulta es otro ( que no este escrito en harbour ni en mod_harbour ) si funciona y muy bien
ahora ya funciona perfecto !! porque los parametros no los recibia!!
esto ya funciona Ok
Code: Select all  Expand view
#include "{% hb_getenv('PRGPATH') + '/hbcurl.ch' %}"

function Main()
   
    local h := UseWebService()
   
    AP_SetContentType( "application/json" )
   
    ?? hb_jsonEncode(h)

retu nil

function UseWebService()

    local uValue, hCurl
    local cUrlWs        := '190.110.XXX.YYY:6263/pre/jnetws/auth'
    local hHeaders  := { 'Content-Type: application/json' }  
    local hParams       := {=>}
    local h             := {=>}
    local n


    hParams[ 'wsuser' ]     := 'app1'
    hParams[ 'wspsw' ]  := 'acvbs'
    hParams[ 'user' ]       := 'demo'
    hParams[ 'psw' ]        := '1129'
    hParams[ 'emp' ]        := 'Empre003'

    curl_global_init()

    if ! empty( hCurl := curl_easy_init() )

        curl_easy_setopt( hCurl, HB_CURLOPT_SSL_VERIFYPEER, 0)             
        curl_easy_setopt( hCurl, HB_CURLOPT_URL, cUrlWs )
        curl_easy_setopt( hCurl, HB_CURLOPT_HTTPHEADER, hHeaders )
        curl_easy_setopt( hCurl, HB_CURLOPT_POST, 1 )   
        curl_easy_setopt( hCurl, HB_CURLOPT_POSTFIELDS, hb_jsonEncode( hParams ) )

        curl_easy_setopt( hCurl, HB_CURLOPT_DL_BUFF_SETUP )        
       
        n := curl_easy_perform( hCurl )
       
        if n == 0
       
            uValue  := curl_easy_dl_buff_get( hCurl )          
            h       := hb_jsonDecode( uvalue )
           
        else
            h[ 'error' ] := curl_easy_strerror( n )
        endif
    endif

    curl_global_cleanup()

return h
Wilson 'W' Gamboa A
Wilson.josenet@gmail.com
User avatar
wilsongamboa
 
Posts: 548
Joined: Wed Oct 19, 2005 6:41 pm
Location: Quito - Ecuador

Return to mod_harbour

Who is online

Users browsing this forum: No registered users and 1 guest