Anatomy of an XML Web Service Lifetime
This topic is specific to a legacy technology. XML Web services and XML Web service clients should now be created using Windows Communication Foundation.
The process that occurs when you make an XML Web service call is similar to the process that occurs when you make a regular method call. The main difference is that instead of calling a method that is located in the client application, you generate a request message over the specified transport, such as HTTP. Because the XML Web service method can be located on a different computer, the information that the XML Web service needs to process the request must be passed across the network to the server that hosts the XML Web service. The XML Web service processes the information and sends the result back, over the network, to the client application.
The following illustration shows the process of communication between a client and an XML Web service.
XML Web service lifetime
The following describes the sequence of events that occur when an XML Web service is called:
The client creates a new instance of an XML Web service proxy class. This object resides on the same computer as the client.
The client invokes a method on the proxy class.
The infrastructure on the client computer serializes the arguments of the XML Web service method into a SOAP message and sends it over the network to the XML Web service.
The infrastructure receives the SOAP message and deserializes the XML. It creates an instance of the class implementing the XML Web service and invokes the XML Web service method, passing in the deserialized XML as arguments.
The XML Web service method executes its code, eventually setting the return value and any out parameters.
The infrastructure on the Web server serializes the return value and out parameters into a SOAP message and sends it over the network back to the client.
The XML Web service infrastructure, on the client computer, receives the SOAP message, deserializes the XML into the return value and any out parameters, and passes them to the instance of the proxy class.
The client receives the return value and any out parameters.
Building an XML Web Service
Creating an XML Web service is similar to creating any component that provides programmatic access to its application logic. To create an XML Web service, you need some functionality that constitutes the service you want to expose, a service description that defines how to use the service, and an infrastructure to support the receiving and processing of requests and the sending of responses. Fortunately, much of the required infrastructure is provided for you.
Building an XML Web Service Client
Because XML Web services are accessible using URLs, HTTP, and XML, it means that programs running on any platform and in any language can access XML Web services. Since the decentralized nature of XML Web services enables both the client and the XML Web service to function as autonomous units, there are countless ways to consume an XML Web service. For example, a call to an XML Web service can be included in a Web application, a middleware component, or even another XML Web service. No matter what form the XML Web service client might take, all that is needed to call an XML Web service is to send a properly formatted request message that conforms to the published service description for that XML Web service. Depending upon the nature of the XML Web service, it might send a response message in return. The originator of the request must then be capable of extracting the necessary information from this message.