Web Services, Part III: WebService's Methods
Benefits of the WebService Behavior
The primary reason to use the
WebService behavior is that it provides you with a way to use Web services without having expert knowledge of SOAP. SOAP (Simple Object Access Protocol) is the protocol by which Web pages send and receive messages to and from Web services over HTTP. The
WebService behavior simplifies the use of Web services by handling the communication of the SOAP data packets between the browser and the Web services. You don't have to worry about assembling and disassembling SOAP messages. All the SOAP-specific handling code is encapsulated inside the behavior, simplifying the client-side script in the main Web page.
WebService behavior exposes objects and methods to client-side scripts, to enable assembling messages as well as disassembling responses that are sent back by the Web services. The objects that are exposed by the behavior enable error handling and easy access to the returned data. The
WebService behavior receives method calls from the client-side script and sends a request to the Web service. The results are returned to the client script, and processing continues. The Web page can then use the information in whatever context is required, such as updating some portion of the page, sending error messages, etc.
A key feature of the
WebService behavior is that it enables client-side script to access a Web service without requiring navigation to another URL. Using the
WebService behavior approach, only portions of the page that are indicated by the user's inputs can be dynamically updated. This is much more efficient than navigating to a new URL, after which the browser downloads and renders the entire page. Although this method of refreshing the whole page is very common today, it is inefficient because the Web page refreshes and re-renders an entire page of content, even if only a small percentage of the page has actually changed. You can probably notice this inefficiency when searching a catalog or a search engine. The delays and waste of resources can be significant.
Next: How to use the WebService Behavior