|
|
Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
Page 4 of 4
The final portion of this architectural style is the R in REST: representation. This is the structural form of the resource as it moves back and forth from client to server. In Java and other object-oriented languages, we think about objects, but by giving resources logical names, you do not have a strict binding between an information consumer and producer and can therefore negotiate the form when you ask for it. This is one of the key advantages of REST over SOAP as far as information management is concerned. You do not want the same physical structure or level of detail back in all situations. XML may be a great format in the business tier, but JavaScript frameworks tend to have difficulty with this data-interchange lingua franca. In a browser-based API, you might like to refer to the same resource but ask for it back as JavaScript Object Notation (JSON). There is no reason, if the server can support the request, for the client to get back anything other than what it needs. With this flexibility in place, however, you can build frameworks that automatically serialize the returned value into Java, C#, or other objects you can use. It is like having the simplicity of Java remote method invocation (RMI) without its Java-only limitations.
As an architectural style, REST is simple and flexible, and it allows the various communicating pieces to change over time. This flexibility gives you the resilience to embrace the change that inevitably comes in the form of new use cases, new technologies, new requirements, or a new understanding of your domains. Software achieves scalability by talking to logical names that might map to a load balancer that redirects to multiple back-end responders. Clients do not need to know which specific machine they are communicating with. To meet the needs of this kind of an environment, you need an integration approach that separates out the concerns of:
The simple diagram in Figure 3 shows how REST implements this separation of concerns:

WSDL-based SOAP systems do not give you this flexibility. They bind you to a contract that controls what is being asked and of whom, and what will be returned. It is difficult to change any part of that without affecting the clients using the service. REST isn't immune to this problem, but more opportunities to route around it are available. Document/Literal style SOAP has more flexibility than the remote procedure call (RPC) approach, but you lose the ability to name the request and the results the way you can in REST via URLs. This makes it much harder to identify cacheable requests. It is not impossible, and work is being done to improve the situation, but the collection of specifications needed to manage relatively simple requests starts to feel like overengineering.
When you need to invoke behavior in standard, contract-bound ways between disparate partners, SOAP is a good approach. If, on the other hand, you are looking to share information in flexible, scalable, reusable ways, then REST is a great approach. If you would like to build systems that do not require constant migration in the face of back-end flux, then REST's resource-oriented approach gives you that flexibility. The trick is to focus on the information. Who wants it? How do they want it? What do they know and what do they need to know? If you can build software systems that efficiently satisfy these needs, you will add tremendous business value to your customers and give yourself a long-term architectural strategy for success.
In the next article in this series, you'll explore Restlet, an API that makes it easier to build and consume RESTful services in Java.
Read more about Enterprise Java in JavaWorld's Enterprise Java section.
More