RAD Studio |  |

Writing Servers that Support Web Services
Building a Web Service server | See Also
Collapse All

In addition to the invokable interfaces and the classes that implement them, your server requires two components: a dispatcher and an invoker. The dispatcher (THTTPSoapDispatcher) receives incoming SOAP messages and passes them on to the invoker. The invoker (THTTPSOAPPascalInvoker) interprets the SOAP message, identifies the invokable interface it calls, executes the call, and assembles the response message.

Note: THTTPSoapDispatcher andTHTTPSoapPascalInvoker are designed to respond to HTTP messages containing a SOAP request. The underlying architecture is sufficiently general, however, that it can support other protocols with the substitution of different dispatcher and invoker components.
Once you register your invokable interfaces and their implementation classes, the dispatcher and invoker automatically handle any messages that identify those interfaces in the SOAP Action header of the HTTP request message.

Web services also include a publisher (TWSDLHTMLPublish). Publishers respond to incoming client requests by creating the WSDL documents that describe how to call the Web Services in the application.

Building a Web Service server

RAD Studio provides a wizard to speed development of a Web Service server application.

Use the following steps to build a server application that implements a Web Service:

1. Choose FileNewOther and on the WebServices page, double-click the Soap Server Application icon to launch the SOAP Server Application wizard. The wizard creates a new Web server application that includes the components you need to respond to SOAP requests.
2. When you exit the SOAP Server Application wizard, it asks you if you want to define an interface for your Web Service. If you are creating a Web Service from scratch, click yes, and you will see the Add New Web Service wizard. The wizard adds code to declare and register a new invokable interface for your Web Service. Edit the generated code to define and implement your Web Service. If you want to add additional interfaces (or you want to define the interfaces at a later time), choose FileNewOther, and on the WebServices page, double-click the SOAP Web Service interface icon. For details on using the Add New Web Service wizard and completing the code it generates, see Adding new Web Services.
3. If you are implementing a Web Service that has already been defined in a WSDL document, you can use the WSDL importer to generate the interfaces, implementation classes, and registration code that your application needs. You need only fill in the body of the methods the importer generates for the implementation classes. For details on using the WSDL importer, see Using the WSDL importer.
4. If you want to use the headers in the SOAP envelope that encodes messages between your application and clients, you can define classes to represent those headers and write code to process them. This is described in Defining and using SOAP headers.
5. If your application raises an exception when attempting to execute a SOAP request, the exception will be automatically encoded in a SOAP fault packet, which is returned instead of the results of the method call. If you want to convey more information than a simple error message, you can create your own exception classes that are encoded and passed to the client. This is described in Creating custom exception classes for Web Services.
6. The SOAP Server Application wizard adds a publisher component (TWSDLHTMLPublish) to new Web Service applications. This enables your application to publish WSDL documents that describe your Web Service to clients. For information on the WSDL publisher, see Generating WSDL documents for a Web Service application.

See Also

Understanding Invokable Interfaces

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!