Team Fly |
Page 320
Here is a list of characteristics that define Web services:
They have no user interface.
They are published and consumed via a network (the Internet, an intranet, and so on). They are not localized.
SOAP and other XML-based technologies send messages using ordinary, plain text. This, obviously, raises some security issues. Plain text can be read by anyone, and aside from that, many people mistakenly think that a Web service could not transmit a virus. Given that firewalls are supposed to pass XML through (it's sometimes simply seen as a flavor of HTML), Web service communications slide right in. Hackers, though, know full well that virii executables can be embedded as ASCII strings.
They are similar to traditional objects (they expose methods and properties, and their clients consume what they expose). The difference between a classic object and a Web service is that the latter isn't tightly coupled, doesn't demand that the consumer and service share the same object model. Instead, XML (and its derivatives) is the shared language into which members are translated during the request-response communication.
They communicate via XML (SOAP variation), theoretically thereby eliminating language-, and even platform-, dependence. They are not proprietary, like COM objects. However, the Web service itself is written in a computer language—not XML. XML is a metalanguage: It can describe language and data, but cannot actually compute. When the Web service receives the client's request (or the client receives the service's response), the XML message has been automatically repackaged into an object. If you're familiar with .NET object-to-XML serialization, you understand that this process is handled for you—there are built-in .NET serialization features. (You won't have to handle the serialization process in the Web service examples in this chapter.) Note that this process is similar to DCOM, but open XML is used to transmit the object rather than a proprietary format.
In this example you create and test a Web service that requires parameters. You'll pose as the client to test the service's response. The service exposes a method that accepts a string and returns the words in it reversed (one two three becomes three two one). Start a new VB.NET project and double-click the ASP.NET Web Service icon in the New Project dialog box. (If this type of new project cannot be created, read the VS.NET documentation to find out how to install IIS.) You'll see a design window for this project, but it's not intended to be used for visible UI controls such as TextBoxes; rather, it's for adding database-connection controls and such. Switch to code view.
This line is required:
Imports System.Web.Services
Delete the commented sample code lines and replace them with Listing 13.1.
Team Fly |