Webservice
Webservice
WEBSERVICE
APPSERVER
PROTHEUS COM PAULO BINDO - POUI
MÓDULO – Webservice
• O que é REST
https://www.totvs.com/blog/developers/rest/
https://coodesh.com/blog/dicionario/o-que-e-rest/
• Instalar SoapUI
https://www.soapui.org/downloads/soapui/soapui-os-older-versions/
• Instalar Postman
https://www.postman.com/
"enableMultiThread": true
3
PROTHEUS COM PAULO BINDO - POUI
MÓDULO – Webservice – WRESTFul
• comando para conectar no servidor REST
http://localhost:8084/rest/api/crm/v2/Seller/
4
PROTHEUS COM PAULO BINDO - POUI
MÓDULO – Webservice – WRESTFul
Class FWAPIManager
Method New()
Método Construtor
@param cAdapter , caracter, Infor,a o adapter a ser utilizado para iniciar o objeto
Method SetApiAdapter()
@param cAdapter , caracter, Infora o adapter a ser utilizado para iniciar o objeto
Method SetApiQstring()
5
PROTHEUS COM PAULO BINDO - POUI
MÓDULO – Webservice – WRESTFul
Method SetApiVersion()
Method SetApiAlias()
Method SetApiHasNext()
Method SetApiFilter()
@param aFilter , array, Array contendo o filtro a ser executado. Exemplo := {Alias,{alias.campo1 = xxx}, {alias.campo2 = yyy}}
6
PROTHEUS COM PAULO BINDO - POUI
MÓDULO – Webservice – WRESTFul
Method SetApiFields()
@param cFields , caracter, String com os campos da api. Ex: "code, number, date"
Method SetApiMap()
Method SetApiRelation()
Method SetIndexKey()
7
PROTHEUS COM PAULO BINDO - POUI
MÓDULO – Webservice – WRESTFul
Method SetJson()
Method SetJsonObject()
Método que monta o objeto Json de acordo com os atributos atribuídos na classe
Method SetPage()
Method SetPageSize()
Method SetJsonError()
{{cCode,cMessage,cDetailedMessage,cHelpUrl}} 8
PROTHEUS COM PAULO BINDO - POUI
MÓDULO – Webservice – WRESTFul
Method SetQuery()
@param cQuery , caracter, Query a ser executada sem o where, apenas com os joins
Method GetQuery()
Method GetApiAdapter()
Method GetApiPage()
Method GetApiPgSize()
Method GetExpFilter()
Method GetProtField()
Método que retorna o nome do campo Protheus de acordo com o AliasAPi e FieldApi
Method GetEstJson()
@param lTran, Lógico, Retorna os nomes oficiais, senão, retorna a estrutura com base no nickname
10
PROTHEUS COM PAULO BINDO - POUI
MÓDULO – Webservice – WRESTFul
Method GetApiVersion()
Method GetApiMap()
Method GetApiRelation()
Method GetApiAlias()
Method GetApiFields()
Method GetJsonObject()
Method GetJsonArray()
Method GetJsonSerialize()
Method ToObjectJson()
Método que retorna o JsonSerializado apanas para um objeto e não um array de objetos.
Method ToArray()
@return aRet , array , Retorno com 3 posições: [1] Cabeçalho, [2] Items, [3] Objetos
12
PROTHEUS COM PAULO BINDO - POUI
MÓDULO – Webservice – WRESTFul
Method DisplayEmptyFld()
Method ToExecAuto()
Method GetOrderKey()
Method GetProtInfo()
Método que retorna um array com alias, alias api e campos do Protheus
13
PROTHEUS COM PAULO BINDO - POUI
MÓDULO – Webservice – WRESTFul
Method GetJsonError()
Method Activate()
Method IsActive()
Method Destroy()
14
PROTHEUS COM PAULO BINDO - POUI
MÓDULO – Webservice – Autenticação
Autenticação básica
https://tdn.totvs.com/display/tec/oAuth
https://tdn.totvs.com/display/public/framework/Exemplo+de+consumo+com+HTT
P+Basic
15
PROTHEUS COM PAULO BINDO - POUI
MÓDULO – Webservice – TLPP
• Linguagem TL++
https://tdn.totvs.com/display/tec/Produtos+do+tlppCore
• REST server (tlppCore)
https://tdn.totvs.com/display/tec/REST
• Json
https://tdn.totvs.com/display/tec/Json
• Guia de referência das classes AdvPL
https://tdn.totvs.com/display/tec/AdvPL+-+Classes
• Guia de referência das classes AdvPL
https://tdn.totvs.com/display/tec/AdvPL+-+Classes
• FWAdapterBaseV2
https://tdn.totvs.com/display/public/framework/09.+FWAdapterBaseV2
16
PROTHEUS COM PAULO BINDO - POUI
MÓDULO – Webservice – TLPP
• Acessar lista de api
https://tdn.totvs.com/pages/viewpage.action?pageId=553900578
Exemplo: http://localhost:8084/rest/tlpp/rest/list/service
• Métricas de tempos
https://tdn.totvs.com/pages/viewpage.action?pageId=553900594
Habilitar via http:
http://localhost:8084/rest/tlpp/rest/usage/time?rest_trace_time=1
Leitura tempo: http://localhost:8084/rest/tlpp/rest/usage/time
17