Java Reference
In-Depth Information
8.1.2. Transports
Web services typically use HTTP or HTTPS to exchange messages. HTTP and HTTPS are
usually used because of their ubiquity. Using established ports and protocols simplifies web
service deployment because firewalls and routers are already configured for this traffic. It's
not necessary to open additional ports, which in some environments isn't possible. It also
simplifies development because existing web servers can host the web services. Web ser-
vices, specifically SOAP-based services, can also use other transports such as SMTP and
FTP. These other transports are beyond the scope of this chapter.
8.1.3. Web service types
The two big web service standards are SOAP and REST. With SOAP, messages are defined
using the Web Services Description Language (WSDL) and the message is encoded in a
well-defined XML format called a SOAP message. The WSDL defines the structure of an
incoming request and also the structure of the response. Given a WSDL document, code-
generation tools can produce code that will invoke a web service and process the response.
These tools exist for practically every language and platform. For example, if you're at-
tempting to invoke a web service from a .NET application, Microsoft provides tools and
APIs that make creating a client painless. The wsdl.exe application generates C# client
code from a WSDL file. The developer doesn't need to write the code that processes the
XML request or generate the response. Similar tools exist for other languages including
C++, Python, PHP, and so on.
Representational State Transfer (REST), like SOAP, uses XML and the HTTP protocol.
RESTful web services take a much different and arguably simpler approach from that of
SOAP. The basic idea behind REST is that a unique URL identifies each service. The para-
meters to the web service are passed in the same way that parameters to a form are passed
via HTTP. Furthermore, each web service gets mapped to one of the HTTP methods: GET ,
PUT , DELETE , POST , HEAD , and OPTIONS . These operations are documented in RFC
2616. A web service that returns a value and makes no change to the state should be imple-
mented as a GET operation. Use the PUT operation to store a document on the server, such
as creating a bid in ActionBazaar.
At the end of this chapter we'll compare SOAP to REST and provide guidelines for choos-
ing a technology after we explore each.
Search WWH ::




Custom Search