Programming .NET Web Services

Book description

Web services are poised to become a key technology for a wide range of Internet-enabled applications, spanning everything from straight B2B systems to mobile devices and proprietary in-house software. While there are several tools and platforms that can be used for building web services, developers are finding a powerful tool in Microsoft's .NET Framework and Visual Studio .NET. Designed from scratch to support the development of web services, the .NET Framework simplifies the process--programmers find that tasks that took an hour using the SOAP Toolkit take just minutes.Programming .NET Web Services is a comprehensive tutorial that teaches you the skills needed to develop web services hosted on the .NET platform. Written for experienced programmers, this book takes you beyond the obvious functionality of ASP.NET or Visual Studio .NET to give you a solid foundation in the building blocks of web services, and leads you step-by-step through the process of creating your own.Beginning with a close look at the underlying technologies of web services, including the benefits and limitations, Programming .NET Web Services discusses the unique features of the .NET Framework that make creating web services easier, including the Common Language Runtime (CLR) and the namespaces used in .NET programming. Filled with numerous code examples using the C# language, the book leads you through some of the more challenging issues of web services development, including the use of proxies, marshalling of complex data types, state management, security, performance tuning and cross-platform implementation. The book also covers:

  • Creating and publishing your first web service
  • The UDDI project, tModels and what they mean for web service publishersSecuring web service applications
Written for programmers who are familiar with the .NET Framework and interested in building industrial-strength web services, Programming .NET Web Services is full of practical information and good old-fashioned advice.

Table of contents

  1. Table of Contents
  2. Preface
    1. What This Book Covers
    2. Audience
    3. What You Need to Use This Book
    4. How This Book Is Organized
    5. Conventions Used in This Book
    6. Comments and Questions
    7. Acknowledgments
      1. Alex
      2. Matthew
  3. Understanding Web Services
    1. Why Web Services?
      1. Web-Enabled Applications
      2. What Is a Web Service?
      3. The Roles of Web Services
    2. The Origin of Web Services
      1. A Brief History of Web Services
        1. Sharing code between applications
        2. Sharing code between computers
        3. Sharing code between networks
      2. COM/DCOM
      3. CORBA/IIOP
      4. Java RMI
      5. Problems with Existing Standards
      6. The Promise of .NET Web Services
    3. The .NET Web Service Architecture
      1. The Underlying Technologies
      2. WSDL
      3. SOAP
      4. DISCO
      5. UDDI
    4. Competing Web Service Technologies
    5. Other Technologies
      1. .NET MyServices
      2. .NET Remoting
      3. XML-RPC
      4. Message Queuing
      5. BizTalk Server
  4. Creating ASP.NET Web Services
    1. Creating a Web Service: “Hello, World”
      1. Creating a Web Service with Inline Code
        1. The WebService directive
        2. The using directive: importing .NET namespaces
        3. The namespace keyword
        4. The WebService class
        5. The WebMethod attribute
      2. Creating “Hello, World” with Visual Studio .NET (1/2)
      3. Creating “Hello, World” with Visual Studio .NET (2/2)
        1. Setting up VS.NET for the web service project
        2. Creating a C# web service project
        3. Exploring the solution and project
        4. Exploring the .asmx file and service design view
        5. Displaying all files in Solution Explorer
        6. Understanding the autogenerated service code
        7. Understanding the code-behind model
        8. Building the service
      4. Testing the Service
      5. Viewing the Service Description
      6. Invoking the Web Method
    2. The WebService Attribute
    3. The WebMethod Attribute
      1. The Description and MessageName Properties
      2. The EnableSession Property
      3. The CacheDuration Property
      4. The TransactionOption Property
      5. The BufferedResponse Property
    4. Deploying a Web Service
      1. Deploying a Web Service with VS.NET
        1. FrontPage Extensions and UNC
        2. Locally and remotely hosted projects
        3. VS.NET UNC support
        4. FrontPage and UNC performance
      2. Deploying a Web Service Directly to IIS
        1. Example deployment
    5. Using the .NET Compilers
  5. Consuming Web Services
    1. The Web Service Consumer Model
      1. Publish/Find/Bind Consumer Model
      2. Client/Service Model
    2. Accessing Web Services: HTTP
      1. Internet Information Server (IIS)
      2. Working with HTTP
      3. Using HTTP GET
      4. Using HTTP POST
      5. Using SOAP
      6. Comparing HTTP GET, HTTP POST, and SOAP
    3. Exposing Web Services: WSDL
      1. WSDL Elements
      2. Deconstructing a WSDL Document
    4. Calling Web Services: the Client Proxy
    5. Creating a Client Proxy
      1. Using VS.NET
      2. Using wsdl.exe
      3. Using a Proxy Class
    6. Working with the Proxy Class
      1. WebClientProtocol
      2. HTTPWebClientProtocol
      3. Other Proxy Class Implementations
    7. Consuming a Web Site Using a Screen Scraper Service
      1. Traditional Screen Scraping
      2. Regular Expressions
      3. WSDL Extensions for Regular Expressions
      4. Scraping the Web Service Way
  6. Working with Data Types
    1. Working with Simple Data Types
      1. XML Schema
      2. .NET Primitive Data Types
      3. Structs
      4. Arrays
    2. Working with Complex Data Types
      1. Serialization
      2. Shaping XML Output
      3. Shallow and Deep Serialization
    3. Using Complex Data Types as Arguments
      1. Accepting Complex Types: Service View
      2. Passing Complex Arguments: Consumer View
    4. Passing Data with DataSets
      1. Using a DataSet
      2. Returning Typed and Untyped DataSets
        1. Creating a typed DataSet from the command line
        2. Creating a typed DataSet in VS.NET
    5. Using Binary Data
  7. Managing State
    1. The Great State Debate
      1. Stateless Versus Stateful Design
      2. Web Services and Property Procedures
      3. Transactional Web Services
    2. State Management Scenarios
      1. Thin Layer Design
      2. Stateful Design
      3. Aggregate Design
    3. ASP.NET’s Session State Facility
      1. The Session Cookie
      2. Using Session State
      3. The Items Collection
      4. Accessing Stateful Services
    4. Session State Configuration
      1. Mode
      2. Out-of-Process State Servers
      3. Using a Windows Service for State
      4. Using a SQL Server Database for State
      5. Timeout
      6. Designing Session-Friendly Classes
    5. Example: Managing Session State
    6. Application State
    7. Custom Cookies
    8. Stateless Web Services and Tickets
    9. SOAP Headers
      1. Defining a SOAP Header
      2. The Proxy Class
      3. Using SOAP Headers
        1. Required headers
        2. Output headers
        3. Unknown headers
      4. SOAP Header Issues
  8. Asynchronous Services
    1. Asynchronous Consumption
      1. The BeginInvoke and EndInvoke methods
      2. Polling Asynchronous Requests
      3. Calling Several Methods Simultaneously
      4. Using a WaitHandle
      5. Using Callbacks
      6. Using a Complete Threading Class
    2. Asynchronous Services
      1. OneWay Methods
      2. Asynchronous Services with Components
        1. The Service class
        2. The ServiceMonitor class
        3. Compiling the component
        4. The web service
        5. The client
        6. Threading safely
      3. Other Approaches to Asynchronous Services
  9. Caching and Profiling
    1. ASP.NET Caching
      1. The Purpose of Caching
      2. Testing with Cached Web Services
    2. Simple Output Caching
      1. Disabling the Cache
      2. Candidates for Output Caching
      3. Caching Times
    3. Data Caching
      1. Inserting Items into the Cache
      2. Absolute Expiration Versus Sliding Expiration
      3. Other Cache Members
      4. Cache Priorities
      5. A Simple Data Caching Example
      6. Cloning
    4. Cache Dependencies
      1. Creating File Dependencies
      2. Creating Dependencies on Other Cache Items
      3. The Item Removed Callback
    5. Replacing Stateful Design with Caching
    6. Profiling Your Web Service
      1. The Testing Environment
      2. Performance Counters
      3. Important ASP.NET Counters
  10. Debugging, Tracing, and Logging
    1. Debugging in Visual Studio .NET
      1. Creating a Web Service-Client Solution in VS.NET
      2. Setting Web Service Breakpoints
    2. Using Exceptions
      1. The Message Property
      2. The StackTrace Property
      3. Creating Enlightened Exceptions
    3. Logging Errors with .NET
      1. Logging with the Application Log
      2. Retrieving Logs
      3. Logging by Email
      4. Tracing and Assertions
    4. SOAP Extensions
      1. The SOAP Extension Classes
      2. Creating the SoapExtension Class
      3. Processing the Message
      4. Creating the SoapExtensionAttribute
      5. A Simple Logging Extension
    5. Advanced SOAP Extensions
      1. Initializing Data
      2. The ChainStream() Method
      3. A More Advanced Logging Extension
      4. Proxy Extensions
  11. Security and Authentication
    1. Potential Vulnerabilities
    2. Web Service Authentication
    3. IIS Security Features
      1. User Authentication and Client Certificates
      2. Basic Authentication and SSL
      3. IP Address and Domain Name Restriction
      4. Application Mappings Restrictions
      5. IIS Security Flow
    4. ASP.NET Security
      1. The machine.config and web.config Files
      2. ASP.NET Authentication Providers
      3. Using Windows Authentication in Web Services
        1. Configuring Windows authentication
        2. Restricting access by user and group
        3. Restricting access by HTTP verb
        4. Configuring explicit impersonation
        5. IIS and the Windows authentication provider
      4. Avoiding Forms Authentication
      5. Avoiding Passport Authentication
    5. Programmatic Security
      1. Identities, Roles, and Principals
      2. Understanding the WindowsPrincipal and WindowsIdentity Objects
        1. The WindowsPrincipal object
        2. The WindowsIdentity object
      3. Using the WindowsPrincipal and WindowsIdentity Objects
      4. Impersonation
        1. Programmatic impersonation
        2. Impersonation using security tokens
    6. Custom Authentication Techniques
      1. Designing for Performance and Scalability
      2. Implementing Per-Method Authentication Using SQL
      3. Getting Warmer: a Ticket System
        1. Drawbacks of a ticket system
        2. Opportunities for improvement
      4. En Fuego: a Custom Authentication Provider
    7. Process Security
  12. Publishing and Discovery
    1. Publishing
    2. UDDI
      1. History of UDDI
      2. What Is UDDI?
      3. Why UDDI?
        1. Platform-independence
        2. Open architecture and the freedom to innovate
        3. Wide support
    3. UDDI Business Registries
      1. Registry Contents
      2. Categorization
      3. Accessing a Registry
    4. Registering a Business Entity
      1. The Classification System
    5. WSDL and UDDI
      1. WSDL and the UDDI Data Structures
        1. Abstract and concrete service definitions
        2. The frictionless marketplace
      2. WSDL and tModels
        1. Adding a tModel
      3. Associating a Web Service with Your Business
      4. Associating a Service with a tModel
    6. Visual Studio .NET and UDDI
    7. UDDI Messaging
      1. SOAP and UDDI
      2. The Inquiry API
        1. The browse pattern
        2. The drill-down pattern
        3. The invocation pattern
        4. The bigger picture
      3. The Publish API
    8. UDDI Access with .NET
      1. The .NET UDDI SDK
      2. Using the .NET UDDI SDK
      3. UDDI SDK Usage Patterns
    9. The WS-Inspection Alternative
    10. Customizing the IE Test Page
  13. Interoperability
    1. State of the Specifications
    2. Implementation Differences
      1. SOAP Message Formats
        1. Document style versus RPC style
        2. The SoapDocumentService and SoapRPCService attributes
      2. SOAP Encoding Formats
    3. SOAP Interoperability
      1. Common SOAP Interoperability Issues
      2. SOAP Builders
      3. The SOAP Interoperability Test
    4. WSDL Interoperability
    5. HTTP Interoperability and M-Post
    6. Known Interoperability Problems
      1. Apache SOAP v2.2
        1. SOAP level: SOAPAction header dispatch
        2. XML level: byte order mark (BOM)
        3. SOAP level: xsi:type dependency
        4. Additional potential issues
      2. SOAP::Lite 0.51
      3. MS SOAP Toolkit v3.0
    7. Maximizing Interoperability
  14. Namespace Quick Reference
    1. The System.Web.Services Namespace
      1. WebMethodAttribute
      2. WebService
      3. WebServiceAttribute
      4. WebServiceBindingAttribute
    2. The System.Web.Services.Protocols Namespace
      1. AnyReturnReader
      2. HtmlFormParameterReader
      3. HtmlFormParameterWriter
      4. HttpGetClientProtocol
      5. HttpMethodAttribute
      6. HttpPostClientProtocol
      7. HttpSimpleClientProtocol
      8. HttpWebClientProtocol
      9. LogicalMethodInfo
      10. LogicalMethodTypes
      11. MatchAttribute
      12. MimeFormatter
      13. MimeParameterReader
      14. MimeParameterWriter
      15. MimeReturnReader
      16. NopReturnReader
      17. PatternMatcher
      18. SoapClientMessage
      19. SoapDocumentMethodAttribute
      20. SoapDocumentServiceAttribute
      21. SoapException
      22. SoapExtension
      23. SoapExtensionAttribute
      24. SoapHeader
      25. SoapHeaderAttribute
      26. SoapHeaderCollection
      27. SoapHeaderDirection
      28. SoapHeaderException
      29. SoapHttpClientProtocol
      30. SoapMessage
      31. SoapMessageStage
      32. SoapParameterStyle
      33. SoapRpcMethodAttribute
      34. SoapRpcServiceAttribute
      35. SoapServerMessage
      36. SoapServiceRoutingStyle
      37. SoapUnknownHeader
      38. TextReturnReader
      39. UrlEncodedParameterWriter
      40. UrlParameterReader
      41. UrlParameterWriter
      42. ValueCollectionParameterReader
      43. WebClientAsyncResult
      44. WebClientProtocol
      45. WebServiceHandlerFactory
      46. XmlReturnReader
  15. Web Service Technologies
    1. Transactions
      1. XAML (Transaction Authority Markup Language)
    2. Security
      1. XKMS (XML Key Management Service)
      2. XML Signatures (XML Digital Signatures)
      3. XML Encryption
      4. SOAP Security Extensions
      5. WS-Security
      6. WS-License
    3. Description and Discovery
      1. WSDL
      2. UDDI (Universal Description, Discovery, and Integration)
      3. WS-Inspection
      4. JXTA Search
    4. Routing and Process Flow
      1. WS-Routing
      2. XLANG
      3. WSCL (Web Services Conversation Language)
      4. WSFL (Web Services Flow Language)
    5. Message Encapsulation
      1. DIME (Direct Internet Message Encapsulation)
      2. Jabber
  16. Index (1/4)
  17. Index (2/4)
  18. Index (3/4)
  19. Index (4/4)

Product information

  • Title: Programming .NET Web Services
  • Author(s): Alex Ferrara, Matthew MacDonald
  • Release date: September 2002
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9780596516567