Getting Started
  Introduction
  What is ASP.NET?
  Language Support

ASP.NET Web Forms
  Introducing Web Forms
  Working with Server Controls
  Applying Styles to Controls
  Server Control Form Validation
  Web Forms User Controls
  Data Binding Server Controls
  Server-Side Data Access
  Data Access and Customization
  Working with Business Objects
  Authoring Custom Controls
  Web Forms Controls Reference
  Web Forms Syntax Reference

XML Web services
   created using ASP.NET

  Introducing XML Web services
  Writing a Simple XML Web service
  XML Web service Type Marshalling
  Using Data in XML Web services
  Using Objects and Intrinsics
  The XML Web service Behavior
  HTML Pattern Matching

ASP.NET Web Applications
  Application Overview
  Using the Global.asax File
  Managing Application State
  HttpHandlers and Factories

Cache Services
  Caching Overview
  Page Output Caching
  Page Fragment Caching
  Page Data Caching

Configuration
  Configuration Overview
  Configuration File Format
  Retrieving Configuration

Deployment
  Deploying Applications
  Using the Process Model
  Handling Errors

Security
  Security Overview
  Authentication & Authorization
  Windows-based Authentication
  Forms-based Authentication
  Authorizing Users and Roles
  User Account Impersonation
  Security and WebServices

Localization
  Internationalization Overview
  Setting Culture and Encoding
  Localizing ASP.NET Applications
  Working with Resource Files

Tracing
  Tracing Overview
  Trace Logging to Page Output
  Application-level Trace Logging

Debugging
  The SDK Debugger

Performance
  Performance Overview
  Performance Tuning Tips
  Measuring Performance

ASP to ASP.NET Migration
  Migration Overview
  Syntax and Semantics
  Language Compatibility
  COM Interoperability
  MTS Transactions

Sample Applications
  A Personalized Portal
  An E-Commerce Storefront
  A Class Browser Application
  IBuySpy.com

  Get URL for this page

Introducing XML Web services

The Internet is quickly evolving from today's Web sites that just deliver user interface pages to browsers to a next generation of programmable Web sites that directly link organizations, applications, services, and devices with one another. These programmable Web sites become more than passively accessed sites - they become reusable, intelligent XML Web services.

The common language runtime provides built-in support for creating and exposing Web Services, using a programming abstraction that is consistent and familiar to both ASP.NET Web Forms developers and existing Visual Basic users. The resulting model is both scalable and extensible, and embraces open Internet standards (HTTP, XML, SOAP, WSDL) so that it can be accessed and consumed from any client or Internet-enabled device.

XML Web services created using ASP.NET

ASP.NET provides support for XML Web services with the .asmx file. An .asmx file is a text file that is similar to an .aspx file. These files can be part of an ASP.NET application that includes .aspx files. These files are then URI-addressable, just as .aspx files are.

The following example shows a very simple .asmx file.


<%@ WebService Language="VB" Class="HelloWorld" %>

Imports System
Imports System.Web.Services

Public Class HelloWorld :Inherits WebService

     <WebMethod()> Public Function SayHelloWorld() As String
          Return("Hello World")
     End Function

End Class
VB

This file starts with an ASP.NET directive WebService, and sets the language to C#, Visual Basic, or JScript. Next, it imports the namespace System.Web.Services. You must include this namespace. Next, the class HelloWorld is declared. This class is derived from the base class WebService; note that deriving from the WebService base class is optional. Finally, any methods that will be accessible as part of the service have the attribute [WebMethod] in C#, <WebMethod()> in Visual Basic, or WebMethodAttribute in JScript, in front of their signatures.

To make this service available, we might name the file HelloWorld.asmx and place it on a server called SomeDomain.com inside a virtual directory called someFolder. Using a Web browser, you could then enter the URL http://SomeDomain.com/someFolder/HelloWorld.asmx, and the resulting page would show the public methods for this XML Web service (those marked with the WebMethod attribute), as well as which protocols (such as SOAP, or HTTP GET) you can use to invoke these methods.

Entering the address: http://SomeDomain.com/someFolder/HelloWorld.asmx?WSDL into the browser returns a Web Service Description Language (WSDL) document. This WSDL document is very important, and is used by clients that will access the service.

Accessing XML Web services

In addition to the ASP.NET server side technology that allows developers to create XML Web services, the .NET Framework provides a sophisticated set of tools and code to consume XML Web services. Because XML Web services are based on open protocols such as the Simple Object Access Protocol (SOAP), this client technology can also be used to consume XML Web services not created using ASP.NET.

Within the SDK, there is a tool called the Web Services Description Language tool (WSDL.exe). This command-line tool is used to create proxy classes from WSDL. For example, you could enter:

WSDL http://someDomain.com/someFolder/HelloWorld.asmx?WSDL

to create a proxy class called HelloWorld.cs.

This class would look very similar to the class created in the previous section. It would contain a method called SayHelloWorld that returns a string. Compiling this proxy class into an application and then calling this proxy class's method results in the proxy class packaging a SOAP request across HTTP and receiving the SOAP-encoded response, which is then marshaled as a string.

From the client perspective, the code would be simple, as shown in the following example.


Dim myHelloWorld As New HelloWorld()
Dim sReturn As String = myHelloWorld.SayHelloWorld()
VB

The return would be "Hello World".

The rest of this section deals with more advanced XML Web services topics, such as sending and receiving complex data types. There is also a section on Text Pattern Matching, a technology that addresses any URI that returns text as if it were a XML Web service. You can also perform data binding operations with XML Web services; this topic is discussed in the Data section.


Copyright 2001-2002 Microsoft Corporation. All rights reserved.