Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 50 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
50
Dung lượng
726,9 KB
Nội dung
Contents Overview 1 HTTP Fundamentals 2 XML Essentials 14 SOAP Fundamentals 26 Lab 3: Issuing HTTP and SOAP Requests Using the .NET Framework 39 Review 45 Module3:TheUnderlyingTechnologiesofWeb Services Information in this document, including URL and other Internet Web site references, is subject to change without notice. Unless otherwise noted, the example companies, organizations, products, domain names, e-mail addresses, logos, people, places, and events depicted herein are fictitious, and no association with any real company, organization, product, domain name, e-mail address, logo, person, places or events is intended or should be inferred. Complying with all applicable copyright laws is the responsibility ofthe user. Without limiting the rights under copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of Microsoft Corporation. Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document. Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property. 2001 Microsoft Corporation. All rights reserved. Microsoft, MS-DOS, Windows, Windows NT, Active Directory, Authenticode, Biztalk, Intellisense, Jscript, MSDN, PowerPoint, Visual Basic, Visual C++, Visual C#, Visual Studio, Win32, and Windows Media are either registered trademarks or trademarks of Microsoft Corporation in the U.S.A. and/or other countries. The names of actual companies and products mentioned herein may be the trademarks of their respective owners. Module3:TheUnderlyingTechnologiesofWeb Services iii Instructor Notes This module provides students with an overview ofthetechnologies that form the foundation of Extensible Markup Language (XML)-based Web Services. After completing this module, students will be able to: ! Describe the structures of a Hypertext Transfer Protocol (HTTP) request and response. ! Issue HTTP POST and GET requests and process the responses by using the Microsoft ® .NET Framework. ! Describe data types by using the XML Schema Definition language (XSD). ! Explain how to control the way a .NET Framework object is serialized to XML. ! Describe the structures of a Simple Object Access Protocol (SOAP) request and response. ! Issue a SOAP request and process the response by using the .NET Framework. Materials and Preparation This section provides the materials and preparation tasks that you need to teach this module. Required Materials To teach this module, you need the Microsoft PowerPoint ® file 2524A_03.ppt. Preparation Tasks To prepare for this module: ! Read all ofthe materials for this module. ! Try the walkthroughs and demonstrations in this module. ! Complete the lab. Presentation: 120 Minutes Lab: 45 Minutes iv Module3:TheUnderlyingTechnologiesofWeb Services Module Strategy This module is intended to demystify thetechnologiesunderlyingWeb Services. Throughout this module, you should emphasize the simplicity ofthetechnologies covered to the students. Use the following strategy to present this module: ! HTTP Fundamentals This section is intended to provide students with a basic understanding ofthe HTTP protocol and explain how to issue HTTP requests using the .NET Framework. Explain that HTTP is a simple protocol designed for interoperability and not performance. Emphasize how simple HTTP is to understand. ! XML Essentials Explain that XML is fundamental to Web Services. Do not spend much time on the basics of XML. Briefly review the important XML concepts. Cover the topics on XSD as a progressive tutorial, rather than a list of concepts. Explain how the default serialization behavior for .NET Framework data types can be modified. Explain the importance ofthe ability to modify default serialization behavior of data types. ! SOAP Fundamentals This topic is intended to provide students with a basic understanding ofthe SOAP protocol and explain how to issue SOAP requests using the .NET Framework. Emphasize that SOAP is the preferred wire format for Web Services. Explain to the students that the .NET Framework handles most ofthe details of communication using SOAP in Web Services implemented using the .NET Framework. Module3:TheUnderlyingTechnologiesofWeb Services 1 Overview ! HTTP Fundamentals ! XML Essentials ! SOAP Fundamentals ***************************** ILLEGAL FOR NON - TRAINER USE ****************************** Web Services are built on Web technologies. The three core technologies that form the foundation for Web Services are the Hypertext Transfer Protocol (HTTP), the Extensible Markup Language (XML), and the Simple Object Access Protocol (SOAP). It is important to understand the workings ofthe three technologies and how the Microsoft ® .NET Framework provides support for these three technologies to be able to use them in Web Services. Because you must be already familiar with the basics of XML, this module provides a refresher of only the XML concepts that are necessary for implementing and using Web Services. After completing this module, you will be able to: ! Describe the structures of an HTTP request and response. ! Issue HTTP POST and GET requests and process the responses by using the Microsoft .NET Framework. ! Describe data types by using the XML Schema Definition language (XSD). ! Explain how to control the way a .NET Framework object is serialized to XML. ! Describe the structures of a SOAP request and response. ! Issue a SOAP request and process the response by using the .NET Framework. Topic Objective To provide an overview ofthemodule topics and objectives. Lead-in In this module, you will learn about the some ofthetechnologiesunderlyingWeb Services. Note 2 Module3:TheUnderlyingTechnologiesofWeb Services " "" " HTTP Fundamentals ! Overview of HTTP ! Structures of HTTP Requests and Responses ! The GET and POST Methods ! HTTP Using the .NET Framework ! Code Walkthrough: Issuing a Synchronous HTTP Request ! Code Walkthrough: Issuing an Asynchronous HTTP Request ***************************** ILLEGAL FOR NON - TRAINER USE ****************************** The Hypertext Transfer Protocol (HTTP) is a World Wide Web Consortium (W3C) standard for transferring documents on the Internet. Web Services can use HTTP for communication. In this section, you will learn the fundamentals of HTTP and how to make HTTP requests using the .NET Framework. Topic Objective To introduce the topics in this section. Lead-in In this section, you will learn the fundamentals of HTTP and how to make HTTP requests using the .NET Framework. Module3:TheUnderlyingTechnologiesofWeb Services 3 Overview of HTTP ! Syntax of a URL ! Example ! Stateless Protocol http://host[:port][path[?querystring]] http://host[:port][path[?querystring]] http://www.woodgrovebank.com/accts.asp?AccNo=23 http://www.woodgrovebank.com/accts.asp?AccNo=23 ***************************** ILLEGAL FOR NON - TRAINER USE ****************************** A resource location is specified in HTTP through a mechanism known as a Uniform Resource Locator (URL). Strictly speaking, the mechanism used in HTTP is a Uniform Resource Identifier (URI), but we can also think of it as a URL. A URI identifies a document, whereas a URL identifies a document and its location. Syntax of a URL The syntax of a URL is as follows: http://host[:port][path[?querystring]] The following is an example of a URL: http://www.woodgrovebank.com/accts.asp?AccNo=23 In the preceding example, www.woodgrovebank.com is the host, accts.asp is the path and AccNo=23 is the query string. If the port number is not specified (as in the preceding example), the default port for HTTP, which is port 80, is used. Stateless Protocol HTTP is a stateless protocol. This means that whenever a request is made by the client, the connection to the server is closed after the response is received from the server. Therefore, if any state must be maintained between the client and the server, the server must pass on state information with the response to the client. This will enable the server to recover this information from the client when it receives the next request. For example, if you implement a Web site that displays user-specific content, you would have to implement a mechanism that retains information about the current user in order to display personalized content. Topic Objective To explain URLs and how HTTP is a stateless protocol. Lead-in Resource locations are specified in HTTP through URLs. Note Example 4 Module3:TheUnderlyingTechnologiesofWeb Services Structures of HTTP Requests and Responses ! Requests ! Responses POST /TheStockExchange/Trading/GetStockPrice.asp HTTP/1.1 Host: localhost Content-Type: application/x-www-form-urlencoded Content-Length: 11 Symbol=MSFT POST /TheStockExchange/Trading/GetStockPrice.asp HTTP/1.1 Host: localhost Content-Type: application/x-www-form-urlencoded Content-Length: 11 Symbol=MSFT HTTP/1.1 200 OK Content-Type: text/xml; charset=utf-8 Content-Length: 75 <?xml version="1.0" encoding="utf-8"?> <stock symbol="MSFT" Price="71.50" /> HTTP/1.1 200 OK Content-Type: text/xml; charset=utf-8 Content-Length: 75 <?xml version="1.0" encoding="utf-8"?> <stock symbol="MSFT" Price="71.50" /> Note the blank line! ***************************** ILLEGAL FOR NON - TRAINER USE ****************************** HTTP requests and responses have a simple structure. Structure of an HTTP Request An HTTP request has the following format: method URL Version headers a blank line message body An example code of an HTTP request is as follows: POST /TheStockExchange/Trading/GetStockPrice.asp HTTP/1.1 Host: localhost Content-Type: application/x-www-form-urlencoded Content-Length: 11 <?xml version="1.0" encoding="utf-8"?> <Symbol=MSFT /> Topic Objective To describe the structures of an HTTP request and response. Lead-in HTTP requests and responses have simple structures. Syntax Example Module3:TheUnderlyingTechnologiesofWeb Services 5 The first line in an HTTP request is known as the request line, and the methods that are supported by a request are as follows: ! OPTIONS ! GET ! HEAD ! POST ! DELETE ! TRACE ! CONNECT ! extension-method In Course 2524A, Developing XML Web Services Using Microsoft Visual C# .NET Beta 2, you will learn about the GET and POST methods only. Structure of an HTTP Response An HTTP response has the following format: Version Status-Code Description headers a blank line message body Example An example code of an HTTP response is as follows: HTTP/1.1 200 OK Content-Type: text/xml; charset=utf-8 Content-Length: 75 <?xml version="1.0" encoding="utf-8"?> <stock symbol="MSFT" Price="71.50" /> Note S yntax 6 Module3:TheUnderlyingTechnologiesofWeb Services The GET and POST Methods ! HTTP-GET ! HTTP-POST GET /Trading/GetStockPrice.asp?Symbol=MSFT HTTP/1.1 Host: localhost GET /Trading/GetStockPrice.asp?Symbol=MSFT HTTP/1.1 Host: localhost POST /Trading/GetStockPrice.asp HTTP/1.1 Host: localhost Content-Type: application/x-www-form-urlencoded Content-Length: 11 Symbol=MSFT POST /Trading/GetStockPrice.asp HTTP/1.1 Host: localhost Content-Type: application/x-www-form-urlencoded Content-Length: 11 Symbol=MSFT ***************************** ILLEGAL FOR NON - TRAINER USE ****************************** The GET and POST request methods are ideal for communicating with a Web Service. This is because these methods are designed specifically for submitting data to a Web server and retrieving a specified resource from a Web server. This makes it possible to layer a function call model on top of these methods, which is exactly the model required for Web Services. HTTP-GET Request Consider the following HTTP-GET request: GET /Trading/GetStockPrice.asp?Symbol=MSFT HTTP/1.1 Host: localhost The most important feature ofthe request line is the querystring. The querystring is the portion ofthe URI that follows the question mark, and consists of a set of URL-encoded name/value pairs. In an HTTP-GET request, there is typically no message body. The response for a GET request is just a standard HTTP response, which is described in the previous topic. Topic Objective To describe GET and POST methods and explain the differences between them. Lead-in The GET and POST request methods are ideal for Web Services communication. Delivery Tip While discussing the details of an HTTP-GET request, point out to the parts ofthe corresponding URL on the preceding slide, in particular the query string. Emphasize that the body is empty. [...]... USE****************************** In the context ofWeb Services, XML is used to describe theWebService interfaces The interface descriptions for a WebService include definitions ofthe datatypes for each operation and the format ofthe messages that are exchanged between a WebService consumer and a WebService Module 3:TheUnderlyingTechnologiesofWeb Services 15 Overview of XML Topic Objective To explain the important... less restrictions on the kind of data that is sent to the server In Module 5, “Implementing a Simple Web Service, ” in Course 2524A, Developing XML Web Services Using Microsoft Visual C# NET Beta 2, you will see how the choice of an HTTP request method affects the kinds of interfaces theWeb Services can expose 7 8 Module3:TheUnderlyingTechnologiesofWeb Services HTTP Using the NET Framework Topic... within the SOAP Body element In the context ofWeb Services, the Body element comprises the data specific to the actual method call, such as theWebService method name and parameters and/or return values for the method invocation 30 Module3:TheUnderlyingTechnologiesofWeb Services SOAP Fault The SOAP Fault element is used to transport error or status information or both, within a SOAP message If the. .. Framework handles these details You will briefly examine protocol bindings when you look at the NET Framework support for SOAP later in this module Module 3:TheUnderlyingTechnologiesofWeb Services 29 Structure of SOAP Messages Topic Objective To explain the structure of SOAP messages and how they can be used in Web Services Lead-in A SOAP message consists ofthe Envelope element at the root, which... document structure You will learn the basics of XSD later in this module For more information about WSDL, see Module 4, “Consuming Web Services,” in Course 2524A, Developing XML Web Services Using Microsoft Visual C# NET Beta 2 Module 3:TheUnderlyingTechnologiesofWeb Services 17 XSD Fundamentals Topic Objective To provide a brief overview of XSD Lead-in One ofthe most important activities involved... 32 Module3:TheUnderlyingTechnologiesofWeb Services Delivery Tip To explain the sample code to the students, open the file \Democode\Mod03\ SOAP Response.txt In the preceding code, the endpoint ofthe GetAccount method is specified in the SOAPAction header, and the method and its parameters are contained in the soap:Body element The response to the preceding method... ofthe fault It must be present within the SOAP Fault element and must provide information explaining the nature ofthe fault ! faultactor The purpose ofthe faultactor element is to provide information about who caused the fault to happen within the message path It indicates the source ofthe fault The value ofthe faultactor element is an URI that identifies the source Applications that are not the. . .Module 3:TheUnderlyingTechnologiesofWeb Services Delivery Tip While discussing the details of an HTTP-POST request point out to the parts ofthe corresponding URL on the preceding slide Emphasize that there is typically no query string Also, point out the blank line between the header and the body HTTP-POST Request Consider the following HTTP-POST request: POST... some ofthe important concepts of XML, let us look at how XML is used in Web Services Schemas To be able to successfully use a Web Service, you need to know the operations supported by theWebService and the structure ofthe documents (or messages) that are consumed and produced by each operation This information is defined in a document, known as a service description, which describes a WebService The. .. 38, the response content is retrieved exactly in the way it is done in a synchronous operation 14 Module3:TheUnderlyingTechnologiesofWeb Services " XML Essentials Topic Objective To introduce the topics in this section Lead-in In this section, you will review some ofthe important concepts of XML that are relevant to Web Services ! Overview of XML ! XSD Fundamentals ! XML Serialization in the . Minutes iv Module 3: The Underlying Technologies of Web Services Module Strategy This module is intended to demystify the technologies underlying Web Services most of the details of communication using SOAP in Web Services implemented using the .NET Framework. Module 3: The Underlying Technologies of Web Services