Bueno, el webservices que quiere consumir tiene una pecualidad, y son 2;
1.- Importante, es tener en la cabecera
( "Connection:", "Keep-Alive" ) , de lo contrario, cuando establecemos conexi贸n , esta es cerrada, dando un bonito valor nulo de respuesta.
2.- En la SOAPAction , hay que poner la URL entera, de lo contrario, el webservices devolver谩 que no existe la acci贸n.
3.- usar soapUI, nos permite averiguar estos matices
Version MSXML2
function amigo_eduardo()
Local cXml := strtran( memoread("EnvioCFE.xml"), hb_osnewline(), "" )
Local cLocation := "http://190.64.89.202/SICFEServicesDINAPOLI/sicfe.svc"
Local oHttp
oHttp := CreateObject( "MSXML2.XMLHTTP" )
oHttp:Open( "POST", cLocation, .F. )
ohttp:SetRequestHeader("Content-Type" ,"text/xml;charset=UTF-8" )
ohttp:SetRequestHeader( "SOAPAction" , "http://tempuri.org/ISICFEEmisor/EnvioCFE" )
oHttp:SetRequestHeader( "Connection:", "Keep-Alive" )
oHttp:SetRequestHeader( "Content-length: ", Str( len( cXml ) ) )
oHttp:Send( cXml )
Alert( oHttp:responseText )
return nil
Version con CURL
Nota:
Enlaza estas librerias para CURL en tu makefile.
#SOPORTE PARA CURL
hbcurls.lib
libcurl.lib
#include "hbcurl.ch"
#include "common.ch"
#include "fileio.ch"
function amigo_eduardo_curl( )
local endpointUrl,curlHandle,curlErr
local aHeader,chpmserv,cc1
Local strXml := strtran( memoread("EnvioCFE.xml"), hb_osnewline(), "" )
Local cLocation := "http://190.64.89.202/SICFEServicesDINAPOLI/sicfe.svc"
cc1 := ""
caction := "EnvioCFE"
endpointUrl := cLocation
aHeader := {}
AADD(aHeader,"Content-Type: text/xml;charset=UTF-8")
AADD(aHeader,"SOAPAction: "+ cAction )
AADD(aHeader,"Connection: Keep-Alive" )
AADD(aHeader,"Content-length: "+ Str( len( strXml )) )
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, strxml)
/* Do everything */
curlErr := curl_easy_perform( curlHandle )
/* Report any errors */
if empty(curlErr)
/* store response in variable */
cc1 := curl_easy_dl_buff_get( curlHandle )
Alert( "ATENCION:" + strtran( htmltoansi( cc1 ), """, '"' ) )
else
Alert( "Error:" + curl_easy_strerror(curlErr) )
endif
else
Alert( "No handle" )
endif
if !empty(curlHandle)
/* Clean-up libcurl */
curl_global_cleanup( curlHandle )
else
Alert( "Error" )
endif
if empty(cc1)
Alert( "Error" )
endif
return cc1