- •About the Authors
- •Contents at a Glance
- •Contents
- •Introduction
- •Goal of the Book
- •How to Use this Book
- •Introduction to the .NET Framework
- •Common Language Runtime (CLR)
- •Class Library
- •Assembly
- •Versioning
- •Exceptions
- •Threads
- •Delegates
- •Summary
- •Introduction to C#
- •Variables
- •Initializing Variables
- •Variable Modifiers
- •Variable Data Types
- •Types of Variables
- •Variable Scope
- •Types of Data Type Casting
- •Arrays
- •Strings
- •Initializing Strings
- •Working with Strings
- •Statements and Expressions
- •Types of Statements
- •Expressions
- •Summary
- •Classes
- •Declaring Classes
- •Inheritance
- •Constructors
- •Destructors
- •Methods
- •Declaring a Method
- •Calling a Method
- •Passing Parameters to Methods
- •Method Modifiers
- •Overloading a Method
- •Namespaces
- •Declaring Namespaces
- •Aliases
- •Structs
- •Enumerations
- •Interfaces
- •Writing, Compiling, and Executing
- •Writing a C# Program
- •Compiling a C# Program
- •Executing a C# Program
- •Summary
- •Arrays
- •Single-Dimensional Arrays
- •Multidimensional Arrays
- •Methods in Arrays
- •Collections
- •Creating Collections
- •Working with Collections
- •Indexers
- •Boxing and Unboxing
- •Preprocessor Directives
- •Summary
- •Attributes
- •Declaring Attributes
- •Attribute Class
- •Attribute Parameters
- •Default Attributes
- •Properties
- •Declaring Properties
- •Accessors
- •Types of Properties
- •Summary
- •Introduction to Threads
- •Creating Threads
- •Aborting Threads
- •Joining Threads
- •Suspending Threads
- •Making Threads Sleep
- •Thread States
- •Thread Priorities
- •Synchronization
- •Summary
- •Case Study
- •Project Life Cycle
- •Analyzing Requirements
- •High-Level Design
- •Primary and Foreign Keys
- •Referential Integrity
- •Normalization
- •Designing a Database
- •Low-Level Design
- •Construction
- •Integration and Testing
- •User Acceptance Testing
- •Implementation
- •Operations and Maintenance
- •Summary
- •Creating a New Project
- •Console Application
- •Windows Applications
- •Creating a Windows Application for the Customer Maintenance Project
- •Creating an Interface for Form1
- •Creating an Interface for WorkerForm
- •Creating an Interface for CustomerForm
- •Creating an Interface for ReportsForm
- •Creating an Interface for JobDetailsForm
- •Summary
- •Performing Validations
- •Identifying the Validation Mechanism
- •Using the ErrorProvider Control
- •Handling Exceptions
- •Using the try and catch Statements
- •Using the Debug and Trace Classes
- •Using the Debugging Features of Visual Studio .NET
- •Using the Task List
- •Summary
- •Creating Form1
- •Connecting WorkerForm to the Workers Table
- •Connecting CustomerForm to the tblCustomer Table
- •Connecting the JobDetails Form
- •to the tblJobDetails Table
- •Summary
- •Introduction to the Crystal Reports Designer Tool
- •Creating the Reports Form
- •Creating Crystal Reports
- •Creating the Windows Forms Viewer Control
- •Creating the Monthly Worker Report
- •Summary
- •Introduction to Deploying a Windows Application
- •Deployment Projects Available in Visual Studio .NET
- •Deployment Project Editors
- •Summary
- •Case Study
- •Project Life Cycle
- •Analyzing Requirements
- •High-Level Design
- •Low-Level Design
- •Summary
- •Populating the TreeView Control
- •Displaying Employee Codes in the TreeView Control
- •Event Handling
- •Displaying Employee Details in the ListView Control
- •Summary
- •Case Study
- •Project Life Cycle
- •Analyzing Requirements
- •High-Level Design
- •Low-Level Design
- •Summary
- •Adding the Programming Logic to the Application
- •Adding Code to the Form Load() Method
- •Adding Code to the OK Button
- •Adding Code to the Exit Button
- •Summary
- •The Created Event
- •Adding Code to the Created Event
- •Overview of XML
- •The XmlReader Class
- •The XmlWriter Class
- •Displaying Data in an XML Document
- •Displaying an Error Message in the Event Log
- •Displaying Event Entries from Event Viewer
- •Displaying Data from the Summary.xml Document in a Message Box
- •Summary
- •Airline Profile
- •Role of a Business Manager
- •Role of a Network Administrator
- •Role of a Line-of-Business Executive
- •Project Requirements
- •Creation and Deletion of User Accounts
- •Addition of Flight Details
- •Reservations
- •Cancellations
- •Query of Status
- •Confirmation of Tickets
- •Creation of Reports
- •Launch of Frequent Flier Programs
- •Summarizing the Tasks
- •Project Design
- •Database Design
- •Web Forms Design
- •Enabling Security with the Directory Structure
- •Summary
- •Getting Started with ASP.NET
- •Prerequisites for ASP.NET Applications
- •New Features in ASP.NET
- •Types of ASP.NET Applications
- •Exploring ASP.NET Web Applications
- •Introducing Web Forms
- •Web Form Server Controls
- •Configuring ASP.NET Applications
- •Configuring Security for ASP.NET Applications
- •Deploying ASP.NET Applications
- •Creating a Sample ASP.NET Application
- •Creating a New Project
- •Adding Controls to the Project
- •Coding the Application
- •Summary
- •Creating the Database Schema
- •Creating Database Tables
- •Managing Primary Keys and Relationships
- •Viewing the Database Schema
- •Designing Application Forms
- •Standardizing the Interface of the Application
- •Common Forms in the Application
- •Forms for Network Administrators
- •Forms for Business Managers
- •Forms for Line-of-Business Executives
- •Summary
- •The Default.aspx Form
- •The Logoff.aspx Form
- •The ManageUsers.aspx Form
- •The ManageDatabases.aspx Form
- •The ChangePassword.aspx Form
- •Restricting Access to Web Forms
- •The AddFl.aspx Form
- •The RequestID.aspx Form
- •The Reports.aspx Form
- •The FreqFl.aspx Form
- •Coding the Forms for LOB Executives
- •The CreateRes.aspx Form
- •The CancelRes.aspx Form
- •The QueryStat.aspx Form
- •The ConfirmRes.aspx Form
- •Summary
- •Designing the Form
- •The View New Flights Option
- •The View Ticket Status Option
- •The View Flight Status Option
- •The Confirm Reservation Option
- •Testing the Application
- •Summary
- •Locating Errors in Programs
- •Watch Window
- •Locals Window
- •Call Stack Window
- •Autos Window
- •Command Window
- •Testing the Application
- •Summary
- •Managing the Databases
- •Backing Up the SkyShark Airlines Databases
- •Exporting Data from Databases
- •Examining Database Logs
- •Scheduling Database Maintenance Tasks
- •Managing Internet Information Server
- •Configuring IIS Error Pages
- •Managing Web Server Log Files
- •Summary
- •Authentication Mechanisms
- •Securing a Web Site with IIS and ASP.NET
- •Configuring IIS Authentication
- •Configuring Authentication in ASP.NET
- •Securing SQL Server
- •Summary
- •Deployment Scenarios
- •Deployment Editors
- •Creating a Deployment Project
- •Adding the Output of SkySharkDeploy to the Deployment Project
- •Deploying the Project to a Web Server on Another Computer
- •Summary
- •Organization Profile
- •Project Requirements
- •Querying for Information about All Books
- •Querying for Information about Books Based on Criteria
- •Ordering a Book on the Web Site
- •Project Design
- •Database Design
- •Database Schema
- •Web Forms Design
- •Flowcharts for the Web Forms Modules
- •Summary
- •Introduction to ASP.NET Web Services
- •Web Service Architecture
- •Working of a Web Service
- •Technologies Used in Web Services
- •XML in a Web Service
- •WSDL in a Web Service
- •SOAP in a Web Service
- •UDDI in a Web Service
- •Web Services in the .NET Framework
- •The Default Code Generated for a Web Service
- •Testing the SampleWebService Web Service
- •Summary
- •Creating the SearchAll() Web Method
- •Creating the SrchISBN() Web Method
- •Creating the AcceptDetails() Web Method
- •Creating the GenerateOrder() Web Method
- •Testing the Web Service
- •Securing a Web Service
- •Summary
- •Creating the Web Forms for the Bookers Paradise Web Site
- •Adding Code to the Web Forms
- •Summary
- •Case Study
- •Project Life Cycle
- •Analyzing Requirements
- •High-Level Design
- •Low-Level Design
- •Summary
- •Overview of Mobile Applications
- •The Microsoft Mobile Internet Toolkit
- •Overview of WAP
- •The WAP Architecture
- •Overview of WML
- •The Mobile Web Form
- •The Design of the MobileTimeRetriever Application
- •Creating the Interface for the Mobile Web Forms
- •Adding Code to the MobileTimeRetriever Application
- •Summary
- •Creating the Forms Required for the MobileCallStatus Application
- •Creating the frmLogon Form
- •Creating the frmSelectOption Form
- •Creating the frmPending Form
- •Creating the frmUnattended Form
- •Adding Code to the Submit Button in the frmLogon Form
- •Adding Code to the Query Button in the frmSelectOption Form
- •Adding Code to the Mark checked as complete Button in the frmPending Form
- •Adding Code to the Back Button in the frmPending Form
- •Adding Code to the Accept checked call(s) Button in the frmUnattended Form
- •Adding Code to the Back Button in the frmUnattended Form
- •Summary
- •What Is COM?
- •Windows DNA
- •Microsoft Transaction Server (MTS)
- •.NET Interoperability
- •COM Interoperability
- •Messaging
- •Benefits of Message Queues
- •Limitations
- •Key Messaging Terms
- •Summary
- •Pointers
- •Declaring Pointers
- •Types of Code
- •Implementing Pointers
- •Using Pointers with Managed Code
- •Working with Pointers
- •Compiling Unsafe Code
- •Summary
- •Introduction to the Languages of Visual Studio .NET
- •Visual C# .NET
- •Visual Basic .NET
- •Visual C++ .NET
- •Overview of Visual Basic .NET
- •Abstraction
- •Encapsulation
- •Inheritance
- •Polymorphism
- •Components of Visual Basic .NET
- •Variables
- •Constants
- •Operators
- •Arrays
- •Collections
- •Procedures
- •Arguments
- •Functions
- •Adding Code to the Submit Button
- •Adding Code to the Exit Button
- •Summary
- •Introduction to Visual Studio .NET IDE
- •Menu Bar
- •Toolbars
- •Visual Studio .NET IDE Windows
- •Toolbox
- •The Task List Window
- •Managing Windows
- •Customizing Visual Studio .NET IDE
- •The Options Dialog Box
- •The Customize Dialog Box
- •Summary
- •Index
EXPLORING ASP.NET WEB SERVICES |
Chapter 28 |
621 |
|
|
|
|
|
Introduction to ASP.NET Web Services
You were introduced to Web services in Chapter 1, “Overview of the .NET Framework,” in the section “Introduction to the .NET Framework.” In this chapter, I will discuss Web services in detail.
As discussed earlier, a Web service is used to integrate different applications that access data through the Internet. To do this, methods in a Web service are called over the Internet, which can then be accessed by applications developed on different platforms.This implies that a Web service is a reusable component, such as a method, that can be used by any Web application running on the Internet. In addition, a Web service can be used by a Windows application.These applications are called Web service client applications.
Before developing Web services, DLL (Dynamic Link Library) files or components were used to create distributed applications.However, to communicate with a client application, these components use protocols such as RPC (Remote Procedure Call ), DCOM (Distributed Component Object Model ), RMI (Remote Method Invocation), or IIOP (Internet Inter-ORB Protocol ). Therefore, communication between a client application and a component depends on various factors, such as hardware platform, programming languages, vendor implementations, and dataencryption schemes.This implies that transferring data between two applications requires a similar infrastructure at the two application sites. However, this scenario cannot be obtained while working with Internet applications. An Internet application can be accessed by various client applications.Therefore, it is essential to build components that can be used to create distributed applications that can be accessed from various platforms. To do this, you can use Web services. Web services allow you to create platform independent distributed applications. The ability to create distributed applications that are independent of the platform is mainly due to the support of a Web service for Internet standards, such as HTTP and XML.
In addition to integrating applications built on different platforms, a Web service allows you to integrate business solutions for one or more organizations. You can create a Web service specific for your organization or customize a Web service created by another organization to your specific requirements. You can also create a Web service that can be used by a single application or be called on the Internet to be used by multiple applications. To call a Web service from the Internet, the
622 Project 5 CREATING A WEB PORTAL FOR A BOOKSTORE
Web service client needs to know the location of the Web service and the input and output information required for accessing the Web service.
A Web service that you create can be a simple one-method service. For example, consider a situation in which you want to know the current time in a particular state. In this case, you can create a method in a Web service that returns the current time in the state that you choose. You can pass the state for which you want to know the current time as a parameter to the method. The method created in a Web service is called a Web method. You will learn to about Web methods in detail later in this chapter.
In addition to performing simple tasks by using a Web service method, you can create Web methods that perform complex tasks. In such cases, a Web service may consist of several Web methods performing complex tasks. For example, consider a situation in which you need to validate the username and password entered by a user to log on to a site.This is a very common scenario, as almost all Web sites require a method to validate the username and password. Therefore, in such a case, you can create a Web service that performs data validations. In addition, the Web service that you create can be used to validate data for various Web sites. You can then customize the Web service according the requirements based on your database schema. In this case, the Web site that uses the Web service to perform data validations is called a Web service client application, and the application that hosts the Web service is called a Web service provider application.
The data validation scenario that I discussed involves various applications and an underlying database. For example, the Web site that needs to perform data validation is a Web application, which interacts with a database. The database may be created using SQL, Access, Oracle, or any other RDBMS (Relational Database Management System). In addition, for the Web application to perform validations based on the data in the database, the Web application uses another application. In this case, another application required to perform validations is a Web service. Therefore, as you can see, multiple applications are involved in a complete business solution. To integrate these applications, a Web service can be used. The next sections will show how a Web service can provide integration of multiple applications.
A Web service uses XML and any other Internet standard, such as HTTP, to create an infrastructure that helps you to integrate applications build on multiple platforms. Because of the support of Web services for XML, these Web services are often referred to as XML Web services.
EXPLORING ASP.NET WEB SERVICES |
Chapter 28 |
623 |
|
|
|
|
|
An XML Web service uses SOAP messaging to communicate and transfer data across applications. In addition, SOAP messaging allows a great deal of abstraction between a Web service client and a Web service provider. This implies that using the XML messaging technique allows you to create a client and a service provider independent of each other.
By now, you must have got an idea of the need for a Web service. I will now discuss the architecture of a Web service.
Web Service Architecture
As discussed earlier, a Web service can be an intermediate application that allows a Web service client application to access data from an underlying database. To do this, the Web service architecture internally consists of four layers.These layers are explained in the following bulleted list.
The data layer. The data layer is the first layer in the Web service architecture. This layer contains the data that the Web client application needs to access.
The data access layer. The layer above the data layer is the data access layer. The data access layer contains the business logic or the code that allows the Web client application to access the data in the data layer. In addition to storing data, the data access layer is used to secure the data present in the data layer.
The business layer. The third layer in the Web service architecture is the business layer. This layer contains the code required for implementing the Web service. The business layer in turn is divided into business logic and business façade layers.The business logic layer contains all the services provided in a Web service. However, the business façade layer acts as an interface of the Web service.
The listener layer. The layer closest to the Web service client is the listener layer. It is the main layer used by the Web service client to communicate with the Web service. When a Web service client wants to access a Web method present in a Web service, the Web service client sends in a request. This request is received by the listener layer. The listener layer then interprets the request sent by the Web service client application. When the client request is processed and the Web service returns the response in the form of an XML message, the listener layer forwards this XML message to the Web service client.
624 Project 5 CREATING A WEB PORTAL FOR A BOOKSTORE
The Web service architecture is explained in Figure 28-1.
FIGURE 28-1 The Web service architecture
After discussing the four-layered structure of a Web service, I will look at the working of the Web service based on the Web service architecture.
Working of a Web Service
The working of a Web service involves the client application sending a request for a service. The request made to the Web service is in the form of an XML message using a transfer protocol, such as HTTP. This scenario is somewhat similar to a method call statement that you use to call a particular method. The request for the service is passed to the listener layer, which forwards the request to the Web service provider application. The request is then processed by the Web service provider application. Processing of the request includes the data access layer to retrieve the data requested by the client application.This data is then passed to the listener layer, which in turn forwards the data to the client application. Figure 28-2 shows the working of a Web service.