View
227
Download
2
Tags:
Embed Size (px)
Citation preview
Overview of Web Services
Web applications consist of a client, which is the browser application, and a web server
Previous versions of ASP.NET would include a Remote Procedure Call (RCP) to call another application on the web server
The .NET Framework introduces Web services as an integral part of the architecture, making it easy to create and consume these services with minimal amounts of code writtenASP.NET 2.0, Third Edition 3
Distributed Object Technology
Goal: use objects residing on other platforms
Mechanism Stub Transport Implementation
Identifying an object Unique ID with Host server Directory services
ASP.NET 2.0, Third Edition 4
Communicating Between Applications
The Web service client application does not communicate directly with the Web service application; rather, it creates a WSDL proxy
WSDL stands for Web Service Description Language (WSDL) The WSDL proxy is a class that is used to
invoke the Web service The WSDL proxy will communicate with
the Web service application through a WSDL stub
ASP.NET 2.0, Third Edition 5
Communicating Between Applications (continued)
The WSDL stub is the code that communicates between the proxy class and the Web service application The purpose of the WSDL stub is to make the
communication with the Web service application simpler and transparent
The developer does not have to know about the inner workings of the Web service application in order to invoke the Web service
Rather, the WSDL stub knows what can be sent into and out of the Web service application
ASP.NET 2.0, Third Edition 6
Applying Web Services to Business
A controversial technique that has been used to retrieve product information across web sites is scraping Scraping is labor intensive and the programmer
needs permission in order to prevent violating copyright laws
Stream data is a Web service that provides data, and the client application connects to the Web service to retrieve it
Web services can also be used to deliver educational materials to schools, to build public service web sites, to retrieve statistical data, etc.
ASP.NET 2.0, Third Edition 8
The Web Service (continued)
The directory mechanism is the means to locate a Web service through a Web service Discovery Directory
Microsoft and IBM have teamed up to create the Universal Description, Discovery, and Integration (UDDI) specification, which can be used to create a third-party Web service Discovery Directory
Use UDDI directories to locate Web services and the WSDL document The UDDI service is now available in the
Windows Server 2003 software
ASP.NET 2.0, Third Edition 14
Page Caching
If the data will not change frequently, use caching techniques to increase performance; turn on page caching by setting the page caching properties
Caching is not enabled by default for data source controls, but you can enable it by setting the control’s EnableCaching property to true and setting the number of seconds to wait before refreshing the page using the CacheDuration property
If your URL that requested the page contains a query string, you can explicitly enable the page to cache each parameter by using the @ OutputCache page directive and adding the VaryByParam attribute
ASP.NET 2.0, Third Edition 16
Web Services Standards and Protocols
HTTP protocol was selected as the primary delivery protocol of Web services because it can be used to deliver documents through proxy servers and fire walls Three methods used to route the message
over the HTTP are: HTTPGet HTTPPost SOAP
ASP.NET 2.0, Third Edition 21
Programming Web Services with .NET Development Editors
When either Visual Studio .NET or Visual Web Developer Express are used to create a Web service, the application generates the WSDL document, the DISCO document, and the test web page
Use the breakpoints within the debugger tool and the tracing features to debug the Web service
To access an object, property, or function within the Web service, the local Web application treats the Web service as a local object
ASP.NET 2.0, Third Edition 22
The SOAP Contract
Simple Object Access Protocol (SOAP) is an XML-based protocol used for messaging delivery
The SOAP contract uses the XML language to describe the location and interfaces that a particular service supports
To use the WSDL command-line utility to look at the contract and generate the proxy class: wsdl /language:VB http://localhost/Service1.asmx?wsdl
The DISCO document is an XML document that examines the SOAP contract to describe the method and data formats within the Web service The DISCO document describes how the proxy class
should make calls to the Web service
ASP.NET 2.0, Third Edition 23
Creating a Web Service
Import the WebService namespace at the top of the file
Insert the WebServiceAttribute, which means that the WebService keyword is inserted before the class declaration Namespace property identifies a unique
URL that can distinguish your Web service from other Web services on the Internet
Description property can be used to provide information about your Web service; the Description attribute will appear on the Web service home page
ASP.NET 2.0, Third Edition 24
Using a Web Service
Although the HTTPGet and HTTPPost methods are limited to sending only primitive data types such as integers and strings, they can also send arrays of these primitive data types
The SOAP protocol allows you to send any structure, class, or enumerator over the Internet Serialization is the process of changing an object
into a form that can be readily transported over the network
Deserialization is the process of changing the string back into the original structure
ASP.NET 2.0, Third Edition 33
Securing Web Services
You can secure a Web service by using traditional methods such as IIS Web security, Windows authentication and Windows NTFS file permissions, and Passport authentication
The Web services Enhancements (WSE) simplifies the development and deployment of secure Web services and allows developers and administrators to apply security policies more easily
You can require a specific authentication method such as anonymous access, or a specific Windows user account You can require the client to use a secure
communications channel such as SSL
ASP.NET 2.0, Third Edition 38
Working with Alternative Platforms: PDAs and Mobile
Devices Because there is a wide range of hardware
and software for alternative platforms, not all of them have the same screen size, resolution, color, graphics, and multimedia capabilities
Many of the new devices have the .NET Compact Framework installed
You can use .NET development editors to create .NET applications for the Pocket PC devices Some developers may choose to use eMbedded
Visual Tools to create their mobile applicationsASP.NET 2.0, Third Edition 39
Creating a WML Document
The standard used to program on a mobile device is the Wireless Application Protocol (WAP) Within the WAP is the Wireless S Protocol (WSP),
which is a transport protocol that performs the same functions as HTTP for mobile devices To work with web content, the WAP standards use
an application standard known as Wireless Markup Language (WML)
Most mobile devices supply a simulator for developers Each device has its own skin, which can be
viewed on the device emulator
ASP.NET 2.0, Third Edition 40
Summary Web services are used to expose part or all of an application.
A Web service must end in the .asmx extension. The keyword, WebMethod, is used to identify the methods that are to be exposed.
Web Service Description Language (WSDL) schema is used to create a WSDL document that describes the functionality of the Web service.
Microsoft and IBM have teamed up to create the Universal Description, Discovery, and Integration (UDDI) specification, which is used to locate Web services.
Call Web services by HTTPGet and HTTPPost methods, or SOAP.
WSDL document creates a proxy class. The web application calls the proxy class to invoke the Web service. The proxy class reads the WSDL document and verifies the delivery method.
SOAP contract is an XML-formatted document called the WSDL.
Secure a Web service by using the traditional methods such as IIS Web security, HTTPS with SSL, Windows authentication, and Passport authentication.ASP.NET 2.0, Third Edition 46
Summary (continued)
The Wireless Application Protocol (WAP) is an open standard used to create programs on a mobile device. Wireless Markup Language (WML) is the programming language used to create the code for the mobile applications.
WML is compliant with the XML protocols. The WML files use cards to organize and divide the structure of the WML document. You can use additional HTML tags within the WML language, such as the anchor tag.
Device emulators, such as the OpenWave Simulator, allow you to simulate phones from a variety of vendors.
A web page that contains Mobile controls is called a Mobile Form. Mobile controls inherit a code behind the page named System.Web.UI.MobileControls.MobilePage.
ASP.NET 2.0, Third Edition 47