Web Services
A web service is an implementation of SOA over the internet.
Web services
expose a contract that is independent of platforms or programming languages.
The two most popular implementations are Simple Object Access Protocol
(SOAP) and Representational State Transfer (REST).
SOAP
SOAP is a communication protocol that uses XML to define a Web Services
Description Language (WSDL). The API described
by WSDL documents can
be parsed by consumers to generate classes automatically. The Java API for
XML Web Services (JAX-WS) provides the specification for producing SOAP-
based web services via annotations. Apache
CXF is a popular open source
implementation of JAX-WS.
REST
REST is a pattern for designing web services that rely on the HTTP protocol
alone. REST web services expose meaningful URLs that utilize the GET, POST,
PUT, and DELETE methods to access resources.
REST architecture does not
specify a standard data format, but JSON is frequently used as a lightweight
alternative to XML. The Java API for RESTful Web Services (JAX-RS)
provides the specification for producing
REST-based web services via
annotations. Jersey is a popular open source implementation of JAX-RS.
SOAP vs REST
SOAP web services are useful when a rigid contract is required to support
complex operations between tightly coupled systems. REST web services are
more
flexible, but the lack of a WSDL document can be prohibitive for complex
services. SOAP web services are generally slower than REST due to the
verbosity of XML payloads.