Usina BRAdvPL Guide
Sign in
← All topics
PRACTICAL GUIDEUnder review

Server-side REST in AdvPL

WSRESTFUL Ed619 ... END WSRESTFUL

Defines a constant-response REST route without data access.

Server-side REST in AdvPLAdvPL
01 · OVERVIEW

Overview

WSRESTFUL declares methods and WSMETHOD handles requests/builds responses. The class name contributes to the URI under AppServer HTTP configuration. This subset uses a named GET without query parameters or request body and returns constant JSON. Authentication, TLS, tenant context and rights must be configured/tested outside this source; compiling it does not implement them. TDN warns classes compiled after HTTP_START may require a restart for publication; plan that operationally, not by restarting a server just to test this text. (Sources: refs. 1–3.)

02 · SYNTAX

Syntax

WSRESTFUL Ed619 ... END WSRESTFUL
03 · PRACTICAL EXAMPLE

Commented example

#Include "TOTVS.ch"
#Include "RESTFul.ch"

WSRESTFUL Ed619 DESCRIPTION "Editorial example status"
    WSMETHOD GET STATUS DESCRIPTION "Editorial example status" ;
        WSSYNTAX "/Ed619/status" PATH "/status" PRODUCES APPLICATION_JSON
END WSRESTFUL

WSMETHOD GET STATUS WSSERVICE Ed619
    // Constant response: no business data or credentials.
    Self:SetContentType("application/json")
    Self:SetResponse('{"status":"ok"}')
Return .T.
Expected result

On an approved service the configured GET route returns {"status":"ok"}. It has not been compiled, registered or called on AppServer. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • For real data, validate format, bound pagination and check resource/branch permissions. Do not use NOTENANT or disable security as a shortcut.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. Criando uma classe REST. WSRESTFUL, métodos e retorno. Accessed on 2026-10-27.
  2. OWASP. Authorization Cheat Sheet. Negar por padrão e conferir cada requisição. Accessed on 2026-10-27.
  3. Atilio. dan-atilio/AdvPL. Maratona de Exemplos/Exemplo_535_Classe_WsRestFul.prw. Arquivo completo consultado; adaptação editorial. Accessed on 2026-10-27.
Status
Under review
Page created on
Last reviewed on
Original language
Portuguese
Reviewed by
Usina.BR
0 approved comment(s)

Comments

There are no approved comments yet.

Sign in with Google or Microsoft to comment.

Powered by Usina Docs · Alpha