Запрос на создание машины:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://example.com/webservices">
<soapenv:Header/>
<soapenv:Body>
<web:CreateCar>
<web:brand>Tesla</web:brand>
<web:model>Model 3</web:model>
<web:year>2022</web:year>
</web:CreateCar>
</soapenv:Body>
</soapenv:Envelope>
После создания машине присваивается уникальный id=456. Пример ответа:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://example.com/webservices">
<soapenv:Header/>
<soapenv:Body>
<web:CreateCarResponse>
<web:carId>456</web:carId>
<web:brand>Tesla</web:brand>
<web:model>Model 3</web:model>
<web:year>2021</web:year>
</web:CreateCarResponse>
</soapenv:Body>
</soapenv:Envelope>
Теперь, как и для REST API, получение машины c id=457
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://example.com/webservices">
<soapenv:Header/>
<soapenv:Body>
<web:GetCarRequest>
<web:carId>457</web:carId>
</web:GetCarRequest>
</soapenv:Body>
</soapenv:Envelope>
Пример ответа:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://example.com/webservices">
<soapenv:Header/>
<soapenv:Body>
<web:GetCarResponse>
<web:car>
<web:id>457</web:id>
<web:brand>Tesla</web:brand>
<web:model>Model Y</web:model>
<web:year>2022</web:year>
</web:car>
</web:GetCarResponse>
</soapenv:Body>
</soapenv:Envelope>
Обратите внимание на перегруженность формата xml. Если в JSON всё аккуратно и человекочитаемо, то в XML, конечно, читаемо, но более перегружено. И это еще простой пример. А еще есть XSD-схема и wsdl 🙂
Но об этом в другой серии постов, если наберем 100🦄 и SOAP вам актуален. Пока GraphQL 😀
#ИнтеграцииGA
