Chapter 18. XML Web Services

 < Day Day Up > 

Topics in This Chapter

  • Web Service Overview: The popularity of Web Services stems from the fact that they are implemented using the non-proprietary technologies of HTTP, XML, and SOAP. For them to become truly useful, users must have a way to locate them on the Internet. UDDI offers one such discovery service.

  • Creating a Web Service: In C#, a Web Service is created by implementing a method that is exposed to clients across the Internet. To indicate a method is available, a WebService directive is required on the Web page, and a WebMethod attribute is attached to the Web Service method.

  • Building an XML Web Service Client: The easiest way to create a Web Service client is to build a proxy using the Web Services Description Language (WSDL) provided by the Web Service. The proxy handles the physical connection to the Web Service and provides asynchronous and synchronous access.

  • WSDL and SOAP: WSDL provides the information that describes a Web Service; Simple Object Access Protocol (SOAP) is the format in which the requests and responses are delivered. An understanding of both offers added insight into how Web Services operate.

  • Web Service Examples: To satisfy real-world business needs, Web Services must deliver more than simple data types. Examples in this section show how to build a service that delivers images and how to build a client to retrieve datasets from the publicly available Amazon Web Services.

XML Web Services provide a relatively simple technique for accessing a method on an object that is running on a local or remote computer. Many embrace this lightweight approach to making Remote Procedure Calls (RPC) as technology that will spell the end to much heavier and complex solutions for distributed communications such as DCOM and CORBA. At the root of its appeal is the fact that Web Services are based on standardized technologies such as HTTP and XML that are designed to promote seamless interoperability among different operating systems. Not everyone is sold on them. Critics point out the lack of security standards, the heavy bandwidth requirements of XML, and the lack of notification and transaction services.

The chapter takes a practical look at the pluses and minuses of implementing and consuming Web Services in a .NET environment. It presents Web Services from the perspective of both the server and client. On the server side, the chapter explores how to define a Web Services class, make its methods available to HTTP clients, and access the ASP.NET Application and Session objects. The emphasis on the client side is how to use the Web Services Description Language (WSDL) contract to create a proxy class that implement calls to the Web Service.

HTTP and SOAP a protocol that codifies how XML is used to package the request and response data that comprise a Web Service operation are the two cornerstones of Web Services. Other protocols such as GET and POST are available, but the Simple Object Access Protocol (SOAP) has fewer limitations and is used in the majority of real-world applications. This chapter takes a look at the SOAP format as well as several issues related to SOAP, including the handling of complex data types, exception handling, and security.

We begin the exploration of the .NET Web Services architecture by creating a simple Web Service and Web Service consumer. Our first examples are created "by hand" to emphasize the underlying principles. After these are understood, we see how Visual Studio.NET simplifies the development. The chapter also demonstrates how to use the wsdl.exe tool and .NET classes that are integral to the development process. Closing out the chapter is a sample application to access the Amazon Web Services.

     < Day Day Up > 

    Core C# and  .NET
    Core C# and .NET
    ISBN: 131472275
    EAN: N/A
    Year: 2005
    Pages: 219 © 2008-2017.
    If you may any questions please contact us: