A wheel-rail contact formulation for analyzing the nonlinear train-structure interaction that takes into account the wheel and rail geometry is proposed. While most of the existing methods treat the contact forces as external forces, the present formulation uses a finite element to model the behavior in the contact interface, based on Hertz's theory and Kalker's laws. The equations of motion are complemented with constraint equations that relate the displacements of the vehicle and structure. This complete system is solved directly using an optimized algorithm. The formulation is validated with experimental data from a test performed on a rolling stock plant.