Rajinder Sidhu, of Crathie Avenue, Dumfries, was on a petition before Sheriff Brian Mahon in private.
The appearance follows an alleged attack at the Tesco car park in Dumfries earlier this month.
A spokesperson for the procurator fiscal said that no plea or declaration was made and Mr Sidhu was committed for further examination.
He was remanded in custody.
A 30-year-old man has made a brief appearance in court at Dumfries on a charge of rape.