0%

Book Description

Build SOA applications on the Microsoft platform in this hands-on guide

  • Master WCF and LINQ concepts by completing practical examples and apply them to your real-world assignments

  • First book to combine WCF and LINQ in a multi-tier real-world WCF service

  • Setting up, managing, and publishing a project

  • Rich with example code, clear explanations, interesting examples, and practical advice – a truly hands-on book for C++ and C# developers

  • In Detail

    WCF is Microsoft's unified programming model for building service-oriented applications. It enables developers to build secure, reliable, transacted solutions that integrate across platforms and interoperate with existing investments. WCF is built on the Microsoft .NET Framework and simplifies development of connected systems. It unifies a broad array of distributed systems capabilities in a composable, extensible architecture that supports multiple transports, messaging patterns, encodings, network topologies, and hosting models. It is the next version of several existing products: ASP.NET's web methods (ASMX), Microsoft Web Services Enhancements for Microsoft .NET (WSE), .NET Remoting, Enterprise Services, and System.Messaging.

    If you are a C++/C# developer looking for a book to build real-world WCF services, you would have run into the huge reference tomes currently in the market. These books are crammed with more information than you need and most build simple one-tier WCF services. And if you plan to use LINQ in the data access layer, you might buy another volume that is just as huge and just as expensive.

    Our book is the quickest and easiest way to learn WCF and LINQ in Visual Studio 2008. It is the first book to combine WCF and LINQ in a multi-tier real-world WCF service. Multi-tier services provide separation of concerns and better factoring of code, which gives you better maintainability and the ability to split layers out into separate tiers for scalability. WCF and LINQ are both powerful yet complex technologies from Microsoft, but this book will get you through. The mastery of these two topics will quickly get you started creating service-oriented applications, and allow you to take your first steps into the world of Service Oriented Architecture without getting overwhelmed.

    Through this book, you will first understand WCF concepts by developing a functional service and apply these techniques to a multi-tier real-world WCF service. You will learn how to use WCF to define the contracts in the service interface layer, Plain Old C# Objects (POCO) to implement business rules in the business logic layer, and LINQ to communicate with the databases in the data access layer. Microsoft pattern and practice Web Service Software Factory is used to create the framework for this WCF service. Concurrency control and distributed transaction support are discussed and tested at the end of the book. Clear step-by-step instructions and precise screenshots will make sure you will not get lost in the new world of WCF and LINQ.

    Table of Contents

    1. WCF Multi-tier Services Development with LINQ
      1. WCF Multi-tier Services Development with LINQ
      2. Credits
      3. About the Author
      4. About the Reviewers
      5. Preface
        1. What This Book Covers
        2. What You Need for This Book
        3. Who is This Book For
        4. Conventions
        5. Reader Feedback
        6. Customer Support
          1. Downloading the Example Code for the Book
          2. Errata
          3. Piracy
          4. Questions
      6. 1. SOA Service Oriented Architecture
        1. What is SOA?
        2. Why SOA?
        3. How do we implement SOA?
        4. SOA from different users' perspectives
        5. Complexities in SOA implementation
        6. Web services
          1. What is a web service?
          2. Web service WSDL
          3. Web service proxy
          4. SOAP
        7. Web services: standards and specifications
          1. WS-I Profiles
          2. WS-Addressing
          3. WS-Security
          4. WS-ReliableMessaging
          5. WS-Coordination and WS-Transaction
        8. Summary
      7. 2. WCF Windows Communication Foundation
        1. What is WCF?
        2. Why is WCF used for SOA?
        3. WCF architecture
        4. Basic WCF concepts WCF ABCs
          1. Address
          2. Binding
          3. Contract
            1. Service contract
            2. Operation contract
            3. Message contract
            4. Data contract
            5. Fault contract
          4. Endpoint
          5. Behavior
          6. Hosting
            1. Self hosting
            2. Windows services hosting
            3. IIS hosting
            4. Windows Activation Services hosting
          7. Channels
          8. Metadata
        5. WCF production and development environments
        6. Summary
      8. 3. Implementing a Basic HelloWorld WCF Service
        1. Creating the HelloWorld solution and project
        2. Creating the HelloWorldService service contract interface
        3. Implementing the HelloWorldService service contract
        4. Hosting the WCF service in ASP.NET Development Server
          1. Creating the host application
          2. Testing the host application
          3. ASP.NET Development Server
          4. Adding an svc file to the host application
          5. Adding a web.config file to the host application
          6. Starting the host application
        5. Creating a client to consume the WCF service
          1. Creating the client application project
          2. Generating the proxy and configuration files
          3. Customizing the client application
          4. Running the client application
          5. Setting the service application to AutoStart
        6. Summary
      9. 4. Hosting and Debugging the HelloWorld WCF Service
        1. Hosting the HelloWorld WCF service
          1. Hosting the service in a managed application
            1. Hosting the service in a console application
            2. Consuming the service hosted in a console application
          2. Hosting the service in a Windows service
          3. Hosting the service in the Internet Information Server
            1. Preparing the folders and files
            2. Creating the virtual directory
            3. Starting the WCF service in the IIS
            4. Testing the WCF service hosted in the IIS
          4. Advanced WCF service hosting options
        2. Debugging the HelloWorld WCF service
          1. Debugging from the client application
            1. Starting the debugging process
            2. Debugging on the client application
            3. Enabling debugging of the WCF service
            4. Stepping into the WCF service
          2. Debugging only the WCF service
            1. Starting the WCF Service in debugging mode
            2. Starting the client application in non-debugging mode
            3. Starting the WCF service and client applications in debugging mode
          3. Attaching to a WCF service process
            1. Running the WCF service and client applications in non-debugging mode
            2. Debugging the WCF service hosted in IIS
          4. Just-In-Time debugger
        3. Summary
      10. 5. Implementing a WCF Service in the Real World
        1. Why layering a service?
        2. Creating a new solution and project using WCF templates
          1. Using the C# WCF service library template
          2. Using the C# WCF service application template
        3. Creating the service interface layer
          1. Creating the service interfaces
          2. Creating the data contracts
          3. Implementing the service contracts
            1. Modifying the app.config file
            2. Testing the service using WCF Test Client
            3. Testing the service using our own client
          4. Adding a business logic layer
            1. Adding the product entity project
            2. Adding the business logic project
            3. Calling the business logic layer from the service interface layer
            4. Testing the WCF service with a business logic layer
        4. Summary
      11. 6. Adding Database Support and Exception Handling to the RealNorthwind WCF Service
        1. Adding a data access layer
          1. Creating the data access layer project
          2. Calling the data access layer from the business logic layer
          3. Preparing the database
          4. Adding the connection string to the configuration file
          5. Querying the database (GetProduct)
          6. Testing the GetProduct method
          7. Updating the database (UpdateProduct)
        2. Adding error handling to the service
          1. Adding a fault contract
          2. Throwing a fault exception
          3. Updating client program to catch the fault exception
          4. Disabling the Just My Code debugging option
          5. Testing the fault exception
        3. Summary
      12. 7. Modeling a WCF Service with Service Factory
        1. What is the Service Factory?
        2. What are Guidance Packages?
        3. Preparing environments
          1. Installing Guidance Automation packages
          2. Installing Microsoft Service Software Factory
        4. Differences between the December 2006 version and the February 2008 version
        5. Modeling the data contracts
          1. Creating the solution
          2. Adding the data contract model
          3. Adding the product data contract
          4. Adding the product fault contract
        6. Modeling the service contracts
          1. Adding the ProductService contract model
          2. Adding the GetProduct operation
          3. Adding the message contracts
          4. Adding the service contracts
          5. Adding the connectors
        7. Specifying the implementation technology for the models
          1. Choosing the implementation technology for service contract model
          2. Changing the property values for service contracts
          3. Choosing the implementation technology for the data contract model
          4. Changing the order property for data members
        8. Generating source code
          1. Creating the service projects
          2. Linking contract models to projects
          3. Validating the contract models
          4. Generating the source code
        9. Summary
      13. 8. Implementing the WCF Service with Service Factory
        1. Creating the business entities
        2. Customizing the data access layer
          1. Adding the connection strings
          2. Adding a reference to the BusinessEntities project
          3. Adding the data access class
        3. Customizing the business logic
        4. Translating the messages
        5. Customizing the Fault contract
        6. Customizing the product service
        7. Modeling the host application and the test client
          1. Modeling the host application
          2. Generating the host application
          3. Adding the test client to the host model
          4. Generating the client proxy
        8. Customizing the client
        9. Testing the service
        10. Summary
      14. 9. Introducing Language-Integrated Query (LINQ)
        1. What is LINQ
        2. Creating the test solution and project
        3. New data type var
        4. Automatic properties
        5. Object initializer
        6. Collection initializer
        7. Anonymous types
        8. Extension methods
        9. Lambda expressions
        10. Built-in LINQ extension methods and method syntax
        11. LINQ query syntax and query expression
        12. Built-in LINQ operators
        13. Summary
      15. 10. LINQ to SQL: Basic Concepts and Features
        1. ORM Object-Relational Mapping
          1. LINQ to SQL
        2. Comparing LINQ to SQL with LINQ to Objects
        3. LINQ to Entities
        4. Comparing LINQ to SQL with LINQ to Entities
        5. Creating LINQ to SQL test application
        6. Modeling the Northwind database
          1. Adding a LINQ to SQL item to the project
          2. Connecting to the Northwind database
          3. Adding tables and views to the design surface
          4. Generated LINQ to SQL classes
        7. Querying and updating the database with a table
          1. Querying records
          2. Updating records
          3. Inserting records
          4. Deleting records
          5. Running the program
        8. Deferred execution
          1. Checking deferred execution with SQL profiler
          2. Checking deferred execution with SQL logs
          3. Deferred execution for singleton methods
          4. Deferred execution for singleton methods within sequence expressions
        9. Deferred (lazy) loading versus eager loading
          1. Lazy loading by default
          2. Eager loading with load options
          3. Filtered loading with load options
          4. Combining eager loading and filtered loading
        10. Joining two tables
        11. Querying a view
        12. Summary
      16. 11. LINQ to SQL: Advanced Concepts and Features
        1. Calling a stored procedure
          1. Calling a simple stored procedure
          2. Mapping a stored procedure to an entity class
          3. Handling output parameters, return codes, multiple shapes of a single result-set, and multiple result-sets
            1. Creating a complex stored procedure
            2. Modeling the stored procedure
            3. Customizing DataContext class for the stored procedure
            4. Testing the stored procedure
        2. Compiled query
        3. Direct SQL
        4. Dynamic query
        5. Inheritance
          1. LINQ to SQL single-table inheritance
            1. LINQ to SQL single-table inheritance
            2. Modeling the BaseProduct and Beverage classes
            3. Modeling the Seafood class
            4. The generated classes with inheritance
            5. Testing the inheritance
        6. Handling simultaneous (concurrent) updates
          1. Detecting conflicts using the Update Check property
            1. Writing the test code
            2. Testing the conflicts
          2. Detecting conflicts using a version column
            1. Adding a version column
            2. Modeling the products table with a version column
            3. Writing the test code
            4. Testing the conflicts
        7. Transactions support
          1. Implicit transactions
          2. Explicit transactions
          3. Participating in existing ADO.NET transactions
        8. Adding validations to entity classes
        9. Debugging LINQ to SQL programs
        10. Summary
      17. 12. Applying LINQ to SQL to a WCF Service
        1. Creating the LINQNorthwind solution
        2. Modeling the data contracts
        3. Modeling the service contracts
        4. Generating the source code
        5. Modeling the Northwind database
        6. Implementing the data access layer
          1. Adding GetProduct to the data access layer
          2. Adding UpdateProduct to the data access layer
        7. Implementing the business logic layer
        8. Implementing the service interface layer
          1. Modifying the ProductFault class
          2. Modifying the DataContract class
          3. Modifying the ServiceImplementation class
            1. Adding references to the project
            2. Adding a translator class
            3. Implementing the GetProduct and UpdateProduct operations
        9. Creating the host application and the test client
          1. Modeling the host application and the test client
          2. Implementing the GetProduct functionality
          3. Implementing the UpdateProduct functionality
        10. Testing the GetProduct and UpdateProduct operations
        11. Testing concurrent update manually
        12. Testing concurrent update automatically
        13. Summary
      18. 13. Distributed Transaction Support of WCF
        1. Creating the DistNorthwind solution
        2. Testing the transaction behaviour of the WCF service
          1. Creating a client to call the WCF service sequentially
          2. Testing the sequential calls to the WCF service
          3. Wrapping the WCF service calls in one transaction scope
          4. Testing multiple database support of the WCF service
            1. Modifying the data access layer for the second database support
            2. Modifying the business logic layer for the second database support
            3. Modifying the service interface layer for the second database support
            4. Modifying the service host for the second database support
            5. Modifying the client for the second database support
            6. Testing the WCF service with two databases
        3. Enabling distributed transaction support
          1. Enabling transaction flow in bindings
            1. Enabling transaction flow on the service application
            2. Enabling transaction flow on the client application
          2. Modifying the service operation contract to allow a transaction flow
          3. Modifying the service operation implementation to require a transaction scope
        4. Understanding distributed transaction support of a WCF service
        5. Testing the distributed transaction support of the WCF service
          1. Propagating a transaction from client to the WCF service
          2. Configuring the Distributed Transaction Coordinator
          3. Configuring the firewall
        6. Summary