You can try opening or closing your service stance so you are tossing away from the sun a little
^^ +1. This is the best idea IMO, if you're stuck without sunglasses and/or cap. At the same time, try to adjust your toss higher, lower, or to one side, in order to "get away from" the sun. Do whatever you have to do with your positioning at the baseline, toss, etc., in order to minimize looking in the sun's direction.
If all else fails, try jollyroger's idea. Well, you won't have to try, you'll just wind up doing it.
EDIT: One time, I tried EVERYTHING I could to get away from being right into the sun, and I just couldn't. I tried for three straight points to figure out some way around it, and wound up with jollyroger's strategy on all three. Finally, in desperation (and this is the ONLY time I've ever had to do this in 20 years playing tennis), I just gave up trying and served underhand, which worked. We got clobbered on the point, but at least the serve was in.