Where do I start the Web Service?

Where do I start the Web Service?

Postby dutch » Wed Jul 20, 2022 9: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: Select all  Expand view
#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 19.01 / 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)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: Where do I start the Web Service?

Postby leandro » Wed Jul 20, 2022 12:41 pm

Creo que debes hacerlo así

Code: Select all  Expand view

#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

[ Embarcadero C++ 7.60 for Win32 ] [ FiveWin 23.07 ] [ xHarbour 1.3.0 Intl. (SimpLex) (Build 20230914) ]
User avatar
leandro
 
Posts: 1669
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia

Re: Where do I start the Web Service?

Postby dutch » Wed Jul 20, 2022 1: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: Select all  Expand view

#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 19.01 / 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)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: Where do I start the Web Service?

Postby cmsoft » Wed Jul 20, 2022 2: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: Select all  Expand view

#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
User avatar
cmsoft
 
Posts: 1289
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: Where do I start the Web Service?

Postby cmsoft » Wed Jul 20, 2022 2:12 pm

Corrijo
Asi te lo trae
Code: Select all  Expand view
#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

Image
User avatar
cmsoft
 
Posts: 1289
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: Where do I start the Web Service?

Postby Antonio Linares » Wed Jul 20, 2022 5:10 pm

Querido César,

muchas gracias !
regards, saludos

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

Re: Where do I start the Web Service?

Postby dutch » Thu Jul 21, 2022 2: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: Select all  Expand view
#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

Image
Regards,
Dutch

FWH 19.01 / 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)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 91 guests