Right in daily life you can use these two words interchangeably without any trouble. Most of the Chinese consider them as same meaning. BUT actually they have difference. In China, there's other nationalities whose mother tongue is not 汉语. 中文should be a simplified version for 中国的语文, that is to say it should be the legally language spoken in China, and right now that language is 汉语, as Han Chinese compost more than 90% of the population, not language from other minorities in China, say like Tibetan or Mongolian. So 中文is more political sense, while 汉语 is the actual name for this language.