Home > Articles > Web Services > XML

  • Print
  • + Share This
This chapter is from the book

A Simple Example: Searching for Information

Today, most services are invoked over the Web by inputting data into HyperText Markup Language (HTML) forms and sending the data to the service, embedded within a uniform resource locator (URL) string:

http://www.google.com/search 
    ?q=Skate+boots&btnG=Google+Search 

This example illustrates how simple Web interactions, such as a search, a stock purchase, or a request for driving directions, are accessed over the Web by embedding parameters and keywords in a URL. In this example, entering a simple search request for Skate boots into the Google–search engine results in the URL shown. The search keyword represents the service being requested over the Web, whereas the Skate+boots keywords represent the search string entered into the HTML form displayed by the Google Web site. The Google–search service then passes the request to a series of other search engines, which return lists of URLs to pages with text matching the search keywords Skate+boots. This inefficient way of searching the Web depends entirely on matching the given text strings to cataloged HTML pages.

XML provides a great many advantages for transmitting data across the Internet. Now the preceding request can be contained in an XML document instead:

<SOAP-ENV:Body>
  <s:SearchRequest
  xmlns:s="http://www.xmlbus.com/SearchService">
   <p1>Skate</p1>
   <p2>boots</p2>
   <p3>size 7.5</p3>
   </s:SearchRequest>
  </SOAP-ENV:Body>
</SOAP-ENV:Body> 

Sending the request within an XML document has many advantages, such as improved data typing and structure, greater flexibility, and extensibility. XML can represent structured and typed data—the size field can be typed as a decimal string or as a floating point, for example—and can contain a larger amount of information than is possible within a URL string.

This example is shown in the form of a Simple Object Access Protocol (SOAP) message, a standard form of XML messaging and one of the major enabling technologies in the Web services foundation (see Chapter 4). In SOAP messages, the name of the service request and the input parameters take the form of XML elements. The example also illustrates the use of XML namespaces (xmlns:), another critical element of Web services (see Chapter 2). Because XML documents support data typing, complex structures, and the association of XML schemas, modern Web services technology provides significant advantages over existing URL and HTML capabilities for accessing software applications.

  • + Share This
  • 🔖 Save To Your Account