Chapter 10. Web Services as Objects
Starting in 2001, Web services seemed to be the focus of every other technology story, as experts promised they would change the world or maybe cure cancer. Although the importance of Web services initially might have been overstated, they're incredibly useful for the purpose of enabling machines to communicate.Web services transmit data in the same way that a Web browser and a Web server do, via HTTP (Hypertext Transfer Protocol). Instead of swapping HTML and form data, XML is sent. Furthermore, the Simple Object Access Protocol (SOAP) is an XML standard frequently used to send messages in a consistent format between systems.The funny thing about Web services and ASP.NET is that you don't really need to know much about XML or SOAP to make Web services work. That's a real blessing, too, because trying to dig into the SOAP standard is enough to make some developers go running for the hills. Fortunately, the tools found in ASP.NET and Visual Studio make it easy to create and consume Web services.When learning about Web services, you need to think of them in terms of having remote access to code, not just a means to send messages back and forth between systems. When you consume a Web service, it's like having a class locally, in your own code. The difference is that the execution happens on the remote system, not on your own. The application data is serialized between the two systems as XML.
What is serialization? It's the conversion of objects into a format that can be transmitted, in this case using XML. |
This is probably a good time to mention that although you can simulate object-oriented programming with Web services, it's far from ideal. Remember that because data must be serialized and calls must be made to the server any time that data must be processed, this could result in many potentially large messages being sent back and forth to the server. This kind of activity could cause a busy server to buckle under pressure and not scale or perform well. Thus, Web services should be as simple as possible, and they should act more as end-points for the exchange of data and less like remote objects.