Cashdro
Posted: Thu Jul 25, 2019 7:17 am
Hello everyone, I need to control an automatic cash drawer (Cashdro).
The communication is reactivated through the web service.
There is some DLL to send data to an IP and to collect the information that returns me.
I've been watching xb2.net but I don't see how to send and receive.
I have to send calls of this type:
https://192.168.13.168/Cashdro3WS/index.php?
operation=startOperation&name=admin&password=1234&ty
pe=4&posid=terminal2&posuser=Maria¶meters={"amou
nt":"100"}
The class I have is as follows but it doesn't work for me:
CLASS WebService
EXPORTED:
// ---------------------------------------------------------------------------------
CLASS VAR hWinINet_Dll
CLASS VAR fp_InternetOpen
CLASS VAR fp_InternetOpenUrl
CLASS VAR fp_InternetReadFile
CLASS VAR fp_InternetCloseHandle
// ---------------------------------------------------------------------------------
VAR cUserAgent
VAR hInternet
VAR pBuffer
VAR nBufferSize
// ---------------------------------------------------------------------------------
INLINE CLASS METHOD initClass()
::hWinINet_Dll := DllLoad("WinINet.dll")
::fp_InternetOpen := nGetProcAddress(::hWinINet_Dll,"InternetOpenA" )
::fp_InternetOpenUrl := nGetProcAddress(::hWinINet_Dll,"InternetOpenUrlA" )
::fp_InternetReadFile := nGetProcAddress(::hWinINet_Dll,"InternetReadFile" )
::fp_InternetCloseHandle := nGetProcAddress(::hWinINet_Dll,"InternetCloseHandle")
return Self
// --------------------------------------------------------------------
INLINE METHOD init( cUserAgent , nBufferSize )
BYNAME cUserAgent DEFAULT "WEBSERVICES"
BYNAME nBufferSize DEFAULT 0x8000
::Release() // clean previous conections
::pBuffer := _xgrab( ::nBufferSize )
::hInternet := nFpCall( ::fp_InternetOpen ,::cUserAgent ,INTERNET_OPEN_TYPE_PRECONFIG ,0,0,0)
return Self
// ---------------------------------------------------------------------------------
INLINE METHOD Release()
if( !Empty(::pBuffer))
_xfree(::pBuffer) ; ::pBuffer := NIL
end
if( !Empty(::hInternet))
nFpCall( ::fp_InternetCloseHandle ,::hInternet) ; ::hInternet := NIL
end
return Self
// ---------------------------------------------------------------------------------
INLINE METHOD ReadUrl( cUrl , cHeaders , nContext)
local h := 0
local nLen := 0
local n := 0
local cRet := ""
if( Empty( cHeaders) )
cHeaders := 0
nLen := 0
else
nLen := Len(cHeaders)
end
DEFAULT nContext := 0
h := nFpCall( ::fp_InternetOpenUrl ,::hInternet , cUrl , cHeaders,nLen, 0 , nContext)
if( h != 0 )
_bset(::pBuffer,0,::nBufferSize)
if (nFpCall( ::fp_InternetReadFile ,h , ::pBuffer , ::nBufferSize , @n ) != 0)
cRet := PeekStr(::pBuffer,0,n)
end
nFpCall( ::fp_InternetCloseHandle ,h)
end
return cRet
// ---------------------------------------------------------------------------------
ENDCLASS
Thank you very much for your help
The communication is reactivated through the web service.
There is some DLL to send data to an IP and to collect the information that returns me.
I've been watching xb2.net but I don't see how to send and receive.
I have to send calls of this type:
https://192.168.13.168/Cashdro3WS/index.php?
operation=startOperation&name=admin&password=1234&ty
pe=4&posid=terminal2&posuser=Maria¶meters={"amou
nt":"100"}
The class I have is as follows but it doesn't work for me:
CLASS WebService
EXPORTED:
// ---------------------------------------------------------------------------------
CLASS VAR hWinINet_Dll
CLASS VAR fp_InternetOpen
CLASS VAR fp_InternetOpenUrl
CLASS VAR fp_InternetReadFile
CLASS VAR fp_InternetCloseHandle
// ---------------------------------------------------------------------------------
VAR cUserAgent
VAR hInternet
VAR pBuffer
VAR nBufferSize
// ---------------------------------------------------------------------------------
INLINE CLASS METHOD initClass()
::hWinINet_Dll := DllLoad("WinINet.dll")
::fp_InternetOpen := nGetProcAddress(::hWinINet_Dll,"InternetOpenA" )
::fp_InternetOpenUrl := nGetProcAddress(::hWinINet_Dll,"InternetOpenUrlA" )
::fp_InternetReadFile := nGetProcAddress(::hWinINet_Dll,"InternetReadFile" )
::fp_InternetCloseHandle := nGetProcAddress(::hWinINet_Dll,"InternetCloseHandle")
return Self
// --------------------------------------------------------------------
INLINE METHOD init( cUserAgent , nBufferSize )
BYNAME cUserAgent DEFAULT "WEBSERVICES"
BYNAME nBufferSize DEFAULT 0x8000
::Release() // clean previous conections
::pBuffer := _xgrab( ::nBufferSize )
::hInternet := nFpCall( ::fp_InternetOpen ,::cUserAgent ,INTERNET_OPEN_TYPE_PRECONFIG ,0,0,0)
return Self
// ---------------------------------------------------------------------------------
INLINE METHOD Release()
if( !Empty(::pBuffer))
_xfree(::pBuffer) ; ::pBuffer := NIL
end
if( !Empty(::hInternet))
nFpCall( ::fp_InternetCloseHandle ,::hInternet) ; ::hInternet := NIL
end
return Self
// ---------------------------------------------------------------------------------
INLINE METHOD ReadUrl( cUrl , cHeaders , nContext)
local h := 0
local nLen := 0
local n := 0
local cRet := ""
if( Empty( cHeaders) )
cHeaders := 0
nLen := 0
else
nLen := Len(cHeaders)
end
DEFAULT nContext := 0
h := nFpCall( ::fp_InternetOpenUrl ,::hInternet , cUrl , cHeaders,nLen, 0 , nContext)
if( h != 0 )
_bset(::pBuffer,0,::nBufferSize)
if (nFpCall( ::fp_InternetReadFile ,h , ::pBuffer , ::nBufferSize , @n ) != 0)
cRet := PeekStr(::pBuffer,0,n)
end
nFpCall( ::fp_InternetCloseHandle ,h)
end
return cRet
// ---------------------------------------------------------------------------------
ENDCLASS
Thank you very much for your help