FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Where do I start the Web Service?
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
Where do I start the Web Service?
Posted: Wed Jul 20, 2022 09:43 AM
Dear All,

I must communicate with website. I think the web service is way to do.
Where do I start?

I try but not successful. It show error
Application
===========
Path and name: d:\FWH1901\samples\testws.exe (32 bits)
Size: 3,732,480 bytes
Compiler version: xHarbour 1.2.3 Intl. (SimpLex) (Build 20180609)
FiveWin version: FWH 18.10
C compiler version: Borland/Embarcadero C++ 7.3 (32-bit)
Windows version: 6.2, Build 9200

Time from start: 0 hours 0 mins 0 secs
Error occurred at: 07/20/22, 16:42:18
Error description: Error MSXML2.XMLHTTP/3 DISP_E_MEMBERNOTFOUND: SEND
Args:
[ 1] = C

Code (fw): Select all Collapse
#include "fivewin.ch"

REQUEST DBFCDX

function Main()

   local odoc  := CreateObject( "MSXML2.DOMDocument" )
   local ohttp := CreateObject( "MSXML2.XMLHTTP" )
   local strret

   ohttp:Open( "GET" ,"http://www.w3schools.com/angular/customers.php", .F. )
   ohttp:SetRequestHeader( "Accept"        , "application/xml")
   ohttp:SetRequestHeader( "Content-Type" ,"application/json" )
   oDoc:async := .f.
   oDoc:LoadXml('<?xml version=""1.0"" encoding=""utf-8""?>')
   ohttp:Send(oDoc:xml)
   strret := alltrim(ohttp:responseText)

   ? StrRet

//   StrToHashArray( StrRet )
   SaveToDBF( StrRet )

return nil

function SaveToDBF( cStr )

   local hData

   cStr  := CharRepl( "[]", RangeRem( 1, 31, cStr ), "{}" )
   do while '" :' $ cStr
      StrTran( cStr, '" :', '":' )
   enddo
   cStr  := StrTran( cStr, '":', '"=>' )

   hData := &cStr

   if File( "download.dbf" )
      USE download.dbf NEW ALIAS DST EXCLUSIVE VIA "DBFCDX"
   else
      DBCREATE( "download.dbf", { { "NAME",    'C', 40, 0 }, ;
                                  { "CITY",    'C', 40, 0 }, ;
                                  { "COUNTRY", 'C', 40, 0 } }, ;
                "DBFCDX", .t., "DST" )
   endif

   AEval( HGetValueAt( hData, 1 ), { |h| DBAPPEND(), FW_HashToRec( h ) } )

   XBROWSER

   CLOSE DST

return nil



Thank in advance for any idea.
Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)
Posts: 1816
Joined: Wed Oct 26, 2005 02:49 PM
Re: Where do I start the Web Service?
Posted: Wed Jul 20, 2022 12:41 PM
Creo que debes hacerlo así

Code (fw): Select all Collapse
#include "fivewin.ch"

REQUEST DBFCDX

function Main()

   local odoc  := CreateObject( "MSXML2.DOMDocument" )
   local ohttp := CreateObject( "MSXML2.XMLHTTP" )
   local strret
   local hRespn  := hash()

   ohttp:Open( "GET" ,"http://www.w3schools.com/angular/customers.php", .F. )
   ohttp:SetRequestHeader( "Accept"        , "application/xml")
   ohttp:SetRequestHeader( "Content-Type" ,"application/json" )
   oDoc:async := .f.
   oDoc:LoadXml('<?xml version=""1.0"" encoding=""utf-8""?>')
   ohttp:Send(oDoc:xml)
   strret := alltrim(ohttp:responseText)
   
   hb_jsondecode(strret,@hRespn ) //Parse JSON to hash*/
   xbrowse(hRespn) 


   ? StrRet

//   StrToHashArray( StrRet )
   SaveToDBF( StrRet )

return nil
Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 25.01 ] [ xHarbour 64 bits) ]
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
Re: Where do I start the Web Service?
Posted: Wed Jul 20, 2022 01:11 PM
Dear leandro,

I've got the same error. I don't know which library I miss. ::Sebd() method is unknow.
Application
===========
Path and name: d:\FWH1901\samples\testws.exe (32 bits)
Size: 3,731,968 bytes
Compiler version: xHarbour 1.2.3 Intl. (SimpLex) (Build 20180609)
FiveWin version: FWH 18.10
C compiler version: Borland/Embarcadero C++ 7.3 (32-bit)
Windows version: 6.2, Build 9200

Time from start: 0 hours 0 mins 0 secs
Error occurred at: 07/20/22, 20:09:25
Error description: Error MSXML2.XMLHTTP/3 DISP_E_MEMBERNOTFOUND: SEND
Args:
[ 1] = C

Stack Calls
===========
Called from: => TOLEAUTO:SEND( 0 )
Called from: testws.prg => MAIN( 17 )

leandro wrote:Creo que debes hacerlo así

Code (fw): Select all Collapse
#include "fivewin.ch"

REQUEST DBFCDX

function Main()

   local odoc  := CreateObject( "MSXML2.DOMDocument" )
   local ohttp := CreateObject( "MSXML2.XMLHTTP" )
   local strret
   local hRespn  := hash()

   ohttp:Open( "GET" ,"http://www.w3schools.com/angular/customers.php", .F. )
   ohttp:SetRequestHeader( "Accept"        , "application/xml")
   ohttp:SetRequestHeader( "Content-Type" ,"application/json" )
   oDoc:async := .f.
   oDoc:LoadXml('<?xml version=""1.0"" encoding=""utf-8""?>')
   ohttp:Send(oDoc:xml)
   strret := alltrim(ohttp:responseText)
   
   hb_jsondecode(strret,@hRespn ) //Parse JSON to hash*/
   xbrowse(hRespn) 


   ? StrRet

//   StrToHashArray( StrRet )
   SaveToDBF( StrRet )

return nil
Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)
Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Re: Where do I start the Web Service?
Posted: Wed Jul 20, 2022 02:06 PM
Acá me trae la respuesta pero el no me lo decodifica bien el hb_jsondecode, porque esta dentro del valor de respuesta
Code (fw): Select all Collapse
#include "fivewin.ch"

REQUEST DBFCDX

function Main()

   local odoc  := CreateObject( "MSXML2.DOMDocument" )
   local ohttp := Createobject("MSXML2.ServerXMLHTTP")
   local strret
   local hRespn  := hash(), hRespn1 := hash()

   ohttp:Open( "GET" ,"http://www.w3schools.com/angular/customers.php", .F. )
   ohttp:SetRequestHeader( "Accept"        , "application/xml")
   ohttp:SetRequestHeader( "Content-Type" ,"application/json" )
   oDoc:async := .f.
   oDoc:LoadXml('<?xml version=""1.0"" encoding=""utf-8""?>')
   ohttp:Send(oDoc:xml)
   
   strret := alltrim(ohttp:responseText)
   
   hb_jsondecode(strret,@hRespn ) //Parse JSON to hash*/

   xbrowse(hRespn1)


   //? StrRet

//   StrToHashArray( StrRet )
   //SaveToDBF( StrRet )

return nil
Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Re: Where do I start the Web Service?
Posted: Wed Jul 20, 2022 02:12 PM
Corrijo
Asi te lo trae
Code (fw): Select all Collapse
#include "fivewin.ch"

REQUEST DBFCDX

function Main()

   local odoc  := CreateObject( "MSXML2.DOMDocument" )
   local ohttp := Createobject("MSXML2.ServerXMLHTTP")
   local strret
   local hRespn  := hash(), hRespn1 := hash()

   ohttp:Open( "GET" ,"http://www.w3schools.com/angular/customers.php", .F. )
   ohttp:SetRequestHeader( "Accept"        , "application/xml")
   ohttp:SetRequestHeader( "Content-Type" ,"application/json" )
   oDoc:async := .f.
   oDoc:LoadXml('<?xml version=""1.0"" encoding=""utf-8""?>')
   ohttp:Send(oDoc:xml)
   
   strret := alltrim(ohttp:responseText)
   
   hb_jsondecode(strret,@hRespn ) //Parse JSON to hash*/
   //hb_jsondecode(hRespn["records"],@hRespn1 )

   xbrowse(hRespn["records"])


   //? StrRet

//   StrToHashArray( StrRet )
   //SaveToDBF( StrRet )

return nil

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Where do I start the Web Service?
Posted: Wed Jul 20, 2022 05:10 PM

Querido César,

muchas gracias !

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
Re: Where do I start the Web Service?
Posted: Thu Jul 21, 2022 02:21 AM
Dear cmsoft,

Thank you, it works now.

This is the way to get from web server. How can I do the web server to response from web application? The web app will send request and I must reply data back.

cmsoft wrote:Corrijo
Asi te lo trae
Code (fw): Select all Collapse
#include "fivewin.ch"

REQUEST DBFCDX

function Main()

   local odoc  := CreateObject( "MSXML2.DOMDocument" )
   local ohttp := Createobject("MSXML2.ServerXMLHTTP")
   local strret
   local hRespn  := hash(), hRespn1 := hash()

   ohttp:Open( "GET" ,"http://www.w3schools.com/angular/customers.php", .F. )
   ohttp:SetRequestHeader( "Accept"        , "application/xml")
   ohttp:SetRequestHeader( "Content-Type" ,"application/json" )
   oDoc:async := .f.
   oDoc:LoadXml('<?xml version=""1.0"" encoding=""utf-8""?>')
   ohttp:Send(oDoc:xml)
   
   strret := alltrim(ohttp:responseText)
   
   hb_jsondecode(strret,@hRespn ) //Parse JSON to hash*/
   //hb_jsondecode(hRespn["records"],@hRespn1 )

   xbrowse(hRespn["records"])


   //? StrRet

//   StrToHashArray( StrRet )
   //SaveToDBF( StrRet )

return nil

Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)

Continue the discussion