Context. An X-ray survey with the XMM-Newton telescope, XMM-XXL, has identified hundreds of galaxy groups and clusters in two 25 deg2 fields. Combining spectroscopic and X-ray observations in one field, we determine how the kinetic energy of galaxies scales with hot gas temperature and also, by imposing prior constraints on the relative energies of galaxies and dark matter, infer a power-law scaling of total mass with temperature. Aims. Our goals are: i) to determine parameters of the scaling between galaxy velocity dispersion and X-ray temperature, T300 kpc, for the halos hosting XXL-selected clusters, and; ii) to infer the log-mean scaling of total halo mass with temperature, lnM200 | T300 kpc, z. Methods. We applied an ensemble velocity likelihood to a sample of >1500 spectroscopic redshifts within 132 spectroscopically confirmed clusters with redshifts z < 0.6 to model, lnσgal | T300 kpc, z, where σgal is the velocity dispersion of XXL cluster member galaxies and T300 kpc is a 300 kpc aperture temperature. To infer total halo mass we used a precise virial relation for massive halos calibrated by N-body simulations along with a single degree of freedom summarising galaxy velocity bias with respect to dark matter. Results. For the XXL-N cluster sample, we find σgal T300 kpc 0.63±0.05, a slope significantly steeper than the self-similar expectation of 0.5. Assuming scale-independent galaxy velocity bias, we infer a mean logarithmic mass at a given X-ray temperature and redshift, (ln(E(z)M200/1014 M)|T300 kpc, z) = πT + αT ln (T300 kpc/Tp) + βT ln (E(z)/E(zp)) using pivot values kTp = 2.2 keV and zp = 0.25, with normalization πT = 0.45 ± 0.24 and slope αT = 1.89 ± 0.15. We obtain only weak constraints on redshift evolution, βT = -1.29 ± 1.14. Conclusions. The ratio of specific energies in hot gas and galaxies is scale dependent. Ensemble spectroscopic analysis is a viable method to infer mean scaling relations, particularly for the numerous low mass systems with small numbers of spectroscopic members per system. Galaxy velocity bias is the dominant systematic uncertainty in dynamical mass estimates.