Java Reference
In-Depth Information
Recall also that REST builds heavily on the existing HTTP protocol. If you're very observant, you
might recall that SOAP can wrap its messages inside the HTTP protocol. Take, for instance, the
example provided by WebserviceX.NET to access the stock quote service:
POST /stockquote.asmx HTTP/1.1
Host: www.webservicex.net
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: " http://www.webserviceX.NET/GetQuote"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd=" http://www.w3.org/2001/XMLSchema"
xmlns:soap=" http://schemas.xmlsoap.org/soap/envelope/" >
<soap:Body>
<GetQuote xmlns=" http://www.webserviceX.NET/">
<symbol>string</symbol>
</GetQuote>
</soap:Body>
</soap:Envelope>
So what is the difference here? In SOAP, the HTTP protocol is just one way to “encapsulate” a
SOAP message. Other methods exist. For example, it is possible to send SOAP messages over the
so‐called SMTP protocol, the Simple Mail Transfer Protocol that is used to send e‐mails. When
you are coding SOAP clients, however, JAX‐WS assumes by default that you're going to send
SOAP messages over HTTP, and the main concern then is to construct the actual XML SOAP
message.
In REST, the HTTP protocol is the complete exchange protocol, meaning that REST basically
instructs programmers to use the same protocol as your web browser uses to access websites, with
the difference being that web servers will not return HTML data to be rendered by a web browser,
but structured data that can be parsed by a computer. This can be in XML as well, but with the
difference that this XML will not contain any of the SOAP‐defined tags. For example, you could
send the following HTTP GET request to a RESTful web service:
GET /stockquote/IBM HTTP/1.1
Host: www.example.com
Connection: keep-alive
Accept: application/xml
And simply get back the following reply:
HTTP/1.0 200 OK
Content-Type: application/xml
<StockQuotes>
<Stock>
<Symbol>IBM</Symbol>
<Last>190.01</Last>
<Date>4/17/2014</Date>
Search WWH ::




Custom Search