呵呵,其实Delphi的帮助里面都有说明了,贴出来你看看:
Calling server interfaces
Applicationsdo
not need to call the IAppServer interface directly because the appropriate calls are made automatically when you use the properties and methods of the client dataset. However, while it is not necessary to work directly with the IAppServer interface, you may have added your own extensions to the remote data module’s interface. When you extend the application server’s interface, you need a way to call those extensions using the connection created by your connection component. Unless you are using SOAP, you cando
this using the AppServer property of the connection component. AppServer is a Variant that represents the application server’s interface. You can call an interface method using AppServer by writing a statement such as
MyConnection.AppServer.SpecialMethod(x,y);
However, this technique provides late (dynamic) binding of the interface call. That is, the SpecialMethod procedure call is not bound until runtime when the call is executed. Late binding is very flexible, but by using it you lose many benefits such as code insight and type checking. In addition, late binding is slower than early binding, because the compiler generates additional calls to the server to set up interface calls before they are invoked.
When you are using DCOM or CORBA as a communications protocol, you can use early binding of AppServer calls. Use the as operator to cast the AppServer variable to the IAppServer descendant you created when you
created the remote data module. For example:
with MyConnection.AppServer as IMyAppServerdo
SpecialMethod(x,y);
To use early binding under DCOM, the server’s type library must be registered on the client machine. You can use TRegsvr.exe, which ships with Delphi to register the type library.
Note: See the TRegSvr demo (which provides the source for TRegsvr.exe) for an example of how to register the type library programmatically.
To use early binding with CORBA, you must add the _TLB unit that is generated by the type library editor to your project. Todo
this, add this unit to the uses clause of your unit.
When you are using TCP/IP or HTTP, you can’t use true early binding, but because the remote data module uses a dual interface, you can use the application server’s dispinterface to improve performance over simple late binding. The dispinterface has the same name as the remote data module’s interface, with the string ‘Disp’ appended. You can assign the AppServer property to a variable of this type to obtain the dispinterface. Thus:
var
TempInterface: IMyAppServerDisp;
begin
TempInterface :=IMyAppServerDisp(IDispatch(MyConnection.AppServer));
...
TempInterface.SpecialMethod(x,y);
...
end;
Note: To use the dispinterface, you must add the _TLB unit that is generated when you save the type library to the uses clause of your client module.
If you are using SOAP, you can’t use the AppServer property. Instead, you must use a remote interfaced object (THTTPRio) and make early-bound calls. As with all early-bound calls, the client application must know the application server’s interface declaration at compile time. You can add this to your client application either by adding the same unit the server uses to declare and register the interface to the client’s uses clause, or you can reference a WSDLdo
cument that describes the interface. For information on importing a WSDLdo
cument that describes the server interface, see Importing WSDLdo
cuments.
Note: The unit that declares the server interface must also register it with the invocation registry. For details on how to register invokable interfaces, see Defining invokable interfaces.
Once your application uses the server unit that declares and registers the interface, or you have imported a WSDLdo
cument to generate such a unit, create an instance of THTTPRio for the desired interface:
X := THTTPRio.Create(nil);
Next, assign the URL that your connection component uses to the remote interfaced object:
X.URL := SoapConnection1.URL;
You can then
use the as operator to cast the instance of THTTPRio to the application server’s interface:
InterfaceVariable := X as IMyAppServer;
InterfaceVariable.SpecialMethod(x,y);