Skip to content
Agentmart
Submit a tool

advpl-webservice

Web Services em ADVPL — REST (WSRESTFUL, @Get/@Post) e SOAP (WSSERVICE/WSMETHOD/WSDATA).

Skill by replybr

IndexedMIT
Write a review

Chalk Labs

Need help deploying advpl-webservice?

Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.

Book a call

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/replybr-advpl-webservice

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Web Services em ADVPL — REST (WSRESTFUL, @Get/@Post) e SOAP (WSSERVICE/WSMETHOD/WSDATA). NUNCA RpcSetEnv em REST (regra SEC crítica). Use ao criar API ou integração HTTP no Protheus.

Use cases: backend

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/advpl-webservice

What's inside

Skill name
advpl-webservice
Description
Web Services em ADVPL — REST (WSRESTFUL, @Get/@Post) e SOAP (WSSERVICE/WSMETHOD/WSDATA). NUNCA RpcSetEnv em REST (regra SEC crítica). Use ao criar API ou integração HTTP no Protheus.
License
MIT
Instructions
259 lines in SKILL.md · view on GitHub

Agent Skills spec issues

  • name: missing

Files (2)

  • SKILL.md
  • reference.md

SKILL.md (first lines)

# advpl-webservice — REST e SOAP no Protheus

ADVPL/TLPP suporta duas formas de Web Service:

- **REST** — preferida hoje. Sintaxe declarativa com `WSRESTFUL` + annotations `@Get`/`@Post`/`@Put`/`@Delete`. Em TLPP, mais limpo ainda com `Class ... Inherit FWRest`.
- **SOAP** — legado, mas vivo. `WSSERVICE` + `WSDATA` + `WSMETHOD` + `WSSTRUCT`.

O AppServer Protheus expõe ambos via porta HTTP configurada em `appserver.ini` (`[HTTPSERVER]`, `[HTTPV11]` para REST).

## Quando usar

- Criar API REST/SOAP no Protheus.
- Edit em fontes com `WSRESTFUL`, `WSSERVICE`, `WSMETHOD`, `WSDATA`, `WSSTRUCT`, `@Get`, `@Post`.
- Integração de Protheus com aplicação externa (mobile, e-commerce, ERP terceiro).
- Revisão de segurança em endpoint exposto (SEC-001, SEC-002).

## REST com WSRESTFUL (TLPP moderno)

```advpl
#include "tlpp-core.th"
#include "tlpp-rest.th"

@Get(endpoint="/v1/cliente/:codigo", description="Busca cliente por código")
User Function GetCliente()
    Local oResp  := JsonObject():New()
    Local cCod   := oRest:GetUrlParam("codigo")
    Local cError := ""

    If Empty(cCod)
        oRest:SetStatusCode(400)
        oResp["error"] := "Codigo obrigatorio"
        oRest:SetResponse(oResp:ToJson())
        Return .F.
    EndIf

    DbSelectArea("SA1")
    SA1->(DbSetOrder(1))
    If SA1->(DbSeek(xFilial("SA1") + cCod))
        oResp["codigo"] := SA1->A1_COD
        oResp["nome"]   := AllTrim(SA1->A1_NOME)
        oResp["cnpj"]   := SA1->A1_CGC
        oRest:SetStatusCode(200)
    Else
        oRest:SetStatusCode(404)
        oResp["error"] := "Cliente nao encontrado"
    EndIf

    oRest:SetResponse(oResp:ToJson())
Return .T.
```

## REST com WSRESTFUL (estilo classic)

```advpl
WSRESTFUL XYZCli DESCRIPTION "API de Clientes"

    WSMETHOD GET   DESCRIPTION "Lista clientes"   WSSYNTAX "/api/cli"
    WSMETHOD GET   DESCRIPTION "Busca por codigo" WSSYNTAX "/api/cli/{codigo}"
    WSMETHOD POST  DESCRIPTION "Cria cliente"     WSSYNTAX "/api/cli"

END WSRESTFUL

WSMETHOD GET WSSERVICE XYZCli
    Local cBody := ""
    // ... lógica
    ::SetContentType("application/json")
    ::SetResponse(cBody)
Return .T.

WSMETHOD POST WSSERVICE XYZCli
    Local cInput := ::GetContent()  // ATENÇÃO SEC-002
    // ... lógica com validação
Return .T.
```

## SOAP com WSSERVICE

```advpl
WSSERVICE XYZSrv DESCRIPTION "Servico XYZ"
    WSDATA cCodCliente AS STRING
    WSDATA oCliente    AS XYZCliRet

    WSMETHOD BuscaCliente DESCRIPTION "Busca cliente por codigo"
END WSSERVICE

WSSTRUCT XYZCliRet
    WSDATA cCodigo AS STRING
    WSDATA cNome   AS STRING
    WSDATA nLimite AS NUMERIC
END WSSTRUCT

WSMETHOD BuscaCliente WSRECEIVE cCodCliente WSSEND oCliente WSSERVICE XYZSrv
    ::oCliente := WSClassNew("XYZCliRet")
    // ... popula
Return .T.
```

## Regra crítica — NUNCA `RpcSetEnv` em REST (SEC-001 família)

`RpcSetEnv` é usado para abrir ambiente Protheus (empresa, filial, usuário) em **JOB/RPC**. **Em REST, o framework já entrega o ambiente** via autenticação HTTP (`token`, `basic auth`) configurada no `appserver.ini`.

```advpl
// ERRADO — risco crítico (SEC-001 família)
@Post(endpoint="/v1/pedido")
User Function CriaPedido()
    RpcSetEnv("01", "0101", "admin", "totvs")  // BLOQUEAR
    // ...
Return .T.

// CORRETO — ambiente já vem da requisição autenticada
@Post(endpoint="/v1/pedido")
User Function CriaPedido()
    Local cEmp := cEmpAnt  // já preenchido pelo framework
    Local cFil := cFilAnt  // já preenchido pelo framework
    // ... lógica
Return .T.
```

Razão: `RpcSetEnv` hardcoded vaza credenciais e bypassa o login do usuário REST. Auditoria perde rastreio.

From replybr/plugadvpl, MIT.

More from replybr/plugadvpl

Signals

Stars
0
Forks
5
Open issues
0
Last commit (this folder)
May 11, 2026 (5 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from replybr

Done for you

Rather not set it up yourself?

Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.

See how we build AI agents →Read the case studies

Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.

launches shipped
50+
launches shipped
media placements
500+
media placements
founders on every account
2
founders on every account

Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block

Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.

Get advpl-webservice running in your business

Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.

Goes to the Chalk Labs founders, not the newsletter. Privacy

Need help deploying advpl-webservice?

CallGet help
Cite this page

advpl-webservice skill. Agent Mart. https://agentmart.dev/skills/replybr-advpl-webservice (last updated 2026-10-24)