RAD Studio |  |

Using Nonscalar Types in Invokable Interfaces
See Also
Collapse All

The Web Services architecture supports the following scalar types for both Delphi and C++:

Boolean | ByteBool | WordBool
LongBool | Char | Byte
ShortInt | SmallInt | Word
Integer | Cardinal | LongInt
Int64 | Single | Double
Extended | string | WideString
Currency | TDateTime | Variant

The following additional scalar types are supported for C++:

bool | unsigned short | _int64
char | int | AnsiString
signed char | unsigned | float
unsigned char | long | double
short | unsigned long | long double

You need not do anything special when you use these scalar types on an invokable interface. If your interface includes any properties or methods that use other types, however, your application must register those types with the remotable type registry.

Dynamic arrays can be used in invokable interfaces. They must be registered with the remotable type registry, but this registration happens automatically when you register the interface. The remotable type registry extracts all the information it needs from the type information that the compiler generates.

Note: You should avoid defining multiple dynamic array types with the same element type. Because the compiler treats these as transparent types that can be implicitly cast one to another, it doesn't distinguish their runtime type information. As a result, the remotable type registry can't distinguish the types. This is not a problem for servers, but can result in clients using the wrong type definition. As an alternate approach, you can use remotable clases to represent array types.
Note: The dynamic array types defined in the Types unit are automatically registered for you, so your application does not need to add any special registration code for them. One of these in particular, TByteDynArray, deserves special notice because it maps to a 'base64' block of binary data, rather than mapping each array element separately the way the other dynamic array types do.
Enumerated types and types that map directly to one of the automatically-marshaled scalar types can also be used in an invokable interface. As with dynamic array types, they are automatically registered with the remotable type registry.

For any other types, such as static arrays, structs or records, sets, interfaces, or classes, you must map the type to a remotable class. A remotable class is a class that includes runtime type information (RTTI). Your interface must then use the remotable class instead of the corresponding static array, struct or record, set, interface, or class. Any remotable classes you create must be registered with the remotable type registry. As with other types, this registration happens automatically.

See Also

Understanding Invokable Interfaces

Using Nonscalar Types in Invokable Interfaces

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