Forem

Fernilo
Fernilo

Posted on

REST VS SOAP

Cuando se envía una solicitud de datos a una API de REST, se suele hacer a través de un protocolo de transferencia de hipertexto, denominado HTTP. Una vez que reciben la solicitud, las API diseñadas para REST (conocidas como API o servicios web de RESTful) pueden devolver mensajes en distintos formatos: HTML, XML, texto sin formato y JSON. Opera principalmente mediante verbos HTTP (GET, POST, PUT, DELETE).

REST es Menos robusto para transacciones complejas o seguridad avanzada pero es más rápido y ligero (JSON es menos pesado que XML).

Escenarios comunes: Aplicaciones web y móviles, API públicas.

Image description
(Fuente: Seobility)

SOAP (Simple Object Access Protocol) es un protocolo de comunicación basado en XML que permite la interacción entre sistemas a través de redes. Como es un protocolo, impone reglas integradas que aumentan la complejidad y la sobrecarga, lo cual puede retrasar el tiempo que tardan las páginas en cargarse

Por su seguridad y por la integridad de los datos, SOAP es más recomendable.

Escenarios comunes: Servicios empresariales, integraciones complejas.

Ejemplos

REST(json)
GET /api/users/123 HTTP/1.1
Host: example.com

Response:
{
    "id": 123,
    "name": "John Doe"
}
Enter fullscreen mode Exit fullscreen mode
SOAP(xml)
POST /soap HTTP/1.1
Host: example.com
Content-Type: text/xml
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
        <GetUser>
            <UserId>123</UserId>
        </GetUser>
    </soap:Body>
</soap:Envelope>

Response:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
        <GetUserResponse>
            <User>
                <Id>123</Id>
                <Name>John Doe</Name>
            </User>
        </GetUserResponse>
    </soap:Body>
</soap:Envelope>
Enter fullscreen mode Exit fullscreen mode

Please leave your appreciation by commenting on this post!

Let's go

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay