Hi.
Can someone post a sample on how to consume webservices from https using fwh? One of the methods I need to consume sends a file (SendX12File) and the other downloads a file (GetRoutedFiles). Help please?
Reinaldo.
devtuxtla wrote:Hello Reinaldo
what is your personal email to send you an example that you can serve.
regards
*--------------------------------------------------------------------------------------------*
FUNCTION ENVIO_SOAP(_XML, _TEST, cError)
*--------------------------------------------------------------------------------------------*
Local oHttp, cXmltemp:="c:\PREMIUM\"+ALLTRIM(RFC) + "\respuesta.xml", hXmlFile, hLibQrc
Local cLocation := "https://cfdiws.sedeb2b.com/-------/SXCP?wsdl" // AQUI DEBES TENER LA DIRECCION DEL WEBSERVER
Local cUser := "usario:password"
Local cAuthorization := hb_base64( cUser, Len( cUser ) ) // AQUI UTILIZO LA CONVERSION DEL USUARIO A BASE64, TALVEZ NO LO REQUIERAS
Local RETCOM:=.F.
LOCAL cUserdir:="c:\PREMIUM\"+ALLTRIM(RFC) + "\"
DEFAULT _TEST:=.T.
PRIVATE cXmlDef:="este es el contenido a enviar al Webserver"
cXml := S_LOGIN_TEST(cXmlDef)
FOR _X_ = 1 TO 3
TRY
oHttp := CreateObject( "MSXML2.XMLHTTP" )
//getCfdiTest(String user, String password, byte[] file
//oHttp:Open( "POST", cLocation, .F. )
//oHttp:SetRequestHeader( "Content-Type", "application/soap+xml" )
oHttp:Open( "POST", cLocation, .F. )
//oHttp:SetRequestHeader( "Content-Type", "application/soap+xml" )
ohttp:setrequestheader("soapaction","getTest") // AQUI LA ACCCION QUE DEBE RESPONDER EL WEBSERVER
oHttp:Send( cXml )
Respuesta:= oHttp:responseText
Respuesta:=S_ONVERT(Respuesta) // convertir la respuesta (opcional)
//debe dejar huella de la respuesta
hXmlFile := FCreate( cXmltemp )
FWrite(hXmlFile, Respuesta )
FClose( hXmlFile )
CATCH oErr
IF _X_ = 3
MSGINFO("C100 NO PUDE comunicarme con el Webserver, vuelva a intentarlo","Error...")
MSGALERT(PR_ErrorMessage( oErr ),"Alerta...") // majejo del error (opcional)
ELSE
MSGWAIT("Por Favor Espere... Comunicandome con el Webserver " + STR(_X_) ,"Intentando ",10)
LOOP
ENDIF
END TRY
IF EMPTY(oHttp)
IF _X_ = 3
MSGINFO("C101 NO pude conectarme al server " + CRLF + "Error","Error...")
RETCOM:=.T.
ELSE
LOOP
ENDIF
ELSE
EXIT
RETCOM:=.F.
ENDIF
NEXT
IF RETCOM = .T.
RETURN .T.
ENDIF
RETURN RET
*--------------------------------------------------------------------------------------------*
FUNCTION S_LOGIN_TEST(cXmlDef)
*--------------------------------------------------------------------------------------------*
LOCAL cSoapT:="", hXmlFile,cXmltemp:="c:\temp\saop.xml"
cSoapT+='<?xml version="1.0" encoding="UTF-8"?>' + CHR(10)
cSoapT+='<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cfdi="http://service.thatpage.webserver.com"> ' + CHR(10)
cSoapT+='<soapenv:Header />' + CHR(10)
cSoapT+='<soapenv:Body>' + CHR(10)
cSoapT+='<cfdi:getTest>' + CHR(10) // funcion a ejecutar
cSoapT+='<cfdi:user>XXXXXXXXX</cfdi:user>' + CHR(10)
cSoapT+='<cfdi:password>YYYYYYYY</cfdi:password>' + CHR(10)
cSoapT+='<cfdi:file>'+cXmlDef
cSoapT+='</cfdi:file>' + CHR(10)
cSoapT+='</cfdi:getTest>' + CHR(10)
cSoapT+='</soapenv:Body>' + CHR(10)
cSoapT+='</soapenv:Envelope>' + CHR(10)
hXmlFile := FCreate( cXmltemp )
FWrite(hXmlFile, cSoapT )
FClose( hXmlFile )
RETURN cSoapT
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 83 guests