Chapter 11. Exposing Legacy Components as Web Services

0-13-100962-1_ch11 Chapter 11. Exposing Legacy Components as Web Services

Snoops

   

  
Migrating to .NET: A Pragmatic Path to Visual Basic .NET, Visual C++ .NET, and ASP.NET
By Dhananjay  Katre, Prashant  Halari, Narayana  Rao  Surapaneni, Manu  Gupta, Meghana  Deshpande

Table of Contents


A Web service is a collection of functions that are packed together as a single entity and exposed to the network for use by other programs over the Internet. In other words, it is a Uniform Resource Locator (URL)-addressable resource that programmatically returns information to clients . Web services can be considered as building blocks for creating distributed systems over the Internet. Some examples of Web services are

  • A credit-checking service that returns credit information against a social security number.

  • A stock quote service that returns the stock price associated with a specified ticker symbol.

  • A purchasing service that allows purchase of supplies against an item code and quantity.

To understand Web services, let's take an example from a better-known technology, COM. Any programmer working with Microsoft technologies must have used a third-party component or at least developed some components for applications. A COM component provides "services" to the application using them. For example, a component developed for a banking application might provide services such as loan and interest calculation. If the business logic requires such calculations at many places in the application, just accessing required methods of the COM simplifies the coding efforts. Components also isolate business logic from the rest of the application.

Web services represent a similar black-box functionality that can be reused without worrying about how the functionality is implemented. Web services can be interpreted as offering services over the Web. Web services are based on open Internet standards, such as HTTP and XML. The communication between the client application and Web service is via HTTP protocol using Simple Object Access Protocol (SOAP) standards. Any system supporting these Web standards will be able to support Web services.

SOAP is the communications protocol for Web services. It is basically a specification that defines the XML format for messages. A well- formed XML fragment enclosed in a couple of SOAP elements can be called a SOAP message. The SOAP specification defines what an HTTP message that contains a SOAP message looks like. The following example shows a typical SOAP message. The message is enclosed in an envelope and contains a header that defines the message and a body that contains the actual message.

 graphics/icon01.gif <?xml version="1.0" encoding="UTF-8" ?>  <env:Envelope xmlns:env="http://www.w3.org/2001/09/soap-enve- lope">    <env:Header>        <n:priority>1</n:priority>    </env:Header>    <env:Body>      <m:alert xmlns:m="http://testexample.org/alert">        <m:msg>Hello World</m:msg>      </m:alert>    </env:Body>  </env:Envelope> 

Web services provide well-defined interfaces called contracts that describe the services provided rather than how they are implemented. Web services are described by the Web Services Description Language (WSDL). A WSDL file is an XML document that describes a set of SOAP messages and how the messages are exchanged. In addition to describing message contents, WSDL defines where the service is available and what communications protocol is used to talk to the service. This means that the WSDL file defines everything required to write a program to work with a Web service.

Most people who use SOAP don't write SOAP messages directly but use the SOAP ToolKit or other toolkits to create and parse the SOAP messages. These toolkits generally translate function calls from some kind of language to a SOAP message. The SOAP ToolKit contains the following:

  • A client-side component (SoapClient) that allows an application to invoke Web service operations described by a WSDL document.

  • A server-side component (SoapServer) that maps invoked Web service operations to COM object method calls as described by the WSDL and Web Services Meta Language (WSML) files. This file is necessary for Microsoft's implementation of SOAP.

  • Necessary components that construct, transmit, read, and process SOAP messages. These processes are collectively referred to as marshalling and unmarshalling.

The following section describes the use of Microsoft SOAP ToolKit 2.0 to create WSDL and WSML files, and then how to consume these Web services using SoapClient and .NET client is described.


Snoops

   
Top


Migrating to. NET. A Pragmatic Path to Visual Basic. NET, Visual C++. NET, and ASP. NET
Migrating to. NET. A Pragmatic Path to Visual Basic. NET, Visual C++. NET, and ASP. NET
ISBN: 131009621
EAN: N/A
Year: 2001
Pages: 149

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net