.NET Framework Essentials

.NET Framework Essentials

by Thuan L. Thai, Hoang Lam
     
 

View All Available Formats & Editions

.NET Framework Essentials is an objective, concise, and technical overview of the new Microsoft .NET Framework for developing web applications and services.

Specifically written for intermediate to advanced VB, C/C++, Java, and Delphi developers, .NET Framework Essentials is also useful to system architects and leaders who are assessing tools for

See more details below

Overview

.NET Framework Essentials is an objective, concise, and technical overview of the new Microsoft .NET Framework for developing web applications and services.

Specifically written for intermediate to advanced VB, C/C++, Java, and Delphi developers, .NET Framework Essentials is also useful to system architects and leaders who are assessing tools for future projects. The authors devote special attention to the writing of .NET components plus web applications and services.

This book takes on all of the most important .NET Framework topics—from the underlying Common Language Runtime (CLR) to its specialized packages for ASP.NET, Web Forms, Windows Forms, XML and data access (ADO.NET). The authors survey each of the major .NET languages, including VB.NET, C#, and Managed C++, as well as MSIL, the intermediate language understood by the CLR. They've included working code samples in every .NET language.

Compact and free of fluff or proprietary hype, .NET Framework Essentials is an outstanding value for experienced programmers and architects who need to get up to speed quickly on a far-reaching new technology.

Read More

Editorial Reviews

Library Journal
In June, Microsoft unveiled the Beta 2 version of its XML platform, .NET, upon which this book is based. The authors do a good job of covering a range of topics from the basics of .NET and the runtime environment to web services and how .NET works with XML. This single-volume overview is superior to Microsoft Press's recent cluster of .NET titles (Computer Media, LJ 7/01). The companion web site offers additional resources and updates. Since Microsoft has not launched the final version of .NET, it is still best not to purchase a slew of .NET guides. But if patrons are clamoring, buy this one. Copyright 2001 Cahners Business Information.

Product Details

ISBN-13:
9780596001650
Publisher:
O'Reilly Media, Incorporated
Publication date:
06/08/2001
Series:
Oreilly Temp Net Series
Edition description:
LST ED.
Pages:
320
Product dimensions:
6.04(w) x 9.02(h) x 0.84(d)

Read an Excerpt

Chapter 6: Web Services

Web Services allow access to software components through standard web protocols such as HTTP and SMTP. Using the Internet and XML, we can now create software components that communicate with others, regardless of language, platform, or culture. Until now, software developers have progressed toward this goal by adopting proprietary componentized software methodologies, such as DCOM; however, because each vendor provides its own interface protocol, integration of different vendors' components is a nightmare. By substituting the Internet for proprietary transport formats and adopting standard protocols such as SOAP, Web Services help software developers create building blocks of software, which can be reused and integrated regardless of their location.

In this chapter, we describe the .NET Web Services architecture and provide examples of a web service provider and several web service consumers.

Web Services in Practice

You may have heard the phrase "software as services" and wondered about its meaning. The term service, in day-to-day usage, refers to what you get from a service provider. For example, you bring your dirty clothing to the cleaner to use its cleaning service. Software, on the other hand, is commonly known as an application, either off-the-shelf, shrink-wrapped, or a custom application developed by a software firm. You typically buy the software (or in our case, build the software). It usually resides on some sort of media such as floppy diskette or CD and is sold in a shrink-wrapped package through retail outlets.

How can software be viewed as services? The example we are about to describe might seem far-fetched; however, it is possible with current technology. Imagine the following. As you grow more attached to the Internet, you might choose to replace your computer at home with something like an Internet Device, specially designed for use with the Internet. Let's call it an iDev. With this device, you can be on the Internet immediately. If you want to do word processing, you can point your iDev to a Microsoft Word service somewhere in Redmond and type away without the need to install word processing software. When you are done, the document can be saved at an iStore server where you can later retrieve it. Notice that for you to do this, the iStore server must host a software service to allow you to store documents. Microsoft would charge you a service fee based on the amount of time your word processor is running and which features you use (such as the grammar and spell checkers). The iStore service charges vary based on the size of your document and how long it is stored. Of course, all these charges won't come in the mail, but rather through an escrow service where the money can be piped from and to your bank account or credit card.

This type of service aims to avoid the need to upgrade of your Microsoft Word application. If you get tired of Microsoft Word, you can choose to use a different software service from another company. Of course, the document that you store at the iStore server is already in a standard data format. Since iStore utilizes the iMaxSecure software service from a company called iNNSA (Internet Not National Security Agency), the security of your files is assured. And because you use the document storage service at iStore, you also benefit from having your document authenticated and decrypted upon viewing, as well as encrypted at storing time.

All of these things can be done today with Web Services.

In fact, Microsoft has launched a version of the "software as service" paradigm with its Passport authentication service. Basically, it is a centralized authentication service that you can incorporate into your web sites. For sites using the Passport authentication service, it's no longer necessary to memorize or track numerous username/password pairs.

Recently, Microsoft also announced Project HailStorm, a set of user-centric Web Services, including identification and authentication, email, instant messaging, automated alert, calendar, address book, and storage. As you can see, most of these are well-known services that are provided separately today. Identification and authentication is the goal of the Passport project. Email might map to Hotmail or any other web-based email services. Instant messaging and automated alert should be familiar to you if you use MSN Messenger Service or AOL Instant Messenger. A calendar and address book are usually bundled together with the web-based email service. Consolidating these user-centric services and exposing them as Web Services would allow the user to publish and manage his own information.

A HailStorm customer can also control access permission to the data to allow or restrict access to content. These services also allow other users, organizations, and smart devices to communicate and retrieve information about us. For example, how many times have you been on the road with your mobile phone and want to get to your contact list in Outlook? Your mobile phone should be able to communicate with your address book Web Service to get someone's phone number, right? Or better yet, if your car broke down in the middle of nowhere, you should be able to use your mobile phone to locate the nearest mechanic. The user is in control of what information is published and to whom the information will be displayed. You would probably have it set up so that only you can access your address book, while the yellow pages Web Service that publishes the nearest mechanic shop to your stranded location would be publicly accessible to all.

Currently, users store important data and personal information in many different places. With HailStorm Web Services, information will be centrally managed. For example, your mechanic might notify you when it's time for your next major service. Or when you move and change your address, instead of looking up the list of contacts you wish to send the update to, HailStorm will help you publish your update in one action.

The potential for consumer-oriented and business-to-business Web Services like HailStorm is great, although there are serious and well-founded concerns about security and privacy. In one form or another, though, Web Services are here to stay, so let's dive in and see what's underneath.

Web Services Framework

Web Services combine the best of both distributed componentization and the World Wide Web. It extends distributed computing to broader ranges of client applications. The best thing is that it does it by seamlessly marrying and enhancing existing technologies.

Web Services Architecture

Web Services are distributed software components that are accessible through standard web protocols. The first part of that definition is similar to that of COM/DCOM components. However, it is the second part that distinguishes Web Services from the crowd. Web Services enable software to interoperate with a much broader range of clients. While COM-aware clients can understand only COM components, Web Services can be consumed by any application that understands how to parse an XML-formatted stream transmitted through HTTP channels. XML is the key technology used in Web Services and is used in the following areas of the Microsoft .NET Web Services framework:

Web Service wire formats
The technology enabling universal understanding of how to perform data exchanges between the service provider and consumer; the format of data for the request and response.

Web Service description in WSDL (Web Services Description Language)
The language describing how the service can be used. Think of this as the instructions on the washing machine at the laundromat telling you where to put quarters, what buttons to push, etc.

Web Service discovery
The process of advertising or publishing a piece of software as a service and allowing for the discovery of this service.

Figure 6-1 depicts the architecture of web applications using Windows DNA, while Figure 6-2 shows .NET-enabled web applications architecture. As you can see, communication between components of a web application does not have to be within an intranet. Furthermore, intercomponent communication can also use HTTP/XML.

Figure 6-1. Windows Distributed interNet Architecture

 

Figure 6-2. NET-enabled web application framework

 

Web Services Wire Formats

You may have heard the phrase "DCOM is COM over the wire." Web Services are similar to DCOM except that the wire is no longer a proprietary communication protocol. With Web Services, the wire formats rely on more open Internet protocols such as HTTP or SMTP.

A web service is more or less a component running on the web server, exposed to the world through standard Internet protocols. Microsoft .NET Web Services currently supports three protocols: HTTP GET, HTTP POST, and SOAP (Simple Object Access Protocol), explained in the next sections. Because these protocols are standard protocols for the Web, it is very easy for the client applications to use the services provided by the server.

HTTP GET and HTTP POST

As their names imply, both HTTP GET and HTTP POST use HTTP as their underlying protocol. The GET and POST methods of the HTTP protocol have been widely used in ASP (Active Server Pages), CGI, and other server-side architectures for many years now. Both of these methods encode request parameters as name/value pairs in the HTTP request. The GET method creates a query string and appends it to the script's URL on the server that handles the request. For the POST method, the name/value pairs are passed in the body of the HTTP request message.

SOAP

Similar to HTTP GET and HTTP POST, SOAP serves as a mechanism for passing messages between the clients and servers. In this context, the clients are web services consumers, and the servers are the web services. The clients simply send an XML-formatted request message to the server to get the service. The server responds by sending back yet another XML-formatted message. The SOAP specification describes the format of these XML requests and responses. It is simple, yet extensible, because it is based on XML.

SOAP is different than HTTP GET and HTTP POST because it uses XML to format its payload. The messages being sent back and forth have a better structure and can convey more complex information compared to simple name/value pairs in HTTP GET/POST protocols. Another difference is that SOAP can be used on top of other transport protocols, such as SMTP in addition to HTTP.

Web Services Description (WSDL)

For web service clients to understand how to interact with a web service, there must be a description of the method calls, or the interface that the web service supports. This web service description document is found in an XML schema called WSDL (Web Services Description Language). Remember that type libraries and IDL scripts are used to describe a COM component. Both IDL and WSDL files describe an interface's method calls and the list of in and out parameters for the particular call. The only major difference between the two description languages is that all descriptions in the WSDL file are done in XML.

In theory, any WSDL-capable SOAP client can use the WSDL file to get a description of your web service. It can then use the information contained in that file to understand the interface and invoke your web service's methods.

WSDL Structure

The root of any web service description file is the <definitions> element. Within this element, the following elements provide both the abstract and concrete description of the service:

Types
A container for datatype definitions.

Message
An abstract, typed definition of the data being exchanged between the web service providers and consumers. Each web method has two messages: input and output. The input describes the parameters for the web method; the output describes the return data from the web method. Each message contains zero or more <part> parameters. Each parameter associates with a concrete type defined in the <types> container element.

Port Type
An abstract set of operations supported by one or more endpoints.

Operation
An abstract description of an action supported by the service. Each operation specifies the input and output messages defined as <message> elements.

Binding
A concrete protocol and data-format specification for a particular port type. Similar to port type, the binding contains operations, as well as the input and output for each operation. The main difference is that with binding, we are now talking about actual transport type and how the input and output are formatted.

Service
A collection of network endpoints--ports. Each of the web service wire formats defined earlier constitutes a port of the service (HTTP GET, HTTP POST, and SOAP ports).

Port
A single endpoint defined by associating a binding and a network address. In other words, it describes the protocol and data-format specification to be used as well as the network address of where the web service clients can bind to for the service.

The following shows a typical WSDL file structure:

<definitions name="" targetNamespace="" xmlns:...>
 
  <types>...</types>
 
  <message name="">...</message>
  ...
 
  <portType name="">
    <operation name="">
      <input message="" />
      <output message="" />
    </operation>
    ...
  </portType>
  ...
 
  <binding name="">
    <protocol:binding ...>
    <operation name="">
      <protocol:operation ...>
      <input>...</input>
      <output>...</output>
    </operation>
    ...
  </binding>
  ...
 
  <service name="">
    <port name="" binding="">
      <protocol:address location="" />
    </port>
    ...
  </service>
</definitions>

The <types> element contains physical type descriptions defined in XML Schema (XSD). These types are being referred to from the <message> elements.

For each of the web methods in the web service, there are two messages defined for a particular port: input and output. This means if a web service supports all three protocols: SOAP, HTTP GET, and HTTP POST, there will be six <message> elements defined, one pair for each port. The naming convention used by the Microsoft .NET autogenerated WSDL is:

MethodName + Protocol + {In, Out}

For example, a web method called GetBooks( ) will have the following messages...

Read More

Customer Reviews

Average Review:

Write a Review

and post it to your social network

     

Most Helpful Customer Reviews

See all customer reviews >