The "WAY" itself is a metaphor here, indicating aspects and concepts of continuity or progression. Basically, this shows that our conception of time is mostly derived from our conception of progression and thus, of space. Considering the two cases in point, I would like to suggest that this continuous aspect of information is emphasized when we use "WAY of DOING it". Therefore, this 'way of coding' information is more likely to occur in a descriptive or instructional context. It might also be experienced as less authoritarian and more cooperative than any "WAY to DO it".
"THE WAY to DO it" might as well be encountered in an instructional setting, but exudes more authority with respect to doing it the 'right' way, distinguishing that specific one from others more strongly than "THE WAY of DOING it", where the definite article will tend to draw readers' attention towards a process rather than towards a choice. An indefinite article would, conversely, in both cases suggest alternatives.
Any "WAY to DO" would, however, most likely not be descriptive while referring to aspects of progression or continuity, would it? Rather, it might refer to an isolated aspect of a process, if any process at all will be necessary, since these 'ways' are not conceptualized as metaphorical journeys, but as logical gateways. Thus, any "WAY to DO it" will tend to be result-oriented instead of process-oriented, won't it?