FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour TIPCLIENTHTTP problem ( new )
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
TIPCLIENTHTTP problem ( new )
Posted: Wed Oct 30, 2019 07:18 PM
For many years I have used the following call:
Local oHttp:=TIpClientHttp():new("https://xxx.xxx.com/1", .F. )

Now that I am using the newest Harbour libraries, and the latest FWH ( 19.09 ), I get the following messages when making this call:

. Error description: Error BASE/1081 Operation not supported: TIPCLIENTHTTP:new()
Args:
[ 1] = O TIPCLIENTHTTP
[ 2] = C https

Stack Calls
===========
Called from: client.prg => TIPCLIENT:NEW( 225 )
Called from: httpcli.prg => TIPCLIENTHTTP:NEW( 96 )


Opening the object is followed by creating an XML document, and then:

oHttp:open()
oHttp:Post( cXml)
cRet := oHttp:readAll( )
oHttp:close()


Looking this up on the Forum yielded a post showing that the harbour library has been "problematic" and unfixed for a long time. Is there a suggested "better way" to make this call ? I use the procedure to obtain data from a web server.

Samples of how to implement the better way would be appreciated.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: TIPCLIENTHTTP problem ( new )
Posted: Wed Oct 30, 2019 08:20 PM
Excuse me, I don't understand your goal well
If your goal is to obtain data from a website, what do you send in cXml? ( with Post method ) and imagine that you are using SSL as it is a site that ends in "S" (httpS:)
Hbtip library itself does not support https.
You need to add support for SSL to be able to use https protocol.

REQUEST __HBEXTERN__HBSSL__

Function Main()

.../...

IF !tip_SSL()
MsgStop("Required SSL")
Return
ENDIF

You need also this libs:
hbssl
libeay32
ssleay32

and DLLs in folder of EXE

libeay32
ssleay32

I recommend that you use CURL library
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: TIPCLIENTHTTP problem ( new )
Posted: Wed Oct 30, 2019 08:34 PM

This has worked perfectly ( the XML content is properly formatted ) for several years. I upgraded to 19.09 and the Microsoft version of Harbour ( latest release from Antonio ), and suddenly this now occurs.

Prior to the upgrade, it never had a problem, so the code WAS fine.

Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: TIPCLIENTHTTP problem ( new )
Posted: Wed Oct 30, 2019 08:37 PM
TimStone wrote:This has worked perfectly ( the XML content is properly formatted ) for several years. I upgraded to 19.09 and the Microsoft version of Harbour ( latest release from Antonio ), and suddenly this now occurs.

Prior to the upgrade, it never had a problem, so the code WAS fine.


Sorry, but perhaps the site you are connecting to has changed its security protocols. I assure you that if the site you connect to ends in "S" you need the SSL protocol for your connection.
Try your previous version and tell me if it works without adding SSL.
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: TIPCLIENTHTTP problem ( new )
Posted: Wed Oct 30, 2019 08:39 PM

I also understand from your words that you send a string in XML format and get an answer in that same format. Is that so?
That's why you need to use the POST method

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: TIPCLIENTHTTP problem ( new )
Posted: Wed Oct 30, 2019 11:48 PM
This is the full Function that has worked perfectly until now. You mention hb_curl ... but where might there be samples of implementing it ?

Code (fw): Select all Collapse
FUNCTION ExchVinOnly( cVehVin )

  // local dummy := SSL_Init()
    Local oHttp:=TIpClientHttp():new("https://xxx.xxx.com/1", .F. ) 
    Local cXml := '<data-request>'+hB_osnewline()+;
        '     <vin>' + TRIM( cVehVin ) + '</vin>' + hb_osnewline() + ;
        '     <product-data-id>3D4207</product-data-id>'+hB_osnewline()+;  
        '     <location-id>' + TRIM(cGetSN) + '</location-id>'+hB_osnewline()+;
        '</carfax-request>'+hB_osnewline()
    Local cRet
    LOCAL oXmlDoc := TXmlDocument():new(  )
    LOCAL oXmlNode, oXmlRecScan, oXmlFieldScan
    LOCAL cYear := "", cMake := "", cModel := "", cVin := SPACE(20), ;
        cRetVin := "                   ", cMsg := "     ", lNoVin := .f.
        
    LOCAL aInfo[25], aRetData := {}
    LOCAL oXmlDoc2, oXmlIter, oTagActual
    AFill( aInfo, " " )
            21 =  Error Message                       22 - Carfax Outage
            23 = Production date
            */

    iDLL := LoadLibrary( "wininet.dll" )    

    IF lGetData
        IF .NOT. oHttp:open()
            MsgAlert( "Connection error:", oHttp:lastErrorMessage( ) )
            RETURN
        ENDIF
        oHttp:Post( cXml)
        cRet :=  oHttp:readAll( )
        oHttp:close()
   
               cRet := strtran(cRet, CHR(10), CRLF)
           m_lincnt := MLCount( cRet, 100,, .f. )
    
        /*   AT THIS POINT IN THE CODE
              The program decodes/parses the data returned in cRet.  The code is not relevant for
               this question
         */
    
    ELSE
        MsgInfo( "You do not have this service authorized.  This service is not available.")
    ENDIF

    // Close the library
    FreeLibrary( iDLL )   /*                         */
    
RETURN( aInfo )


The following libraries are linked in to the build:

Code (fw): Select all Collapse
echo $(HBDIR)\lib\hbtipssl.lib >> msvc.tmp
echo $(HBDIR)\lib\ssleay32.lib >> msvc.tmp
echo $(HBDIR)\lib\libeay32.lib >> msvc.tmp
echo $(HBDIR)\lib\hbtip.lib >> msvc.tmp
echo $(HBDIR)\lib\hbssl.lib >> msvc.tmp


To date there has not been a problem with this build ...
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: TIPCLIENTHTTP problem ( new )
Posted: Thu Oct 31, 2019 10:32 AM
Why don't you try something as follows? This works with https too.

Code (fw): Select all Collapse
//---------------------------------------------------------------------//
SendPostToUrl( "https://xxxx.xxxx.com/aaa/bbbb", cJson, cContentTpe, cAuthorization  ) 

Function SendPostToUrl( cUrl, cParams,cContentType,cAuthorization )
    Local oOle,cRet:='',uRet
    default cContentType:="application/x-www-form-urlencoded"
    default cAuthorization:=""
    Try
        oOle := CreateObject( 'MSXML2.XMLHTTP' )
    Catch
        oOle := CreateObject( 'Microsoft.XMLHTTP' )
    End
    oOle:Open( 'POST', cUrl, .f. )
    
    oOle:SetRequestHeader( "Content-Type",cContentType)
    if !empty(cAuthorization)
        oOle:SetRequestHeader( "Authorization",cAuthorization)
    end if
    
    oOle:Send( cParams )
    SysRefresh()
    
    #ifdef __XHARBOUR__
        cRet := oOle:ResponseBody
    #else
        cRet:=""
        hb_jsonDecode(oOle:ResponseBody,@cRet)
    #endif
Return cRet
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: TIPCLIENTHTTP problem ( new )
Posted: Thu Oct 31, 2019 08:21 PM

Anserkk,

Thank you. That is providing the connection that is working for me.

Tim

Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit

Continue the discussion