Avalados por :

Como criar uma API REST com roteamento MVC1: guia passo a passo

  • Creado 01/03/2024
  • Modificado 01/03/2024
  • 10 Vistas
0
Cargando...
Hi,

In this blog post, I would like to show how to create a REST API and how to apply MVC1 routing to handle different requests simply from a controller class.

For that, first we will create a handler and controller class for the REST structure. Then we will add an MVC1 controller class and model class to process business logic.

And finally, we will create a service to handle REST requests.

At the end of the post, there are web browser, Postman, and ABAP consuming examples for the same REST API.

To read more about SAP REST, have a look at REST Tutorial .







Let's start.

Create the following structures ;

  • ZREST_S_RESP_STATE

  • ZREST_S_RESPONSE

  • ZREST_S_REQUEST




  • ZREST_S_RESP_STATE





  • ZREST_S_RESPONSE





  • ZREST_S_REQUEST





Now we will create classes.

Call Stack for a call




Classes

  • ZREST_CL_DEFS

  • ZREST_CL_MODEL

  • ZREST_CL_REQ_CONTROLLER

  • ZREST_CL_REQ_HTTP_HANDLER

  • ZREST_CL_HTTP_HANDLER



CLASS zrest_cl_defs DEFINITION
  PUBLIC
  CREATE PUBLIC .

  PUBLIC SECTION.

    CONSTANTS c_state_success TYPE char1 VALUE 'S' ##NO_TEXT.
    CONSTANTS c_state_warning TYPE char1 VALUE 'W' ##NO_TEXT.
    CONSTANTS c_state_error TYPE char1 VALUE 'E' ##NO_TEXT.

  PROTECTED SECTION.
  PRIVATE SECTION.
ENDCLASS.



CLASS ZREST_CL_DEFS IMPLEMENTATION.
ENDCLASS.
Pedro Pascal
Se unió el 07/03/2018
Pinterest
Telegram
Linkedin
Whatsapp

Sin respuestas

No hay respuestas para mostrar No hay respuestas para mostrar Se el primero en responder

contacto@primeinstitute.com

(+51) 1641 9379
(+57) 1489 6964

© 2024 Copyright. Todos los derechos reservados.

Desarrollado por Prime Institute

¡Hola! Soy Diana, asesora académica de Prime Institute, indícame en que curso estas interesado, saludos!
Hola ¿Puedo ayudarte?