Web Services

Web Services

Postby reinaldocrespo » Fri Sep 14, 2012 6:32 pm

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.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: Web Services

Postby reinaldocrespo » Tue Sep 25, 2012 4:36 pm

Is anyone consuming webservices using SOAP from harbour/xharbour?


Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: Web Services

Postby devtuxtla » Tue Sep 25, 2012 8:59 pm

Hello Reinaldo

what is your personal email to send you an example that you can serve.

regards
Visite Chiapas, el paraiso de México.
devtuxtla
 
Posts: 392
Joined: Tue Jul 29, 2008 1:55 pm

Re: Web Services

Postby reinaldocrespo » Tue Sep 25, 2012 9:01 pm

reinaldo dot crespo
at gmail.com

and thank you very much.


Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: Web Services

Postby Antonio Linares » Wed Sep 26, 2012 6:13 am

devtuxtla wrote:Hello Reinaldo

what is your personal email to send you an example that you can serve.

regards


Please copy it here for other users, thanks :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42089
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Web Services

Postby devtuxtla » Wed Sep 26, 2012 6:15 pm

Hello Antonio and all

You're right

Here is the code I use
Code: Select all  Expand view

*--------------------------------------------------------------------------------------------*
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

 
Visite Chiapas, el paraiso de México.
devtuxtla
 
Posts: 392
Joined: Tue Jul 29, 2008 1:55 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 93 guests