All interfaces for programs using RPC must be defined in Microsoft Interface Definition Language (MIDL) and compiled with the MIDL compiler. The following topics present a brief overview of creating and compiling a MIDL interface:
MIDL files are text files that you can create and edit with a text editor. If you generate a UUID for your interface, you will typically store the output in a template MIDL file. For more information on UUIDs, see Generating Interface UUIDs.
All interfaces in MIDL follow the same format. They begin with a header that contains a list of interface attributes and the interface name. The attributes are enclosed in square brackets. The interface header is followed by its body, which is enclosed in curly brackets. A simple interface is shown in the following example:
[
uuid(ba209999-0c6c-11d2-97cf-00c04f8eea45),
version(1.0)
]
interface MyInterface
{
const unsigned short INT_ARRAY_LEN = 100;
void MyRemoteProc(
[in] int param1,
[out] int outArray[INT_ARRAY_LEN]
);
}
Some of the attributes that typically appear in a MIDL interface definition are the UUID and the interface version number. The body of the interface definition must contain the procedure declarations of all of the remote procedures in the interface. It can also contain the declarations of data types and constants required by the interface.
All parameters in the remote procedure declarations must be declared as [in], [out], or [in, out]. These declarations specify that the client program passes data into a remote procedure, gets data out of a remote procedure, or both. For more detailed information about interface parameter declarations, see The IDL Interface Body.
Compiling a MIDL File
The MIDL compiler is a command-line tool that is automatically installed with the Platform Software Development Kit (SDK). Invoke it in a command window by typing the command midl, followed by the name of a MIDL file, at the command line. Make sure that the directory containing the MIDL compiler is in your path. The following example illustrates its use:
midl MyApp.idl
Note that you do not have to include the extension if the file name has the .idl extension. You can also use the MIDL compiler command-line switches by inserting them between the midl command and the file name. This is demonstrated in the following example:
midl /acf MyApp.acf MyApp.idl
In this example, the MIDL compiler is executed using the file MyApp.idl as the input file. The command line switch /acf instructs the compiler to use an application configuration file (ACF) for input as well. Application configuration files are discussed more thoroughly in The IDL and ACF Files.
Do you need to interface with Business Central? This learning path will discuss working with web and REST services, APIs, Azure Functions, and control add-ins that can be used to interface with Business Central.