D The technologies

53 246 0
D The technologies

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

D The Technologies CertPrs8 / MCAD/MCSD XML Web Services and Server Components Development with Visual Basic .NET / Lind / 222653-6 / Chapter D P:\010Comp\CertPrs8\653-6\appd.vp Wednesday, October 30, 2002 9:49:00 AM Color profile: Generic CMYK printer profile Composite Default screen T his appendix contains explanations of all the acronym-ridden Internet technologies that are used to make the .NET Framework such an exciting environment—and that have made XML Web Services possible. HTTP The Hypertext Transfer Protocol (HTTP) is a stateless application-level protocol that is based on a request-response system. That HTTP is an application-level protocol means that it will need a lower-level network protocol to achieve communications between computers. The most common network protocol is the Transmission Control Protocol (TCP) protocol from the TCP/IP suite. Although HTTP can use other network protocols, the proliferation of TCP/IP has made it the only real choice today. HTTP when used with TCP/IP uses one of the well-known ports (80) defined for connections between the client and the server. This predictable behavior means that HTTP proxies can be used to provide a means for clients situated behind a firewall access to HTTP servers outside that firewall. This is one of the things that make HTTP a common choice for developing client/server applications. HTTP is a stateless protocol. A stateless protocol does not “remember” anything between one transmission and another; it has no context—each request is an independent connection to the server. HTTP/1.1 is the current standard from the World Wide Web Consortium (W3C). HTTP/1.1 has actually been a standard since 2000. The current work on application- level protocols within W3C is with the XML protocol. To find additional information about the HTTP/1.1 standard, visit the W3C web site for HTTP at http://www.w3.org/Protocols/. Next you need to look at some of the specifics of HTTP. URIs, URLs, and URNs A Universal Resource Identifier (URI) is used to unambiguously locate a resource on the network. These resources can be files, programs, e-mail addresses, XML web services, or indeed anything else. There are two types of URIs: Uniform Resource Locators (URLs) and Uniform Resource Names (URNs). 2 Appendix D: The Technologies CertPrs8 / MCAD/MCSD XML Web Services and Server Components Development with Visual Basic .NET / Lind / 222653-6 / Appendix D P:\010Comp\CertPrs8\653-6\appd.vp Wednesday, October 30, 2002 9:49:00 AM Color profile: Generic CMYK printer profile Composite Default screen The URL is a reference to a specific resource on the network at a particular location. The URL includes three parts to be able to define the resource. They are: ■ Protocol The first part of the URL is the protocol; http, https, ftp, file, and telnet are some common protocol designations. ■ Server The second part is the server name using the Domain Name System (DNS) name. For more information on DNS, see later in this appendix. ■ Resource The last part is the path on the server where the resource is located. The following are examples of URLs: ■ http://www.osborne.com Points to the default document on the server www.osborne.com. ■ https://localhost/Stock.asmx Points to the XML web service Stock.asmx on the local computer, using the secure (encrypted) version of the HTTP protocol. ■ http://www.w3.org/Protocols/Index.html Points to the Index.html page in the Protocols folder on the www.w3.org server using the HTTP protocol. URNs are persistent, location-independent resource-identifiers. HTTP does not use URNs, but you will have seen them in XML documents. The HTTP protocol uses only URLs. Basics The HTTP protocol uses a request/response system to provide communication between a client and a server. The communication starts with the client sending an HTTP request to the server. The request includes method, URL, and protocol version followed by a block of data that includes the modifiers, client information, and any other information needed for the request. The data block is formatted as a MIME message. The server will respond by returning a message containing a status line that indicates the outcome of the request as well as the protocol version followed by a MIME message that contains the returned information. HTTP packets are made up from ASCII text only; MIME is a process of encoding other data into ASCII text so that any type data can be carried in an HTTP packet. HTTP 3 CertPrs8 / MCAD/MCSD XML Web Services and Server Components Development with Visual Basic .NET / Lind / 222653-6 / Appendix D P:\010Comp\CertPrs8\653-6\appd.vp Wednesday, October 30, 2002 9:49:00 AM Color profile: Generic CMYK printer profile Composite Default screen According to HTTP terminology, the client is a user agent and the server is an HTTP server. The most common user agent is a browser, but user agents can also be other programs that send requests to an HTTP server. In Figure D-1, you can see how the messages are sent between the client and the server. Client Request The request is built from three parts: the status line, the header, and optionally the body. The client initiates the communication with the HTTP server by sending the request. These are the steps in sending the request: 1. Resolve the server name to an IP address. 2. Establish a connection to the server address using port 80. 3. Send the request using this connection. 4. Close the connection. The HTTP status line must contain a method that indicates what the request contains. The status line will have the following format: Method Request-URI Protocol For example: GET / HTTP/1.1 This request uses the GET method to request the default document using the HTTP/1.1 protocol. After this initial line in the request, the client inserts information that will be sent to the server using a series of Keyword: Value pairs, CertPrs8 / MCAD/MCSD XML Web Services and Server Components Development with Visual Basic .NET / Lind / 222653-6 / Appendix D 4 Appendix D: The Technologies FIGURE D-1 Client/server communication using HTTP P:\010Comp\CertPrs8\653-6\appd.vp Wednesday, October 30, 2002 9:49:00 AM Color profile: Generic CMYK printer profile Composite Default screen each on a line by itself. The following is an example of what is sent by Internet Explorer 6.0 (the first line had to be broken to fit the page): User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.3705) Method: GET The interesting point here is that the client actually sends the server information about what software is running on the client computer. This information is used by the server and the developer to customize the information that is returned. The request is ended with a blank line to indicate to the server that nothing else is to follow. In the case of the GET method, that is the end of the request, but if the POST method is used, additional data can be appended as a body after the header. Server Response The server response is made up from three parts as well: the status line, the header, and the body of the response. The server response status line has three fields that show the protocol, status, and description of the response. Protocol Status-code Description For example: HTTP/1.1 200 OK indicates that the server is responding using HTTP version 1.1 and that the request was processed successfully. For a listing of the completion codes, see later in this section. The server also sends information in the header based on Keyword: Value pairs. For example, the following information comes from an Apache server: HTTP/1.1 200 OK Date: Tue, 24 Sep 2002 17:14:42 EDT Server: Apache/1.3.6 (Unix) PHP/3.0.7 . Content-Length: 24563 Connection: Close Content-Type: text/html; charset-iso-8859-1 HTTP 5 CertPrs8 / MCAD/MCSD XML Web Services and Server Components Development with Visual Basic .NET / Lind / 222653-6 / Appendix D P:\010Comp\CertPrs8\653-6\appd.vp Wednesday, October 30, 2002 9:49:00 AM Color profile: Generic CMYK printer profile Composite Default screen 6 Appendix D: The Technologies CertPrs8 / MCAD/MCSD XML Web Services and Server Components Development with Visual Basic .NET / Lind / 222653-6 / Appendix D Methods The method used for the request message is indicated in the status line of the request. The server uses the method to determine the purpose of the request. The HTTP standards have many different methods defined; the most commonly used ones— GET, HEAD, and POST—require some attention. GET The GET method is used to request and retrieve information from the server. When you request a URL (http://www.osborne.com) by typing it in the address bar of your browser, the browser will form the following GET request: GET / HTTP/1.0 Accept: */* Connection: Keep-Alive Host: www.osborne.com User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.3705) The GET request can be a maximum 1024 characters long, and it contains only the status line and the header. If the client wants to send additional information to the server through a GET request, that information must be encoded in the URL. For example, if the page you are currently viewing contains a form that the user can fill in to return information to the server and the form has its method set to GET, the following request message is the result of clicking the Submit button: GET /bin/FormEx.aspx?"name=Ken"&"email=kennethslind@hotmail.com" HTTP/1.1 The requested item in this case is /bin/FormEx.aspx. The ? indicates that data follows. This example sends back two fields (name and email). The fields are paired and separated by an ampersand (&). HEAD The HEAD method is the same as the GET method except for one thing: the server will not include a response body in the response to a HEAD method. POST The POST method is used to send form data from the client to the server. It does not have the limitation of 1024 characters; it can be unlimited in size. In addition, P:\010Comp\CertPrs8\653-6\appd.vp Wednesday, October 30, 2002 9:49:01 AM Color profile: Generic CMYK printer profile Composite Default screen HTTP 7 CertPrs8 / MCAD/MCSD XML Web Services and Server Components Development with Visual Basic .NET / Lind / 222653-6 / Appendix D the data that is transmitted is hidden in the message rather than shown openly in the URL as is the case when data is transferred using the GET method. For example, if you send the same information as in the earlier GET example, the POST message will look like this: POST /bin/FormEx.aspx HTTP/1.0 Accept: */* Connection: Keep-Alive Host: www.osborne.com User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.3705) name=Ken&email=kennethslind@hotmail.com Response Codes The HTTP server’s response status line contains a three-digit status code that indicates the outcome of the request. The status code falls into one of the ranges shown here. Status Code Range Description 100–199 Informational 200–299 Client request successful 300–399 Client request redirected, further action necessary 400–499 Client request incomplete 500–599 Server errors Informational, 100–199 This range of status codes contains only the status line with no additional data. Code Text Description 100 Continue This message from the server indicates that the server wants the client to continue sending the request. 101 Switching Protocols Positive answer to the client that the server has agreed to change the application protocol. P:\010Comp\CertPrs8\653-6\appd.vp Wednesday, October 30, 2002 9:49:01 AM Color profile: Generic CMYK printer profile Composite Default screen Client Request Successful, 200–299 These are the successful completion codes from the server. Code Text Description 200 OK Successful completion of the request; the response message contains the requested data. 201 Created Successful completion of the request; a new resource has been created. The URI returned in the body of the response message points to the new resource. 202 Accepted The request has been accepted but not yet acted on. When the processing takes place, there is no guarantee that the request will be successful. 203 Non-Authoritative Information The information returned in the header is not the definitive information from the originating server; instead, it comes from a copy on a different server (i.e., Proxy). 204 No Content Successful completion of the request, but the server does not have to return any data at this time. 205 Reset Content Informs the browser to clear the current form. 206 Partial Content Successful completion of the request based on a Range header. Indicates that additional content is to follow. Client Request Redirected, 300–399 The redirect codes indicate to the client that it needs to take further actions for the request to be successfully completed. Code Text Description 300 Multiple Choices The requested URI refers to multiple possible resources. The user agent and server must negotiate the preferred representation. Usually locale selection. Where the locale is the users preferred language and culture information. 8 Appendix D: The Technologies CertPrs8 / MCAD/MCSD XML Web Services and Server Components Development with Visual Basic .NET / Lind / 222653-6 / Appendix D P:\010Comp\CertPrs8\653-6\appd.vp Wednesday, October 30, 2002 9:49:01 AM Color profile: Generic CMYK printer profile Composite Default screen Code Text Description 301 Moved Permanently The resource has been permanently moved. The client should use the URI in the Location header. 302 Found The resource is temporarily in a different location. The client should use the URI in the Location header. 303 See Other The response can be found at a different URI. The client should use the URI in the Location header. 304 Not Modified The client has requested a response using the If-Modified-Since header. The document has not been modified; the client should use that locally cached copy. 305 Use Proxy The resource can be accessed only through the proxy URI in the Location field. 307 Temporary Redirect The URI in the Location field is to be used for this call only. Client Request Incomplete, 400–499 The 400–499 range represents an error status when the server has deemed that the client has made the error. Code Text Description 400 Bad Request The server did not understand the request. 401 Unauthorized The request did not have the proper authorization; the client should provide proper authentication when the requesting the same resource again. 402 Payment Required This code is reserved for future use. 403 Forbidden The server understood the request but refused to act. Do not repeat the request. 404 Not Found The resource could not be found. 405 Method Not Allowed The method in the request status line is not supported for the requested protocol. 406 Not Acceptable The resource can produce only responses that have content characteristics that are incompatible with the accept header in the request message. 407 Proxy Authentication Required The client must authenticate with the proxy first. HTTP 9 CertPrs8 / MCAD/MCSD XML Web Services and Server Components Development with Visual Basic .NET / Lind / 222653-6 / Appendix D P:\010Comp\CertPrs8\653-6\appd.vp Wednesday, October 30, 2002 9:49:01 AM Color profile: Generic CMYK printer profile Composite Default screen Code Text Description 408 Request Timeout The client did not send a request within the time limit of the server. 409 Conflict The request could not be acted on because of the state of the resource. 410 Gone The resource is permanently gone. 411 Length Required The request cannot be acted on without a Content-Length value in the request. 412 Precondition Failed The precondition in one or more of the If request headers evaluated to false on the server. 413 Request Entity Too Large The serve cannot, or will not, process the request; it is too large in size. 414 Request-URI Too Long The URL is too long for the server to interpret. 415 Unsupported Media Type The body of the request is in a format that the server cannot interpret. Server Errors, 500–599 This range indicates that the server is aware that it has made an error or that other server resources prevent the request from being successfully completed. Code Text Description 500 Internal Server Error The server encountered an exception; the request could not be processed. 501 Not Implemented The request requires a feature that the server doesn’t implement. 502 Bad Gateway The server received an invalid response from a gateway or proxy it was using to service the request. 503 Service Unavailable The server could not act on the request at this time; try again later. 504 Gateway Timeout The server did not receive a response from the gateway or proxy it was using to service the request. 505 HTTP Version Not Supported The HTTP version requested is not available on the server. 10 Appendix D: The Technologies CertPrs8 / MCAD/MCSD XML Web Services and Server Components Development with Visual Basic .NET / Lind / 222653-6 / Appendix D P:\010Comp\CertPrs8\653-6\appd.vp Wednesday, October 30, 2002 9:49:01 AM Color profile: Generic CMYK printer profile Composite Default screen [...]... The first item The second item The first nested item The second nested item The third nested item The third item The first term First definition The second term Second definition The third term Third definition The fourth term Fourth definition ... The first term First definition The second term Second definition The third term Third definition The fourth term Fourth definition Lists can be nested to produce the specific kind of list required for a web page The following web page is an example of a nested list: Lists - Two ... Composite Default screen MCAD/MCSD XML Web Services and Server Components Development with Visual Basic NET / Lind / 222653-6 / Appendix D XML George How Development 50000 Debbie Soo Sales 55000 John Smith Administration 89000 Patrick Junior Development 35000... node attribute:: The attributes of the context node child:: All the direct children of the context node descendant:: All the descendants of the context node, recursively including all children’s children descendant-or-self:: The context node and its descendants following:: All nodes that are after the context node in the tree following-sibling:: All the following siblings of the context node namespace::... Composite Default screen MCAD/MCSD XML Web Services and Server Components Development with Visual Basic NET / Lind / 222653-6 / Appendix D HTML 21 The third list is the definition list, which lets you list terms and definitions The definition list uses the DL element to define the list, DT elements for the terms, and DD elements for the definitions The following code segment shows a definition list: The. .. that the Window bar shows the title and that the Hello World! greeting is displayed in the browser Headings One way of adding some interest to a web page is to use headings to group information under The HTML standard defines six sizes of headers, defined by the H1, H2, H3, H4, H5, and H6 elements The following example shows how to use the headings to see the different choices Headings... FrontPage Either way, the resulting HTML will be interpreted and rendered (displayed) by the browser HTML is rooted in Standard Generalized Markup Language (SGML), which became a standard in 1986 HTML, which is a very small part of SGML, is standardized through the Worldwide Web Consortium, http://www.w3.org HTML is a standard, but traditionally the browser manufacturers have added bells and whistles to their... valid namespaces that can be used on the context node This include the default namespaces and the XML namespace parent:: The parent of the context node, if there is one preceding:: All nodes that are before the context node in the tree, excluding any ancestors, attribute nodes, and namespace nodes preceding-sibling:: All the preceding siblings of the context node self:: Just the context node itself Node... document the HEAD and BODY elements The HEAD element is used to set page-wide properties, for example, the TITLE of the document The BODY element encloses the information that will be displayed when the HTML document is rendered in a browser The following code segment shows the relationship between the HTML, HEAD, TITLE, and BODY elements: P:\010Comp\CertPrs8\653-6\appd.vp Wednesday, October 30,... you only performed the presentation—effectively losing the data A human can glean the data from the display, but the data is not readable by a computer The solution is to convert the data to XML and use that XML document both in the browser and as input to the database An XML document stores the structure and data but does not contain the presentation logic for that data Your employee data represents . In the case of the GET method, that is the end of the request, but if the POST method is used, additional data can be appended as a body after the header Appendix D Methods The method used for the request message is indicated in the status line of the request. The server uses the method to determine the purpose

Ngày đăng: 05/11/2013, 12:15

Tài liệu cùng người dùng

Tài liệu liên quan