TIPCLIENTHTTP problem ( new )

Post Reply
User avatar
TimStone
Posts: 2536
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Contact:

TIPCLIENTHTTP problem ( new )

Post by TimStone »

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
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: TIPCLIENTHTTP problem ( new )

Post by cnavarro »

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
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
TimStone
Posts: 2536
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Contact:

Re: TIPCLIENTHTTP problem ( new )

Post by TimStone »

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
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: TIPCLIENTHTTP problem ( new )

Post by cnavarro »

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.
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: TIPCLIENTHTTP problem ( new )

Post by cnavarro »

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
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
TimStone
Posts: 2536
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Contact:

Re: TIPCLIENTHTTP problem ( new )

Post by TimStone »

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: Select all


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: Select all

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
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
User avatar
anserkk
Posts: 1280
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: TIPCLIENTHTTP problem ( new )

Post by anserkk »

Why don't you try something as follows? This works with https too.

Code: Select all

//---------------------------------------------------------------------//
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
User avatar
TimStone
Posts: 2536
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Contact:

Re: TIPCLIENTHTTP problem ( new )

Post by TimStone »

Anserkk,

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

Tim
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
Post Reply