Web Resources

Answers to Self Review Exercises


a) False. Web services are used to execute methods on remote machines. The Web service receives the arguments it needs to execute a particular method, executes the method and returns the result to the caller. b) False. The proxy is created by Visual C# or Visual Web Developer when you add the Web reference. The proxy class itself is hidden from you. c) True. d) True. e) False. A CookieContainer also must be created on the client side if the client is not a Web browser. f) True. g) True.


a) SOAP message or SOAP envelope. b) System.Web.Services.WebService. c) code-behind. d) HTTP. e) Description. f) XML serialization. g) domain.



(Phone Book Web Service) Create a Web service that stores phone book entries in a database (PhoneBook.mdf, which is provided in the examples directory for this chapter) and a client application that consumes this service. Give the client user the capability to enter a new contact (Web method AddEntry) and to find contacts by last name (Web method GetEnTRies). Pass only simple types as arguments to the Web service. Add a DataSet to the Web service project to enable the Web service to interact with the database. The GetEnTRies Web method should return an array of strings that contains the matching phone book entries. Each string in the array should consist of the last name, first name and phone number for one phone book entry. When configuring the PhoneBookDataSetTableAdapters.PhoneBookTableAdapter that provides access to the PhoneBook.mdf database, first set up the SELECT query that will be used by the GetEntries Web method. Then, when you add the INSERT statement to the TableAdapter, the TableAdapter Configuration Wizard will preconfigure the INSERT statement for you. You will simply need to name the PhoneBookDataSetTableAdapters.PhoneBookTableAdapter method that will perform the INSERT operation. The SELECT query that will find a phone book entry by last name should be:

SELECT LastName, FirstName, PhoneNumber
FROM PhoneBook
WHERE (LastName = @lastName)

The INSERT statement that inserts a new entry into the PhoneBook.mdf database should be:

INSERT INTO [PhoneBook] ([LastName], [FirstName], [PhoneNumber])
VALUES (@LastName, @FirstName, @PhoneNumber)

[Note: The TableAdapter Configuration Wizard adds the square brackets around each table name and column name by default when it configures the INSERT statement.]


(Phone Book Web Service Modification) Modify Exercise 22.3 so that it uses a class named PhoneBookEntry to represent a row in the database. The client application should provide objects of type PhoneBookEntry to the Web service when adding contacts and should receive objects of type PhoneBookEntry when searching for contacts.


(Blackjack Web Service Modification) Modify the blackjack Web service example in Section 22.5 to include class Card. Change Web method DealCard so that it returns an object of type Card. Also modify the client application to keep track of what cards have been dealt by using Card objects. Your Card class should include properties to determine the face and suit of the card.


(Airline Reservation Web Service Modification) Modify the airline reservation Web service in Section 22.6 so that it contains two separate Web methodsone that allows users to view all available seats, and another that allows users to reserve a particular seat that is currently available. Use an object of type Ticket to pass information to and from the Web service. The Web service must be able to handle cases in which two users view available seats, one reserves a seat and the second user tries to reserve the same seat, not knowing that it is now taken. To obtain the list of available seats, configure the SeatsTableAdapter with the SELECT query:

SELECT Number, Type, Class
FROM Seats
WHERE (Taken = 0)

The names of the methods that execute this query should be FillWithAvailableSeats and GetAvailableSeats. To determine whether a specific seat is available, add the following SELECT query to the SeatsTableAdapter:

FROM Seats
WHERE (Number = @number) AND (Taken = 0)

The names of the methods that execute this query should be FillWithSpecificSeat and GetSpecificSeat. Finally, to reserve a specific seat, add the following UPDATE to the SeatsTableAdapter:

SET Taken = 1
WHERE (Number = @number) AND (Taken = 0)

The name of the method that executes this UPDATE should be UpdateSeatAsTaken.



    Introduction to Computers, the Internet and Visual C#

    Introduction to the Visual C# 2005 Express Edition IDE

    Introduction to C# Applications

    Introduction to Classes and Objects

    Control Statements: Part 1

    Control Statements: Part 2

    Methods: A Deeper Look


    Classes and Objects: A Deeper Look

    Object-Oriented Programming: Inheritance

    Polymorphism, Interfaces & Operator Overloading

    Exception Handling

    Graphical User Interface Concepts: Part 1

    Graphical User Interface Concepts: Part 2


    Strings, Characters and Regular Expressions

    Graphics and Multimedia

    Files and Streams

    Extensible Markup Language (XML)

    Database, SQL and ADO.NET

    ASP.NET 2.0, Web Forms and Web Controls

    Web Services

    Networking: Streams-Based Sockets and Datagrams

    Searching and Sorting

    Data Structures



    Appendix A. Operator Precedence Chart

    Appendix B. Number Systems

    Appendix C. Using the Visual Studio 2005 Debugger

    Appendix D. ASCII Character Set

    Appendix E. Unicode®

    Appendix F. Introduction to XHTML: Part 1

    Appendix G. Introduction to XHTML: Part 2

    Appendix H. HTML/XHTML Special Characters

    Appendix I. HTML/XHTML Colors

    Appendix J. ATM Case Study Code

    Appendix K. UML 2: Additional Diagram Types

    Appendix L. Simple Types


    Visual C# How to Program
    Visual C# 2005 How to Program (2nd Edition)
    ISBN: 0131525239
    EAN: 2147483647
    Year: 2004
    Pages: 600

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