Versão atual:

Rest Tlpp - Como acessar tabelas do Protheus

Ao tentar utilizar utilizar o comando abaixo com a intenção de preparar o ambiente em uma empresa específica para conseguir acessar as tabelas é retornado um erro informando que a função RPCSETENV não existe

PREPARE ENVIRONMENT EMPRESA "01" FILIAL "00"

Segue dados do Rest

onStart.tlpp

#INCLUDE "Tbiconn.ch"
/*
  Função chamada a partir do arquivo appserver.ini

*/
user function onStart() as logical
  local lOK := .T. as logical
  PREPARE ENVIRONMENT EMPRESA "01" FILIAL "00"
return lOK

user function onStartSlave1() as logical
  local lOK := .T. as logical
  PREPARE ENVIRONMENT EMPRESA "01" FILIAL "00"
return lOK

onSelect.tlpp

#include 'tlpp-core.th'
#include 'tlpp-rest.th'
#include 'totvs.ch'
#INCLUDE "Tbiconn.ch"
User function onSelect(  ) as integer

    Local nIndex    :=-1 as integer
    // local aSlaves   := oRest:GetThreadPoolSlaves() as array
    // local nA        := 0 as integer
    // for na := 1 to len(aSlaves)
    //     if ( aSlaves[nA]:ID == 6 ) // logica qualquer
    //         nIndex := nA
    //     endif
    // next
  nIndex:=1
return nIndex

User function onSelectSlave1(  ) as integer

    Local nIndex    :=-1 as integer
return nIndex

Appserver.ini

Servers=HTTP_REST
Log=1
charset=UTF-8
​
[HTTP_REST]
hostname=localhost
port=8095
locations=HTTP_ROOT
ContentTypes=ContentTypes
​
[HTTP_ROOT]
Path=/
RootPath=root/web
ThreadPool=THREAD_POOL
​
[THREAD_POOL]
Environment=environment
MinThreads=1
MaxThreads=4
GrowthFactor=1
UserExits=THREAD_POOL_UEX

[THREAD_POOL_UEX]
OnStart=u_onStart
OnSelect=u_onSelect

[SLAVE_01]
Environment=environment
UserExits=THREAD_POOL_SLAVES_UEX
MinThreads=1
MaxThreads=2
MinFreeThreads=1
GrowthFactor=1
InactiveTimeout=30000
AcceptTimeout=10000

[THREAD_POOL_SLAVES_UEX]
OnStart=u_onStartSlave1
OnSelect=u_onSelectSlave1

[General]
App_Environment=environment

[ContentTypes]
json = text/plain;charset=UTF-8
xml = text/xml;charset=UTF-8
htm = text/html;charset=UTF-8
html = text/html;charset=UTF-8
txt = text/plain;charset=UTF-8

Imagem o erro: erro server1.png

Versão (1):

Ver a versão formatada

Rest Tlpp - Como acessar tabelas do Protheus

Comentário

new question