kbmMW v. 5.00.01 Beta released

We are happy to announce v5 of our popular middleware for Delphi and

Yet again kbmMW continues to set the bar for what an n-tier product must be capable of in the real world!

We hope you will take the time to test this Beta release in your setup and report back regression errors to us by email at kbm@components4developers.com

Keywords for this release:

  • Huge number of new features and improvements!
  • New Smart services and clients for very easy publication of functionality and use from clients and REST aware systems without any boilerplate code.
  • New high quality random functions.
  • New high quality pronouncable password generators.
  • New support for YAML, BSON, Messagepack in addition to JSON and XML.
  • New Object Notation framework which JSON, YAML, BSON and Messagepack is directly based on, making very easy conversion between these formats and also XML which now also supports the object notation framework.
  • Lots of new object marshalling improvements, including support for marshalling native Delphi objects to and from YAML, BSON and Messagepack in addition to JSON and XML.
  • New LogFormatter support making it possible to customize actual logoutput format.
  • CORS support in REST/HTML services.
  • Focus on central performance improvements.
  • Pre XE2 compilers no longer officially supported.
  • Bug fixes

Look at end of post for detailed list of additions, changes and fixes.

Professional and Enterprise Edition is available for all with a current active SAU.
If your SAU has run out, please visit our shop to extend it with another 12 months.

CodeGear Edition is available for free, but only supports a specific Delphi/Win32 SKU, contains a limited feature set and do not include source.

Please visit https://portal.components4developers.com to download.


kbmMW is the premiere n-tier product for Delphi, C++Builder and FPC on .Net, Win32, Win64, Linux, Java, PHP, Android, IOS, embedded devices, websites, mainframes and more.

Please visit http://www.components4developers.com for more information about kbmMW.


Components4Developers is a company established in 1999 with the purpose of providing high quality development tools for developers and enterprises. The primary focus is on SOA, EAI and systems integration via our flagship product kbmMW.

kbmMW is a portable, highly scalable, high end application server and enterprise architecture integration (EAI) development framework for Win32, ..Net and Linux with clients residing on Win32, .Net, Linux, Unix, Mainframes, Minis, Embedded and many other places. It is currently used as the backbone in hundreds of central systems, in
hospitals, courts, private, industries, offshore industry, finance, telecom, governements, schools, laboratories, rentals, culture institutions, FDA approved medical devices, military and more.

5.00.00 Beta Feb 19 2017

Important notes (changes that may break existing code)
* Officially now only supporting XE2 and forward. Support for pre XE2 may not be complete.

New stuff
– Officially now only supporting XE2 and forward. Support for
pre XE2 may not be complete.
– Added RemoteLocationsPrimaryPart to
TkbmMWAuthorizationTransportConstraint (default false).
If set to true, will only compare primary part of
Primary part is defined by everything up til the last ‘:’. In most
cases that will mean the IP address without the port number.
– Added IkbmMWLogFormatter interface to kbmMWLog.
– Added TkbmMWStandardLogFormatter to kbmMWLog. It contains vastly
improved features for controlling the look and layout of the log
output. Its the default used log formatter.
– Added TkbmMWSimpleLogFormatter to kbmMWLog. It outputs a log with
only datetime, type (info/warning/error/fatal etc) and log string.
– Added LogFormatter property to IkbmMWLogManager. It can be set to a
custom log formatter.
– Added mwldtRaw log data type and methods LogRaw to IkbmMWLog. It
allows for logging bytes or strings without
– Added global SystemLog instance which will always output to system
log outputs. It is used as a fallback in case the regular log system
– Added support for marshalling/unmarshalling named enum values via
the new kbmMW_Enum attribute.
Its useful when an enum value cant be used as an identifier or its
value should be different from its presented name.
– Added ExceptOnUnknownType to TkbmMWCustomRTTIMarshal. It controls if
to throw an exception if an unknown type is accessed or not
(default true).
– Added support for marshalling/unmarshalling TDictionary<K,V> types.
– Added support for correctly instantiating classes in unmarshalling
that contains a capacity constructor argument.
– Added Run methods to TkbmMWScheduler. It allows for one time run and
forget scheduled async code. They are used in the same way as the
Schedule methods, but sets Occurs to mwsoRun.
The job will be automatically unscheduled after the run.
– Added overloaded DelayInitial(const AInitialDelaySecs:double) to
It allows for directly giving an initial delay in seconds. It
supports fractional second values.
– Added Clear to TkbmMWScheduledEvents (scheduler.Events) to allow for
clearing all scheduled events. Running events will be allowed to
– Added GetNameSpaceByURI, DefaultNameSpace, DefaultNameSpaceURI to
– Added SearchRelNodeByID, SearchNodeByID, SearchRelNodeByGivenName,
SearchNodeByGivenName to IkbmMWDOMXMLParser.
– Added ExpandNameSpace, GivenName, ChildrenByGivenName,
ChildByGivenName, CheckChildByGivenName to TkbmMWDOMXMLNode.
– Added CheckNodeByGivenName, NodeByGivenName to TkbmMWXMLNodeList.
– Added missing ADSDBF support to kbmMWReg.
– Added mwrtoOptionalInsert,mwrtoKeyNotNullInsert,
mwrtoOptionalDelete,mwrtoKeyNotNullDelete and table modifier flags
OIM/OMI (optional insert/modify), OID/ODI (optional insert/delete),
OMD/ODM (optional modify/delete), OI (optional insert),
OD (optional delete), OM (optional modify),
KIM/KMI (insert/modify on key not null), KID/KDI (insert/delete on
key not null),
KMD/KDM (modify(delete on key not null), KI (insert on key not null),
KM (modify on key not null), KD (delete on key no null)
to TkbmMWResolverTableOption
They allow for more finegrained definition on when insert/update
/delete should happen.
If one of the optional (OIM,OMD,OID,OI,OD,OM) is given, no exception
will be raised for the table when an operation did not succeed, and
resolving will continue. If one of the key (KIM,KMD,KID,KI,KM,KD) is
given, record resolve operation will be skipped for the specific
record if key is null.
– Added ReadBOM overloaded methods with default TEncoding option to
– Added overloaded kbmMWTextToString, kbmMWExpectText,
kbmMWStringRightPad, kbmMWStringLeftPad,
kbmMWGetComputerName functions to kbmMWGlobal.pas.
– Added optional ACallback anonymous function to SendAsyncRequest and
SendAsyncRequestEx in kbmMWClient.pas (WIB only).
It allows for providing an anonymous function that should be called
when an async response is returned. The function must follow this
– Added LOB blob/clob support (user fix) to DOA adapter.
– Vastly improved XSD importer.
– Added generic Object Notation framework for building virtual object
trees consisting of TkbmMWONNative, TkbmMWONArray and TkbmMWONObject
which all are based on TkbmMWONCustomObject.
– Added YAML parser/generator based on object notation framework.
– Added Messagepack parser/generator based on object notation
– Added BSON parser/generator based on object notation framework.
– Added support for converting XML to and from object notation format
via LoadFromObjectNotation and SaveToObjectNotation functions.
– Added new TkbmMWCustomSmartService and TkbmMWCustomHTTPSmartService
services, which can be selected in the service wizard to create
smart services. Smart services supports tagging any function to be
exported to a smart client or a REST client
(TkbmMWCustomHTTPSmartService required).
– Updated transports to support marshalling objects via the transport.
– Added several near lock free features to kbmMWGlobal, including
TkbmMWLockFreeStack, more interlocked functions, lock free array GC
fixes, optional TkbmMWREWLock statistics, support for TkbmMWMREWLock
can switch to TMonitor for reader/writer fair support.
– Optimized many algorithms like TkbmMWStringBuilder,
TkbmMWGenerateGUID, TkbmMWGenerateShortGUID and many more to improve
performance overall.
– Added many new general purpose functions to kbmMWGlobal.
– Added direct support for salt in hash functions deriving from
– Added support for anonymous functions in async kbmMWClient requests
– Added new kbmMWRTTI unit with loads of RTTI functionality.
– Added YAML stream format for kbmMemTable and descendants.
– Added Messagepack stream format for kbmMemTable and descendants.
– Added BSON stream format for kbmMemTable and descendants.
– Added object marshalling to and from YAML.
– Added object marshalling to and from Messagepack.
– Added object marshalling to and from BSON.
– Added ServicePath property to TkbmMWClientIdentity.
– Added MaxLogins to TkbmMWAuthorizationManager which is default 100
to prevent potential login spam.
– Added support for HTTPSys based transport for Windows. Its specially
useful for high performance RESTful applications.
– Added AutoRegisterServices method to TkbmMWServer which can be used
for automatically locating and registering any service that has the
kbmMW_Service attribute defined. It makes use of the old
RegisterService and RegisterServiceByName optional.
– Added LocalSinceEpochMS, UTCSinceEpochMS, Temporenc to
TkbmMWDateTime. Temporenc is a very compact binary encoding of a
datetime value.
– Added FastSetUTC method to TkbmMWDateTime to threadsafely very fast
setting the UTC value of an already defined TkbmMWDateTime record.
The record MUST be initialized before using FastSetUTC, for example
by dt:=TkbmMWDateTime.Now;
– Added ValueToStream, ValueFromStream, ValueToBytes and
ValueFromBytes in
TkbmMWCustomRTTIMarshal. Allows for easy marshalling objects to and
from bytes and streams.
– Added ExceptOnUnknownType boolean property to
Controls if an exception should be thrown in case a type cant be
marshalled or unmarshalled, or it should be silently skipped.
– Added Devart MyDAC support (DMYDAC).
– Added CORS support (Cross Origin-Resource Sharing) in
TkbmMWCustomHTTPService and descendants. (OnCORS event).
– Added PerformOPTIONS and PerformPATCH support to
(OnOptions and OnPatch in TkbmMWEventHTTPService).
– Added REST transport stream format which must be used if non HTTPSys
transport is used for smart services.
– Added TkbmMWSmartClient which allows simple and easy access to
server side smart functions.
Check simpleinvocation sample.
– Added high quality random functions in new kbmMWRandom unit.
TkbmMWRandomDelphi (32 bit non high quality ramdom!),
TkbmMWRandomSplitMix (64 bit)
TkbmMWRandomXoroshiro128Plus (64 bit),
TkbmMWRandomXoroshiro1024 (64 bit),
TkbmMWRandomPCGUInt32 (32 bit),
TkbmMWRandomMersenneTwisterUInt32 (32 bit),
TkbmMWRandomMersenneTwisterUInt64 (64 bit)
– Added high quality pronouncable password generators in new unit
TkbmMWMixerPasswordGen, TkbmMWKoremutakePasswordGen
– Added support for ExchangeType in TkbmMWAMQPClient.
– Added new GC and CloseAndGC methods in TkbmMWAMQPChannel to force
getting rid of defunct/cached but unused AMQP channels.
– Added IPVersion property to TkbmMWCustomTCPIPIndyClientTransport.

Changes/minor additions
– Removed (mwloProcessThreadInfo,mwloThreadName from TkbmMWLogOption
since its now controlled by the log formatter.
– Changed Activate method of IkbmMWScheduledEvent to have true as
default argument AValue.
– Changed SetAsDuration and GetAsDuration to use TkbmMWDuration
instead of TkbmMWDateTime.
– Added support for checking if path is accessible in
– Changed JSON parser/generator to be based on the object notation
– Improved scalability of FastCGI services to better spread load
accross multiple instances.

– Fixed A/V when attempting to use audit file.
– Fixed missing clearing of TkbmMWDuration when parsing duration
strings, resulting in an incorrect duration value (instead of null)
on invalid duration strings.
– Fixed TDuration.Passed(const ADuration:TkbmMWDuration) which didnt
return correct value.
– Fixed deactivating precise scheduled events.
– Fixed events scheduled to start on day, month, week or year
– Fixed issues to initial delay in scheduled events.
– Fixed parsing tags crossing line boundaries in XML parser.
– Fixed various namespace issues in XML parser.
– Fixed WIB compilation issue for XE.
– Fixed TkbmMWStreamStore offset bug when writing first segment.
– Fixed potential shutdown issue in Indy10 transports due to Indy10
– Fixed kbmMWDependency non accumulating memory leaks.
– Fixed NexusDB transport compilation.
– Fixed Autoinc field detection in EDB (ElevateDB) adapter.

Teaser: kbmMW safety first… Random numbers and great passwords!

Usually Delphi’s built in 32 bit random generator is sufficient for most tasks, like generating random numbers for some tests, or a game or something similar. However the random generator is, if one focus on security, not strong enough to be used for cryptographic uses, like password generation.

Random numbers

In next version of kbmMW, a set of random number generators has been added for generating 32bit and 64bit random values in addition to supporting the standard Delphi Randon method.

32 bit random generators in kbmMW:

  • TkbmMWRandomDelphi
  • TkbmMWRandomPCGUInt32
  • TkbmMWRandomMersenneTwisterUInt32

64 bit random generators in kbmMW:

  • TkbmMWRandomSplitMix
  • TkbmMWRandomXoroshiro128Plus
  • TkbmMWRandomXoroshiro1024
  • TkbmMWRandomMersenneTwisterUInt64

They all follow the same principle, and it’s easy to replace one with another, or even add another custom random generator.

To see the randomness of the generators, one can make a lot of random X and Y values and plot them in a fine masked grid. A perfectly random function (in reality that does not exist in current computers) ought to spread the numbers fairly evenly across the grid.

The 32 bit standard Delphi random plot

The 32 bit PCG random plot

The 32 bit Mersenne Twister random plot

The 64 bit split mix random plot

The 64 bit Xoroshiro 128+ random plot

The 64 bit Xoroshiro1024 random plot

The 64 bit Mersenne Twister random plot

As can be seen, the Delphi random generator is pretty bad in producing values across the entire value space, while the others show a much more even spread as would be expected by a fair random generator.

Choosing a random number generator for a particular purpose can be difficult. One has to weigh in speed vs randomness vs full cycle time and other factors. Basically the perfect randon number generator do not exist at this time for regular computers.

These pages explains a bit about their weaknesses and strengths:

But at least now you have a better choice. And in fact this brings us to the next section. Generation of strong passwords.

Strong passwords

Most software today supports some sort of user login, where a password is required. kbmMW certainly supports that, through for example the authorization manager.

But the challenge is to force users to use some good passwords, which they still have a chance to remember without writing down.

As a first for Delphi, kbmMW now also supports multiple password generator algorithms to encourage use of strong passwords.

kbmMW comes with two password generators and a framework on which new custom password generators can be built:

  • TkbmMWMixerPasswordGen
  • TkbmMWKoremutakePasswordGen

The Mixer password generator supports selecting the minimum and maximum number of digits, minimum and maximum number of punctuation characters, unicase or mixed case, and minimum length of a generated password.

The Koremutake password generator generates a random 64 bit value, and converts that 64 bit value into a string consisting of two and three character character groups, forming a semi pronounceable password.

Using the password generators is very simple:

        // Optionally set length, digits, punctuation and case settings.
        // Default a password will be minimum 8 characters long,
        // contain from 1 to 4 digits, no punctuation characters
        // and use mixed case alpha characters.

This could output: 69vcRPhw



We will continue to monitor the various options for password generators, and provide support for them as we find them interesting.

Teaser : kbmMW’s new object notation

kbmMW now supports XML, JSON, BSON, Messagepack and YAML natively, and includes a new common Object Notation format for easy conversion.

JSON and XML has been supported natively by kbmMW for years. Later kbmMW also supported marshalling of native Delphi objects to and from JSON and XML.

In addition to it being a very nice way to stream Delphi objects, the feature also allowed for a way to convert XML to JSON and visa versa.

However, the upcoming version of kbmMW now includes a new object notation framework, that makes it easy to convert from one notation to another, without going through a native Delphi object.

The new version of kbmMW not only supports JSON and XML, but now also YAML (which is a more human readable format) and the compact binary Messagepack and BSON formats, natively, both for creating your own object notation trees in code, and for marshalling Delphi objects to and from.

With the many new object notation formats supported by kbmMW, it also made sense to find a way to make it easy to convert between them, without having to marshal to and from native Delphi objects.

For that reason the kbmMW Object Notation format was invented. The object notation format is based on a number of classes:

  • TkbmMWONCustomObject (from which the classes listed below descends)
  • TkbmMWONObject (for key/value type data)
  • TkbmMWONArray (for array type data)
  • TkbmMWONNative (for string, integer, floats, date/time, binary values, custom native values and more)

In addition a number of abstract stream classes was developed, which purpose is to handle converting the object notation trees to and from various string or binary formats, and a set of abstract classes that handles marshalling object notation trees to and from native Delphi objects.

JSON, YAML, BSON and Messagepack object notation classes directly descends from the Object Notation classes.


  • TkbmMWJSONObject
  • TkbmMWJSONArray
  • TkbmMWJSONNative

  • TkbmMWYAMLObject
  • TkbmMWYAMLArray
  • TkbmMWYAMLNative

  • TkbmMWBSONObject
  • TkbmMWBSONArray
  • TkbmMWBSONNative
For Messagepack:

  • TkbmMWMessagepackObject
  • TkbmMWMessagepackArray
  • TkbmMWMessagepackNative

Since XML is a more rich notation format, it was decided to leave its SAX based parser (which the XML DOM class use) and instead add support for converting the XML DOM tree to and from the Object Notation format. This way its easy to convert between different notation formats, without sacrificing the more advanced features of our native XML parser.

The above specialized object notation classes, are in reality very very slim.
Thus the underlying TkbmMWON…. classes are sufficient for conversion. So even if one build a JSON object notation tree in code, it can still be understood by the Messagepack formatter code etc.

Generally it’s recommended using the non specialized classes instead of the specialized ones for simplicity reasons.

So lets try to build a simple object notation tree:

 father.AsString['name']:='Joe Simpson';
 child.AsString['name']:='Joe Simpson Jr';

This basically makes a father object with name and age, and a list of children (containing only one child with name and age). The object notation tree should now look like this:


So lets convert this to JSON:

  // If set to true, an exception will be raised in case a type is not supported
  // by the specific streamformat. An event also exists which one can hook
  // into, to get information about what type fails etc.

  // s now contains the serialized object in JSON format.

Resulting in s containing:

{"name":"Joe Simpson","age":42,"children":[{"name":"Joe Simpson Jr","age":12}]}

or to YAML:

  // If set to true, an exception will be raised in case a type is not supported
  // by the specific streamformat. An event also exists which one can hook
  // into, to get information about what type fails etc.

  // s now contains the serialized object in YAML format.

Resulting in s containing (with linefeeds):

name: Joe Simpson
age: 42
    name: Joe Simpson Jr
    age: 12

BSON and Messagepack follows the same pattern as JSON and YAML.

And for XML:


  // s now contains the serialized object in XML format.

Resulting in s containing (with linefeeds):

 <name>Joe Simpson</name>
 <children i="0">
  <name>Joe Simpson Jr</name>

In BSON, the output would be a binary value (a stream or a byte array). A Base64 encoded version of the above object notation tree would be:


and a Base64 encoded Messagepack stream would look like:


The Object Notation classes also supports letting the developer indicate if a property key/value pair of type TkbmMWONNative should be streamed as an attribute or an element in XML.

Further the TkbmMWONNative class supports custom values, like the BSON Decimal128 value. As no other streamers understand that value type, using custom types do limit lossless conversion between different object notation formats.

Delphi native objects can be marshalled to and from the Object Notation format, and thus also to and from the above supported specialized object notation formats formats.

Teaser : Easy REST with kbmMW and Delphi

kbmMW has for many years supported REST, but it did require some manual work in marshalling data in and out. Further the URL’s allowed for calling kbmMW’s REST interface had to be formatted fairly strictly.

Using the new kbmMW smart service which is being developed, you can extremely easily publish functions to be consumed by the public via REST via any URL you like.

A kbmMW smart service which have some functions available for calling from smart clients (a new kbmMW client type) and REST clients, could look like this:


 // This service is known to smart clients as SMARTDEMO
 // Methods registered for REST access will, if they
 // provide a relative path, be sub pathed under /myserver
 TkbmMWCustomService2 = class(TkbmMWCustomSmartService)

 // This method can be called both from REST and
 // from smart clients.
 // Its called from REST clients like this:
 // http://../helloworld
 [kbmMW_Rest('method:get, path: "/helloworld"')]
 function HelloWorld:string;

 // This method can be called both from REST and
 // from smart clients.
 // Its called from REST clients like this:
 // http://../myserver/myechostring/somestring
 // or
 // http://../myserver/echostring/somestring
 // somestring (can be anything) will be echoed back.
 // The argument AString will automatically receive
 // the value provided as somestring.
 'method:get, '+
 'path: [ "echostring/{AString}","myechostring/{AString}" ]')]
 function EchoString(
  [kbmMW_Rest('value: "{AString}"')] const AString:string):string;

// This method is only available from REST calls, not
 // from smart clients. (kbmMW_Method attribute is missing)
 // It can be called from a browser like this:
 // http://.../someabspath/addnumbers?arg1=10&arg2=20
 // The functions arguments are automatically populated
 // with the arguments.
 [kbmMW_Rest('method:get, path: "/someabspath/addnumbers"')]
 function AddNumbers(
  [kbmMW_Rest('value: "$arg1", required: true')] const AValue1:integer;
  [kbmMW_Rest('value: "$arg2", required: true')] const AValue2:integer;
  [kbmMW_Arg(mwatRemoteLocation)] const ARemoteLocation:string):integer;

// This method gets and owns a TPerson instamce, which it must
 // itself free. The method is not available for REST calls.
 function StorePerson(
  [kbmMW_Arg(mwatOwnedValue)] const APerson:TPerson):integer;

 // This method is only available from smart clients.
 // It receives a TPerson instamce which is owned by the
 // caller. When called from a smart client, the kbmMW framework
 // is the owner and will automatically free it.
 function StorePerson2(const APerson:TPerson):integer;

 // This method is only available from smart clients.
 // It receives a IPerson2 interface.
 function StorePerson3(const APerson:IPerson2):integer;

 // This method can be called both from REST and
 // from smart clients.
 // The method returns a TPerson instamce which is
 // automatically freed by the kbmMW framework after marshalling.
 // (Its default to free a returned object)
 [kbmMW_Rest('method:get, path: "getperson/{id}", freeResult:true')]
 function GetPerson([kbmMW_Rest('value:{id}')]id:string):TPerson;

// Functions published by the service.

function TkbmMWCustomService2.HelloWorld:string;
 Result:='Hello world';

function TkbmMWCustomService2.EchoString(const AString:string):string;

function TkbmMWCustomService2.ReverseString(
 const AString:string;
 const AClientIdentity:TkbmMWClientIdentity):string;

function TkbmMWCustomService2.AddNumbers(
 const AValue1,AValue2:integer;
 const ARemoteLocation:string):integer;

// In ARemoveLocation the reported remote location
 // for the client is found.

function TkbmMWCustomService2.StorePerson(
 const APerson:TPerson):integer;
 // The TPerson instance is owned by this function,
 // and must be manually freed.

function TkbmMWCustomService2.StorePerson2(
 const APerson:TPerson):integer;
 // The TPerson instance is automatically freed
 // upon exit of this function.

function TkbmMWCustomService2.StorePerson3(
 const APerson:IPerson2):integer;
 // The lifetime of IPerson2 depends on reference counting.

function TkbmMWCustomService2.GetPerson(id:string):TPerson;
 Result.Name:='Sofie Mogensen';


Examples on REST calls:

GET http://localhost/myserver/getperson/1

{“person”:{“Name”:”Sofie Mogensen”,”Address”:””,”Age”:87}}

GET http://localhost/someabspath/addnumbers?arg1=10&arg2=20


Its dead easy to create the server. Just have a central form/datamodule with a kbmMWServer instance, a transport with the new REST streamformat specified, and configured to listen on port 80, and add all the smart service units you want (like the above). Then only the following 2 lines are needed:


and you are running your REST and smart client server!

As usual all this can be combined with traditional services and clients. While REST calls results in objects automatically being streamed and unstreamed as JSON, smart clients will automatically stream and unstream object and interface instances in messagepack format, which is now also supported.