TIPCLIENTHTTP problem ( new )

TIPCLIENTHTTP problem ( new )

Postby TimStone » Wed Oct 30, 2019 7: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
User avatar
TimStone
 
Posts: 2909
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: TIPCLIENTHTTP problem ( new )

Postby cnavarro » Wed Oct 30, 2019 8: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
User avatar
cnavarro
 
Posts: 6504
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: TIPCLIENTHTTP problem ( new )

Postby TimStone » Wed Oct 30, 2019 8: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
User avatar
TimStone
 
Posts: 2909
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: TIPCLIENTHTTP problem ( new )

Postby cnavarro » Wed Oct 30, 2019 8: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
User avatar
cnavarro
 
Posts: 6504
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: TIPCLIENTHTTP problem ( new )

Postby cnavarro » Wed Oct 30, 2019 8: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
User avatar
cnavarro
 
Posts: 6504
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: TIPCLIENTHTTP problem ( new )

Postby TimStone » 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: Select all  Expand view


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  Expand view

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

Re: TIPCLIENTHTTP problem ( new )

Postby anserkk » Thu Oct 31, 2019 10:32 am

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

Code: Select all  Expand view
//---------------------------------------------------------------------//
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
anserkk
 
Posts: 1331
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: TIPCLIENTHTTP problem ( new )

Postby TimStone » Thu Oct 31, 2019 8: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
User avatar
TimStone
 
Posts: 2909
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 41 guests

cron