Sayyiduna Hudhayfah (may Allah be pleased with him) says: I was walking with the Prophet (peace and blessings be upon him) when he went to a heap of filth belonging to some people, stood and urinated, and called me. He said: "Why did you go far from me?" I came and stood behind the Prophet (peace and blessings be upon him). Then water was brought to the Prophet (peace and blessings be upon him), so he performed ablution and wiped over his leather socks.
Related hadith on this topic