Building a Web Services Conduit (Continued)
You can display reviews for a book by accessing the Reviews property of the ProductInfo object. This property will always be Null when the type of Web service call is set to "lite" (see the type property in Listings 1 and 2). To get reviews, you must set the type property of the AsinRequest or AuthorRequest objects to "heavy."
The Reviews property represents an object that allows you to access the average customer review for a book as well as details for each customer review. Listing 6 shows how to handle adding a reviews section into the User Control. Several comments have been added to the code to explain what each part of the code is doing.
You can see a portion of the output generated by the User Control from calling the Amazon.com Web service that includes book details, other books by the lead author, and reviews (see Figure 4). To view a live sample that consumes the Amazon.com Web service, visit the XML for ASP.NET Developers home page and click on a book, or visit www.xmlforasp.net/codeSection.aspx?csID=76.
If you want, you can also access the service using HTTP and XML. However, this example shows that Web services along with SOAP provide a great way to share data between distributed systems without being forced to abandon object-oriented programming techniques. Without them, accessing Amazon.com data would be more difficult (although certainly not impossible). With them, the sky's the limit.
About the Author
Dan Wahlin (Microsoft MVP—ASP.NET) is president of Wahlin Consulting LLC and founded the XML for ASP.NET Developers Web site (www.XMLforASP.NET), which focuses on using XML and Web services in Microsoft's .Net platform. He is also a corporate trainer and speaker and teaches public and on-site XML and .NET training courses around the United States. Dan coauthored Professional Windows DNA (Wrox), ASP.NET Tips, Tutorials, and Code (Sams), and authored XML for ASP.NET Developers (Sams). Reach Dan at .
Back to top
|