RAD Studio |  |

Using Web Services
Collapse All
Topics

Name | Description
Using Web Services | Web Services are self-contained modular applications that can be published and invoked over the Internet. Web Services provide well-defined interfaces that describe the services provided. Unlike Web server applications that generate Web pages for client browsers, Web Services are not designed for direct human interaction. Rather, they are accessed programmatically by client applications. Web Services are designed to allow a loose coupling between client and server. That is, server implementations do not require clients to use a specific platform or programming language. In addition to defining interfaces in a language-neutral fashion, they are designed to allow multiple communications mechanisms as... more
Understanding Invokable Interfaces | Servers that support Web Services are built using invokable interfaces. Invokable interfaces are interfaces that are compiled to include runtime type information (RTTI). On the server, this RTTI is used when interpreting incoming method calls from clients so that they can be correctly marshaled. On clients, this RTTI is used to dynamically generate a method table for making calls to the methods of the interface. To create an invokable interface, you need only compile an interface with the {$M+} compiler option. The descendant of any invokable interface is also invokable. However, if an invokable interface descends from another interface that... more
Using Nonscalar Types in Invokable Interfaces | The Web Services architecture supports the following scalar types for both Delphi and C++:
Registering Nonscalar Types | Before an invokable interface can use any types other than the built-in scalar types listed in Using nonscalar types in invokable interfaces, the application must register the type with the remotable type registry. To access the remotable type registry, you must add the InvokeRegistry unit to your uses clause. This unit declares a global function, RemTypeRegistry, which returns a reference to the remotable type registry. Note: On clients, the code to register types with the remotable type registry is generated automatically when you import a WSDL document. For servers, remotable types are registered for you automatically when... more
Using Remotable Objects | Use TRemotable as a base class when defining a class to represent a complex data type on an invokable interface. For example, in the case where you would ordinarily pass a record or struct as a parameter, you would instead define a TRemotable descendant where every member of the record or struct is a published property on your new class.
Remotable Object Example | This example shows how to create a remotable object for a parameter on an invokable interface where you would otherwise use an existing class. In this example, the existing class is a string list (TStringList). To keep the example small, it does not reproduce the Objects property of the string list. Because the new class is not scalar, it descends from TRemotable rather than TRemotableXS. It includes a published property for every property of the string list you want to communicate between the client and server. Each of these remotable properties corresponds to a remotable type. In... more
Writing Servers that Support Web Services | 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... more
Using the SOAP Application Wizard | Web Service applications are a special form of Web Server application. Because of this, support for Web Services is built on top of the Web Broker architecture. To understand the code that the SOAP Application wizard generates, therefore, it is helpful to understand the Web Broker architecture. Information about Web Server applications in general, and Web Broker in particular, can be found in Creating Internet server applications and Using Web Broker. To launch the SOAP application wizard, choose FileNewOther, and on the WebServices page, double-click the Soap Server Application icon. Choose the type of Web server... more
Adding New Web Services | To add a new Web Service interface to your server application, choose FileNewOther, and on the WebServices page double-click on the icon labeled SOAP Server Interface. The Add New Web Service wizard lets you specify the name of the invokable interface you want to expose to clients, and generates the code to declare and register the interface and its implementation class. By default, the wizard also generates comments that show sample methods and additional type definitions, to help you get started in editing the generated files.
Using the WSDL Importer | To use the WSDL importer, choose File|New|Other, and on the WebServices page double-click the icon labeled WSDL importer. In the dialog that appears, specify the file name of a WSDL document (or XML file) or provide the URL where that document is published. Note: If you do not know the URL for the WSDL document you want to import, you can browse for one by clicking the button labeled Search UDDI. This launches the UDDI browser. Tip: An advantage of using the UDDI browser, even if you know the location of the WSDL document, is that when you locate... more
Defining and Using SOAP Headers | The SOAP encoding of a request to your Web Service application and of the response your application sends include a set of header nodes. Some of these, such as the SOAP Action header, are generated and interpreted automatically. However, you can also define your own headers to customize the communication between your server and its clients. Typically, these headers contain information that is associated with the entire invokable interface, or even with the entire application, rather than just the method that is the subject of a single message.
Creating Custom Exception Classes for Web Services | When your Web Service application raises an exception in the course of trying to execute a SOAP request, it automatically encodes information about that exception in a SOAP fault packet, which it returns instead of the results of the method call. The client application then raises the exception. By default, the client application raises a generic exception of type ERemotableException with the information from the SOAP fault packet. You can transmit additional, application-specific information by deriving an ERemotableException descendant. The values of any published properties you add to the exception class are included in the SOAP fault packet so that... more
Generating WSDL Documents for a Web Service Application | To allow client applications to know what Web Services your application makes available, you can publish a WSDL document that describes your invokable interfaces and indicates how to call them. To publish a WSDL document that describes your Web Service, include a TWSDLHTMLPublish component in your Web Module. (The SOAP Server Application wizard adds this component by default.) TWSDLHTMLPublish is an auto-dispatching component, which means it automatically responds to incoming messages that request a list of WSDL documents for your Web Service. Use the WebDispatch property to specify the path information of the URL that clients must use to access... more
Writing Clients for Web Services | You can write clients that access Web Services that you have written, or any other Web Service that is defined in a WSDL document. There are three steps to writing an application that is the client of a Web Service: Importing the definitions from a WSDL document. Obtaining an invokable interface and calling it to invoke the Web Service. Processing the headers of the SOAP messages that pass between the client and the server.
Importing WSDL Documents | Before you can use a Web Service, your application must define and register the invokable interfaces and types that are included in the Web Service application. To obtain these definitions, you can import a WSDL document (or XML file) that defines the service. The WSDL importer creates a unit that defines and registers the interfaces, headers, and types you need to use.
Calling Invokable Interfaces | To call an invokable interface, your client application must include any definitions of the invokable interfaces and any remotable classes that implement complex types. If the server is written in Delphi or C++Builder, you can use the same units that the server application uses to define and register these interfaces and classes instead of the files generated by importing a WSDL file. Be sure that the unit uses the same namespace URI and SOAPAction header when it registers invokable interfaces. These values can be explicitly specified in the code that registers the interfaces, or it can be automatically generated. If... more
Processing Headers in Client Applications | If the Web Service application you are calling expects your client to include any headers in its requests or if its response messages include special headers, your client application needs the definitions of the header classes that correspond to these headers. When you import a WSDL document that describes the Web Service application, the importer automatically generates code to declare these header classes and register them with the remotable type registry. If the server is written in Delphi, you can use the same units that the server application uses to define and register these header classes instead of the files... more

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