FACTURA ELECTRONICA (PERU)

HMG en Español

Moderator: Rathinagiri

Post Reply
User avatar
edufloriv
Posts: 238
Joined: Thu Nov 08, 2012 3:42 am
DBs Used: DBF, MariaDB, MySQL, MSSQL, MariaDB
Location: PERU

FACTURA ELECTRONICA (PERU)

Post by edufloriv »

Hola amigos saludos,

Estoy tratando de interfacear con un proveedor de servicio electrónico que me ha dado esta dirección para enviar la info de la facturación:

http://190.117.192.69:8090/ws/ws/billService?wsdl

Me parece que es un servicio en local. El tema es que estoy tratando de usar este código que baje del foro:

Code: Select all

function send_soap

local cxml,canswer,nn1

cxml    := TxtBoleta()
canswer := fHttpExecute(cxml)
canswer := strtran(canswer,"><",">"+chr(10)+"<")
memowrit("soapanswer.txt",canswer)
msginfo('soap enviado.')

return .t.



function fHttpExecute(cxml)
local endpointUrl,curlHandle,curlErr
local aHeader,cc1

cc1 := ""

endpointUrl := "http://190.117.192.69:8090/ws/ws/billService?wsdl"  //<- aqui ya puse la url que me dió el proveedor

aHeader := {}
AADD(aHeader,"Accept-Encoding: gzip,deflate" )
AADD(aHeader,"Content-Type: text/xml;charset=UTF-8" )
AADD(aHeader,'SOAPAction: ""' )               // <- Como sé que debo poner aqui ? se lo pregunto también al proveedor ?
*AADD(aHeader,"User-Agent: Jakarta Commons-HttpClient/3.1"  )

curlHandle := curl_easy_init()

if !empty(curlHandle)

/* Specify the Header  data */
curl_easy_setopt(curlHandle,HB_CURLOPT_HTTPHEADER,aHeader)

/* Set the endpoint to send the POST to */
curl_easy_setopt(curlHandle, HB_CURLOPT_URL, endpointUrl)

/* Setup response data */
curl_easy_setopt( curlHandle, HB_CURLOPT_DOWNLOAD )
curl_easy_setopt( curlHandle, HB_CURLOPT_DL_BUFF_SETUP )

/* Specify the POST data */
curl_easy_setopt(curlHandle, HB_CURLOPT_POST, 1)
curl_easy_setopt(curlHandle, HB_CURLOPT_POSTFIELDS, cxml)

/* Do everything */
curlErr := curl_easy_perform(curlHandle)

/* Report any errors */
if empty(curlErr)
/* store response in variable */
cc1 := curl_easy_dl_buff_get( curlHandle )
else
? curl_easy_strerror(curlErr)
endif
else
? "No handle"
endif

if !empty(curlHandle)
/* Clean-up libcurl */
curl_global_cleanup( curlHandle )
else
? "Error"
endif

if empty(cc1)
? "Error"
endif

return cc1
Pero cuando compilo con HMG 3.4.4 me lanza este error :
error-compile.jpg
error-compile.jpg (290.56 KiB) Viewed 1850 times
Por favor es urgente, es primera vez que uso HTTP y SOAP, hasta ahora he estado trabajando con proveedores a los que les entrego la info en local, no he usado nunca SOAP y HTTP.

Agradeciendo de antemano su gentileza, reciban mis cordiales saludos.

Eduardo Flores Rivas


LIMA - PERU
edk
Posts: 911
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: FACTURA ELECTRONICA (PERU)

Post by edk »

Intenta compilar con el comando:

Code: Select all

build.bat your_prg.prg hbcurl.hbc
Este tema puede ser útil: http://hmgforum.com/viewtopic.php?f=5&t=5129#p49533
User avatar
edufloriv
Posts: 238
Joined: Thu Nov 08, 2012 3:42 am
DBs Used: DBF, MariaDB, MySQL, MSSQL, MariaDB
Location: PERU

Re: FACTURA ELECTRONICA (PERU)

Post by edufloriv »

Edk mil gracias amigo, compiló perfecto.

Una consulta esta línea:

Code: Select all

AADD(aHeader,'SOAPAction: ""' )
¿ Mi proveedor de servicio me tiene que decir cual es el "Action" que debo solicitar ?

Mil gracias por tu gentil tiempo
-------------------------------------------------------------------------------------------------------------------------

Edk thank you very much friend, compiled perfect.

A query this line:

Code: Select all

AADD (aHeader, 'SOAPAction: ""')
Does my service provider have to tell me what is the "Action" that I should request?

Thank you very much for your kind time

Eduardo Flores Rivas


LIMA - PERU
User avatar
apais
Posts: 440
Joined: Fri Aug 01, 2008 6:03 pm
DBs Used: DBF
Location: uruguay
Contact:

Re: FACTURA ELECTRONICA (PERU)

Post by apais »

Depende del proveedor del servicio (soap server).
Algunos lo requieren y otros no.

HTH
Angel
Angel Pais
Web Apps consultant/architect/developer.
edk
Posts: 911
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: FACTURA ELECTRONICA (PERU)

Post by edk »

edufloriv wrote: Wed May 22, 2019 11:00 pm A query this line:

Code: Select all

AADD (aHeader, 'SOAPAction: ""')
Does my service provider have to tell me what is the "Action" that I should request?

Thank you very much for your kind time
Para ayudarte, necesito recibir WSDL para este servicio. Intenté conectarse al servicio, pero probablemente se rechace mi IP y no puedo descargar WSDL.
Post Reply