Chapter 7: Creating Web Methods


In Microsoft .NET, the heart of a Web service is its Web methods. Within a Web method, everything that a Web service does is defined. Web methods are the .NET way of specifying which parts of a class are to be exposed as a Web service. In the first four chapters, we looked at the technologies and standards that apply to any Web service, not just those that use .NET as a framework. In Chapter 5, we looked at how some of these standards are implemented in .NET, how to build custom handlers, and which .NET classes are of particular use to the Web services developer. In Chapter 6, we looked at how objects and data are serialized for transmission via a Web service.

With the preliminary work done, it’s time for a detailed look at building Web methods and at what the Microsoft Visual Studio .NET abstraction boils down to underneath. We’ll look at how much control you have over the serializer and how you can customize Web methods using the built-in attributes. (Usually the attributes change some aspect of the service’s .wsdl file.) We’ll also discuss several of these attributes again in later chapters. Last, but not least, we’ll look at how you can debug and deploy your Web service and make it available for discovery.

Building a Web Method

By adding a public WebMethod attribute to your code, you indicate that the code should be exposed as part of your Web service. Six attributes, along with the WebMethod directive, let you modify aspects of your code by allowing you to enable sessions or allowing you to specify how long information is held in the cache. Before we delve into the Web method itself, let’s look at the overall Web services model (which we looked at briefly in Chapter 1 when we built our first example Web service).




Programming Microsoft. NET XML Web Services
Programming MicrosoftВ® .NET XML Web Services (Pro-Developer)
ISBN: 0735619123
EAN: 2147483647
Year: 2005
Pages: 172

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net