Oct 27, 2022
Web Services are a method for two services to communicate to one another
Web services are typically not intended for direct human consumption and messages are usually constructed in data formats like XML or JSON to ease consumption by a program
Web services expose an API that can be consumed by other programs
There are many different standard protocols for web services
The main ones are SOAP and REST
We’ll focus on REST, as it is a bit simpler to use and maps to HTTP verbs we have already learned about
REST (Representational State Transfer) – standardizes interactions with web services through already existing HTTP verbs (GET, POST, PUT, DELETE); other protocols (e.g. SOAP) will create their own arbitrary methods
CRUD Application – a generic term for an application that is mostly involved in Creating, Reading, Updating, and Deleting records
The HTTP verbs map well to this archetype:
JSON (JavaScript Object Notation) – standard data format that is human readable while also being parseable by JavaScript interpreters
An alternative to XML
Many web services give you the choice of using JSON or XML data
{
"firstName": "John",
"lastName": "Smith",
"isAlive": true,
"age": 25,
"height_cm": 167.64,
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": "10021-3100"
},
"phoneNumbers": [
{ "type": "home", "number": "212 555-1234" },
{ "type": "fax", "number": "646 555-4567" }
]
}