There are two types of URIs: Uniform Resource 2 Appendix D: The Technologies CertPrs8 / MCAD/MCSD XML Web Services and Server Components Development with Visual Basic .NET / Lind / 22265
Trang 1The Technologies
CertPrs8 / MCAD/MCSD XML Web Services and Server Components Development with Visual Basic NET / Lind / 222653-6 /
Chapter D Composite Default screen
Trang 2This appendix contains explanations of all the acronym-ridden Internet technologies
that are used to make the NET Framework such an exciting environment—and thathave made XML Web Services possible
HTTP
The Hypertext Transfer Protocol (HTTP) is a stateless application-level protocolthat is based on a request-response system That HTTP is an application-levelprotocol means that it will need a lower-level network protocol to achievecommunications between computers The most common network protocol is theTransmission Control Protocol (TCP) protocol from the TCP/IP suite AlthoughHTTP can use other network protocols, the proliferation of TCP/IP has made itthe only real choice today
HTTP when used with TCP/IP uses one of the well-known ports (80) definedfor connections between the client and the server This predictable behavior meansthat HTTP proxies can be used to provide a means for clients situated behind afirewall access to HTTP servers outside that firewall This is one of the things thatmake HTTP a common choice for developing client/server applications
HTTP is a stateless protocol A stateless protocol does not “remember” anythingbetween one transmission and another; it has no context—each request is anindependent 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 W3Cweb site for HTTP at http://www.w3.org/Protocols/ Next you need to look atsome 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 webservices, or indeed anything else There are two types of URIs: Uniform Resource
2 Appendix D: The Technologies
CertPrs8 / MCAD/MCSD XML Web Services and Server Components Development with Visual Basic NET / Lind /
222653-6 / Appendix D Composite Default screen
Trang 3The URL is a reference to a specific resource on the network at a particularlocation 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 serverwww.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 HTTPprotocol
■ 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 notuse URNs, but you will have seen them in XML documents The HTTP protocoluses only URLs
a MIME message The server will respond by returning a message containing astatus line that indicates the outcome of the request as well as the protocol versionfollowed by a MIME message that contains the returned information
HTTP packets are made up from ASCII text only; MIME is a process of encodingother 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 Composite Default screen
Trang 4According 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 cansee 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 thebody The client initiates the communication with the HTTP server by sending therequest 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 requestcontains 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 usingthe 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 /
Trang 5each on a line by itself The following is an example of what is sent by InternetExplorer 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 informationabout 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 thePOST method is used, additional data can be appended as a body after the header
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 Composite Default screen
Trang 66 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 HTTPstandards 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 Whenyou request a URL (http://www.osborne.com) by typing it in the address bar of yourbrowser, 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 onlythe status line and the header If the client wants to send additional information tothe 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 canfill 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 pairedand separated by an ampersand (&)
Trang 7Connection: 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 thatindicates the outcome of the request The status code falls into one of the rangesshown 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.
Composite Default screen
Trang 8Client 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 therequest 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
8 Appendix D: The Technologies
CertPrs8 / MCAD/MCSD XML Web Services and Server Components Development with Visual Basic NET / Lind /
222653-6 / Appendix D Composite Default screen
Trang 9Code 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 theclient 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.
HTTP 9
CertPrs8 / MCAD/MCSD XML Web Services and Server Components Development with Visual Basic NET / Lind /
222653-6 / Appendix D Composite Default screen
Trang 10Code 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
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.
10 Appendix D: The Technologies
CertPrs8 / MCAD/MCSD XML Web Services and Server Components Development with Visual Basic NET / Lind /
222653-6 / Appendix D Composite Default screen
Trang 11Hypertext Markup Language (HTML) is just that—a markup language that allowsyou to build the web pages your browsers display HTML documents can beproduced using a number of techniques: manually, using Notepad, for instance;
or through a development tool, such as FrontPage Either way, the resulting HTMLwill be interpreted and rendered (displayed) by the browser
HTML is rooted in Standard Generalized Markup Language (SGML), whichbecame a standard in 1986 HTML, which is a very small part of SGML, isstandardized through the Worldwide Web Consortium, http://www.w3.org
HTML is a standard, but traditionally the browser manufacturers have added bellsand whistles to their browsers in order to try to capture market share This has led
to a certain degree of incompatibility between the browsers that are in use As adeveloper, you will need to deal with this issue and try to stay as generic in yourHTML as possible
HTML Documents
This section will introduce the basic HTML syntax and elements Every HTMLdocument has the same structure, which is based on a balanced use of elements Anelement is text enclosed in angle brackets (<>) For example, the HTML elementwould look like this:
<HTML>
</HTML>
The second tag (</HTML>) is the closing of the HTML element Every elementshould be properly closed, but most browsers try to overlook missing ending tags.Every HTML document should be enclosed in an HTML element Inside theHTML element there are other elements that make up the final document—theHEAD and BODY elements The HEAD element is used to set page-wideproperties, for example, the TITLE of the document
The BODY element encloses the information that will be displayed when theHTML document is rendered in a browser The following code segment shows therelationship between the HTML, HEAD, TITLE, and BODY elements:
CertPrs8 / MCAD/MCSD XML Web Services and Server Components Development with Visual Basic NET / Lind /
222653-6 / Appendix D
HTML 11
Composite Default screen
Trang 1212 Appendix D: The Technologies
CertPrs8 / MCAD/MCSD XML Web Services and Server Components Development with Visual Basic NET / Lind /
Trang 13The resulting display is shown next.
To go back to the first page and add some interest to it, you could modify theHTML as follows:
Trang 1414 Appendix D: The Technologies
CertPrs8 / MCAD/MCSD XML Web Services and Server Components Development with Visual Basic NET / Lind /
222653-6 / Appendix D
The new page appears here
Another element that is very useful when making web pages visually pleasing isthe CENTER element, which instructs the browser to center the text in the displayarea With the CENTER element, your page now looks like this:
When viewed in the browser, the page has some added interest, as shown in here
Composite Default screen
Trang 15CertPrs8 / MCAD/MCSD XML Web Services and Server Components Development with Visual Basic NET / Lind /
222653-6 / Appendix D
Paragraphs
When you enter text in the BODY element, it will be displayed starting in thetop-left corner and flow across the browser window without any formatting Newlines are treated as whitespace and so are not displayed The following page uses acouple of paragraphs from earlier in this appendix to illustrate text layout:
a block of data that include 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 The terminology used to describe the client and server is that the client is a user agent and the server is an HTTP Server The most common user agent is a browser, but user agant can also be other programs that send requests to a HTTP Server.
In Figure D-1, you can see how the messages are sent between the client and the server.
Trang 1616 Appendix D: The Technologies
CertPrs8 / MCAD/MCSD XML Web Services and Server Components Development with Visual Basic NET / Lind /
222653-6 / Appendix D
The solution to this jumble comes in the shape of two elements—the P(paragraph) and BR (break) elements Any text that is enclosed in a paragraphelement will be offset separately, and any time the break element is inserted, thetext will continue on the following line In the next code segment, you can see thatthe text has been broken up into two paragraphs Each has additional attributesassociated—margins and alignment:
a block of data that include 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.
The first paragraph is justified, while the second one is left aligned, as shown here:
Composite Default screen
Trang 17The word “time” is in bold, and “good” is in italics.
Composite Default screen
Trang 18CertPrs8 / MCAD/MCSD XML Web Services and Server Components Development with Visual Basic NET / Lind /
222653-6 / Appendix D
Images
Images are used to make web pages more interesting and informative, and to helpget the message across Images are added by using the IMG element, which describeswhat image to show, and optionally its size and any alternative text should thebrowser be incapable of showing the image The following code segment adds animage to a page:
it to the size you want, and send the properly sized image to the browser
If the client has turned off graphics to preserve bandwidth, there is an issue ofletting the user know that there is an image in that location You do so by includingthe ALT attribute to insert the alternative text The following code segment showsthe use of the ALT attribute:
The result of using the ALT attribute is shown next:
18 Appendix D: The Technologies
CertPrs8 / MCAD/MCSD XML Web Services and Server Components Development with Visual Basic NET / Lind /
222653-6 / Appendix D Composite Default screen
Trang 19to add text or image links that point to other URLs The format of the A element is:
<A HREF="where to go">What to display</A>
The browser will render the anchor element by displaying the text (what to display)with an underline to graphically tell the user that the link can be clicked When theuser clicks the link, the browser will redirect to the URL that is specified in theHREF attribute The following code segment shows the use of anchor elements tonavigate to the pages you have worked on so far as well as to an external location:
Trang 20<A HREF="First.htm">First page</A><BR/>
<A HREF="Second.htm">Second page</A><BR/>
<A HREF="Third.htm">Third page</A><BR/>
<LI>The first item</LI>
<LI>The second item</LI>
<LI>The third item</LI>
</UL>
The numbered list uses the OL and LI elements to define the list For instance:
<OL>
<LI>The first item</LI>
20 Appendix D: The Technologies
CertPrs8 / MCAD/MCSD XML Web Services and Server Components Development with Visual Basic NET / Lind /
222653-6 / Appendix D Composite Default screen
Trang 21The third list is the definition list, which lets you list terms and definitions Thedefinition 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:
<LI>The first item</LI>
<LI>The second item
<UL>
<LI>The first nested item</LI>
<LI>The second nested item</LI>
<LI>The third nested item</LI>
Trang 2222 Appendix D: The Technologies
CertPrs8 / MCAD/MCSD XML Web Services and Server Components Development with Visual Basic NET / Lind /
The elements that are used are TABLE to define the boundaries of the table, TR(table row) to define the row, and TD (table detail) to define the columns in that row.The following code defines a table with two rows and two columns listing theparish and capital:
Trang 23CertPrs8 / MCAD/MCSD XML Web Services and Server Components Development with Visual Basic NET / Lind /
222653-6 / Appendix D
<TD>Trelawney</TD>
</TR>
</TABLE>
Setting the BORDER attribute to 1 makes the border visible Setting the attribute
to 0 makes the border invisible Here is the resulting web page:
Tables can be nested within each other This is a very powerful technique that iscommonly employed to build complex web pages with headers, footers, and navigationbars on the sides
Trang 24The combination of these features makes XML one of the enabling technologiesthat standardize data transfers between dissimilar environments as well as thestandard for storing information in documents You will look at these features overthe next sections, but first you will need to know the rules of XML.
XML Introduction
XML is based on elements that use tags that are similar to the tags used in HTML
These tags are free-form, meaning that you can create your own tags to describe a
specific document The collection of tags and the rules imposed on those tags is
called a grammar The best way to look at XML is to contrast it with HTML—
even though the two markup languages are not competing with each other
You will start with some employee data that describes four staff members in yourcompany The data appears in the following list:
Name: George How Department: Development Salary: 50,000
Name: Debbie Soo Department: Sales Salary: 55,000 Name: John Smith Department: Administration Salary: 89,000
Name: Patrick Junior Department: Development Salary: 35,000
If you were asked to represent this data in HTML, you would probably use aTABLE, as in the following HTML page:
<head>
<title>Data in a Table</title>
</head>
<body>
24 Appendix D: The Technologies
CertPrs8 / MCAD/MCSD XML Web Services and Server Components Development with Visual Basic NET / Lind /
222653-6 / Appendix D Composite Default screen
Trang 26Cool, now you have an HTML rendition of the employee data Now you need tosend that data to the payroll system, which uses a database system to store the data.
But can the database system read HTML? The answer to that question is no, not
without custom translation rules The preceding example shows the problem withdata that is formatted for display
All data has three aspects—structure, data, and presentation When you createdthe HTML table, you only performed the presentation—effectively losing thedata 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 inthe browser and as input to the database An XML document stores the structureand data but does not contain the presentation logic for that data
Your employee data represents four employees—you can now create an XMLdocument that mimics that representation You want to represent a collection ofemployee records, so you define the collection element using the <employees></
employees> tags and then you add four <employee></employee> elements insidethe employees element as in the following code segment:
<employees>
<employee>
<name>George How</name>
<department>Development</department>
26 Appendix D: The Technologies
CertPrs8 / MCAD/MCSD XML Web Services and Server Components Development with Visual Basic NET / Lind /
222653-6 / Appendix D Composite Default screen