Best thing to do, in my opinion, is to come up with a melody that is not subservient to harmony. That is, melodies come in all kinds of interesting and original forms. Harmonic progressions in their basic outline are often what are simplistic, so you usually don't want to limit something such as a melody with something simplistic, unless you're trying to work in this really special ingenious chord in just the right spot of a harmony, which can and usually should be done dependent of both harmony and melody, that is thinking in both terms. I've written harmonies and then melodies on top of them before, but it seems to confine the melody to where it lacks flair, originality, taste, all qualities etc. Since I believe melody is the most important thing in a piece, and most difficult to create a good one, then its always best to start writing a piece with one in mind. And then one more advice on this part is to try not to change the melody once you begin to write a harmony underneath it, say if you find a better harmony. You're 9 times out of 10 going to hear the melody better, and you want to use harmony to embellish it. If you find an alternative melody which sounds rather exciting, for instance 'first I will use the main melody, but on the second round, shock the listener with this change' then I believe this could, but doesn't have to be, more dependent on a harmonic change. An example where the melody changes but the harmony doesn't is Adam's 'Oh Holy Night.'