Blog

Web services explained: SOAP, REST and how they work

A web service lets one program ask another for data or an action over a network. How a call works, SOAP vs REST, web service vs API, and a worked design.

A web service is a program that other programs call over a network. One system sends a request to an address, the service does the work, such as looking up a price or booking a slot, and sends back an answer in a format the caller can read, usually JSON or XML. No person is clicking anything at either end. When your accounting package pulls payments from your bank, when a checkout page asks a card processor to charge a card, or when a phone app shows tomorrow’s forecast, a web service is doing the work behind the screen.

This guide explains how a call works, using a public government service you can try yourself, then the main kinds of web service, SOAP and REST compared, how a web service relates to an API, and how a small business might design one.

What is a web service?

A widely quoted definition comes from the World Wide Web Consortium (W3C), in its Web Services Architecture note of February 2004: “a software system designed to support interoperable machine-to-machine interaction over a network.” The same note goes on to say the interface is described in WSDL and that other systems talk to the service with SOAP messages, typically over HTTP. That second half reflects the year it was written. Today the term is used more loosely, for any service that one program calls over the web, and new ones commonly follow the REST style with JSON in place of SOAP and XML.

Five parts show up in almost every web service, whatever its style:

  • The provider runs the service and owns the data or the action behind it.
  • The consumer is the program making the call: a mobile app, a website’s server, another company’s system.
  • The endpoint is the address the consumer sends requests to, such as https://api.example.com/orders.
  • The contract says which requests the service accepts and what each answer looks like. For SOAP it is a WSDL file; for REST it is often an OpenAPI document.
  • The message format is how requests and answers are written down: XML for SOAP, usually JSON for REST.

Interoperability is the point. The two programs can be written in different languages, run on different operating systems and belong to different companies, and the call still works because both sides keep to the same contract and the same web protocols.

How a web service call works

The US National Weather Service runs a free public weather API that shows the whole cycle in two calls. Its documentation asks every caller to send a User-Agent header that identifies the application, with contact details if possible, and notes that this will be replaced by an API key in the future.

Step 1: turn a location into a forecast grid. The consumer sends an HTTP GET to the points endpoint with a latitude and longitude. The example coordinates in the service’s own documentation are in Kansas:

GET https://api.weather.gov/points/39.7456,-97.0892
User-Agent: (yourapp.example, contact@yourapp.example)

Step 2: read the answer. The service replies with status 200 OK and a JSON body (its content type is application/geo+json, JSON for geographic data). When we sent that request on November 28, 2026, the body named the forecast office (TOP), the grid square (32,81), the nearest town (Linn, Kansas) and, most usefully, the address to call next:

https://api.weather.gov/gridpoints/TOP/32,81/forecast

Step 3: follow the link. A second GET to that address returns the forecast itself, period by period.

Three things in this exchange are typical of a well-built service. The response headers include Cache-Control: public, max-age=…, telling any cache along the way how long the answer stays good, so the service is not asked the same question every second. The documentation lists several formats, and the consumer picks one with the Accept header. And the first answer hands the consumer the address of the next resource, so the consumer does not have to build that address itself.

One web service call. A consumer program sends a request with a method, an address and headers to the web service. The service does the work against its data and returns a response with a status code and a body in JSON or XML. A contract, OpenAPI or WSDL, describes both the request and the response.

Types of web services

Most services you will call follow one of two styles, and two newer ones sit beside them.

Style What it is Contract Message format Where you meet it
SOAP A messaging protocol, a W3C Recommendation WSDL XML, in an envelope Older enterprise systems, and partners that publish a WSDL
REST An architectural style built on HTTP Optional; OpenAPI is common Usually JSON Public APIs, mobile app back ends, SaaS products
GraphQL A query language served over HTTP A typed schema JSON Apps whose screens need data from many places at once
gRPC A remote procedure call framework Protocol Buffers definitions Protocol Buffers (binary) Calls between services inside one company's system

SOAP. SOAP Version 1.2, a W3C Recommendation since 2003 (second edition 2007), calls itself “a lightweight protocol intended for exchanging structured information in a decentralized, distributed environment.” A SOAP message is an XML envelope holding an optional header and a mandatory body. The letters used to stand for Simple Object Access Protocol, but version 1.2 says plainly that the name is no longer an acronym. The service is described in WSDL (Web Services Description Language), whose version 2.0 became a W3C Recommendation on June 26, 2007; the older WSDL 1.1 was published as a W3C Note in 2001.

REST. REST (representational state transfer) is not a protocol at all. Roy Fielding defined it in chapter 5 of his 2000 doctoral dissertation as a set of constraints: client and server kept apart, no session state held on the server between requests, responses labeled as cacheable or not, a uniform interface, a layered system and, as the only optional one, code on demand. In practice a REST service exposes resources at addresses (/orders/1042) and uses HTTP’s own methods on them.

GraphQL. A GraphQL server works on a single endpoint, usually /graphql, and the consumer writes a query that names exactly the fields it wants. Every server must accept POST; some also accept GET for queries, and changes to data must go by POST.

gRPC. gRPC uses Protocol Buffers as its interface definition language, and its methods can stream: the client, the server or both can send a sequence of messages over one call.

SOAP vs REST

SOAP REST
What it is A protocol with a written specification A style; each service applies it in its own way
Contract WSDL, generally required Optional; OpenAPI when there is one
Format XML only Any; JSON in most new services
Operations Named operations defined in the WSDL HTTP methods (GET, POST, PUT, DELETE) on resources
Errors A SOAP Fault element inside the reply HTTP status codes, often with a JSON error body
Caching Left to the application HTTP caching, for GET responses marked cacheable
Tooling Client code generated from the WSDL Plain HTTP; code can also be generated from OpenAPI

Errors are a good place to see the difference. SOAP puts error details inside the message: a SOAP fault carries a code saying, among other things, whether the sender sent a bad message (Sender, which the specification says should not be resent without change) or the receiver failed while processing it (Receiver). REST leans on HTTP status codes instead: 404 for a resource that does not exist, 409 for a conflict, 429 when the caller has sent too many requests (the response may add a Retry-After header). For the body, RFC 9457 (July 2023) defines a standard JSON shape called problem details, with fields such as type, title, status and detail.

Methods carry promises in REST. The HTTP standard, RFC 9110, calls a method safe when the client asks for no change on the server (GET is the usual one), and idempotent when sending the same request several times has the same intended effect as sending it once. PUT, DELETE and the safe methods are idempotent; POST is not. That difference matters the moment a network drops a reply. A consumer can resend a PUT without worrying, but a resent POST may create a second order unless the service guards against it.

Which to choose. For a new service that you control, REST with JSON and an OpenAPI description is the common default: every language can call it with an ordinary HTTP client, and the contract is optional but cheap to write. SOAP is usually chosen for you by the other side. If a bank, a government agency or a large customer publishes a WSDL and expects SOAP, you call it in SOAP. GraphQL earns its place when many screens each need a different slice of the same data. gRPC suits high-volume calls between services that one team owns on both sides.

Web service vs API

An API (application programming interface) is any defined way for one piece of software to use another. Many APIs never touch a network: a library’s functions and the operating system’s file calls are APIs too. A web service is an API offered over a network using web protocols. So every web service is an API, and only some APIs are web services.

In everyday speech the two words are now used for the same thing. “The payments API” and “the payments web service” usually mean one HTTP endpoint with a contract. The older word, web service, is more common around SOAP and enterprise systems, and API is what most REST providers call their product. The OpenAPI Specification, at version 3.2.1 when this was written, describes itself as an interface description “for HTTP APIs”, which shows where the vocabulary has moved.

Designing a web service: a worked example

The business below does not exist; it is here as an illustration. A coffee roaster sells beans wholesale to about 60 cafés. Orders arrive by email, and staff retype each one into the roaster’s order system. Two things change at once: a few cafés use ordering software that can place orders automatically, and a regional grocery distributor wants to order too, through its own SOAP service.

Resources first. The roaster’s team lists the things a café needs to read or change, and gives each an address. Writing this list before any code is written is the cheapest point to catch a missing piece.

Request What it does Safe? Idempotent?
GET /v1/products This week's coffees, sizes and wholesale prices Yes Yes
POST /v1/orders Places a new order No No, so the café sends its own order reference with each order, and a repeat of the same reference returns the order already placed
GET /v1/orders/{id} One order and its status (received, roasted, shipped) Yes Yes
PUT /v1/orders/{id}/delivery-day Sets the delivery day No Yes
DELETE /v1/orders/{id} Cancels an order before the roast cut-off No Yes

Decisions the list forces. The v1 in each address lets a later, incompatible version run beside this one while cafés move across. A cancellation after the cut-off returns 409 Conflict with a problem-details body that says why, rather than a vague error. The price list is marked cacheable for an hour, because it changes weekly. Each café gets its own credentials, and every order request checks that the order belongs to the café asking for it. Leaving that check out is the first risk on OWASP’s list, covered below. The contract is written as an OpenAPI document, so the cafés’ software vendors can generate client code from it.

The distributor’s SOAP service. The distributor will not call the roaster’s REST service; it publishes a WSDL and expects the roaster to send order confirmations to it in SOAP. The roaster does not rebuild its service around that. It adds a small adapter: when a distributor order is placed, the adapter turns it into the SOAP message the WSDL describes, sends it and records the reply, retrying when the fault says the receiver failed and stopping for a person to look when it says the message was wrong. One core service stays in REST, with one translator at the edge for the one partner that needs SOAP. Our guide to enterprise application integration covers that kind of connection between systems in more depth.

Securing a web service

A web service is a door into a business’s data. Because it is built to be called by programs, an attacker can script requests against it at a pace no person clicking through a website would manage. The OWASP API Security Top 10 (2023 edition) is the standard list of what goes wrong. Its first entry is broken object level authorization: a service that checks who the caller is but not whether this caller may see this record, so changing the number in /orders/1042 shows someone else’s order. Others on the list include broken authentication, unrestricted resource consumption (no limits on how much one caller can ask for) and improper inventory management (old versions and forgotten endpoints still running).

The basics that follow from it:

  • HTTPS on every endpoint, with no plain HTTP fallback.
  • Authentication per consumer, so one leaked credential can be revoked without breaking every other caller.
  • An ownership check on every record, in the service, never left to the consumer’s software.
  • Rate limits, answered with 429 and a Retry-After header.
  • A list of every live version and endpoint, with a date to switch off the old ones.
  • Input checked against the contract, so malformed requests are refused at the door.

Our guide to building secure web applications places each of those decisions at the stage of a build where it costs least.

Other questions people ask

Is AWS a web service?

Amazon Web Services is a cloud provider whose products are run through web services: almost everything in AWS, from starting a server to storing a file, is a request to an AWS endpoint, whether it is sent by the console, a command-line tool or a program. Amazon S3, its storage service, is a clear case. Its API reference says S3 supports the REST API, and that SOAP support is discontinued, as AWS announced on May 5, 2025: SOAP requests now get a 400 Bad Request. If you are choosing between clouds rather than protocols, our comparison of AWS vs Azure covers that decision.

Which web service is best?

It depends on which meaning you have in mind. If you mean a style for a new service you are building, REST with JSON and an OpenAPI contract is the safe default, with SOAP where a partner requires it. If you mean a provider for a particular job (payments, maps, email, weather), the best one is the one whose contract covers your case, whose limits fit your volume and whose terms you can live with if you ever need to leave.

What is the difference between a web server and a web service?

A web server is the software that accepts HTTP requests and sends responses: Apache HTTP Server, nginx, Microsoft IIS, LiteSpeed and Caddy are common examples. A web service is an application that answers requests meant for programs. It often sits behind one of those servers, although many frameworks include an HTTP server of their own. The weather service above, for instance, answered our request through nginx, according to its response headers.

What is a web service in simple words?

A program that waits at a web address for other programs to ask it for something, does what was asked, and answers in a format they can read.

If you need a web service built

We build the services and APIs behind the web applications and portals we deliver. Our web application development page sets out how we work and the stack we use for that layer: .NET, Java, Node.js with NestJS, and Laravel on PHP. If you have systems that need to talk to each other, or a partner asking you for an API, describe them through the contact page. A member of the team replies within one business day.

The full service behind this post: Custom Web Application Development Company.

Ready to scope your project?

Send us two sentences about what you need. We reply within one business day with the next step and any questions we need answered first.

Get a Quote