In League of Legends, the laning phase is all about juggling last hitting the minions and harassing the enemy champion to prevent them from last hitting the minions. What do you do in a scenario in which the enemy's harass has a farther range or just better in general? Specifically, I had to mid lane against a Brand with me as Ryze and it was kinda painful. Ryze inherently have a hard time last hitting unless he starts to spam his spells which will often leave him mana-less. When I try to get in range to use my spells, Brand had already used his combo to stun me and gotten back before I can use more than one spell. Is there a strategy I should adopt when playing against a champion who's range and harass is obviously superior to mine?
It is very hard to create a solution to this problem 100% of the time, but there are some tips I can give.
The most important thing is to learn to last hit under a tower. For an average early game:
Obviously this is heavily dependent on champion and changes throughout the game
If Brand is zoning you this hard, he's going to be pushing his wave. Get the CS you can from under your tower (takes practice), and let your jungle know that mid is prime for a gank.
Ryze is more of a late game hero as well. The most common way to build damage is with a teardrop, so rush it and use your spells to last hit as necessary.
As mentioned by Toast in his answer , one of the bigger things to learn is how to last hit under a tower. If an enemy is constantly pushing you to tower, learning the 2T-1 combo for melee minions (2 Tower, 1 auto), and 1-T-1 for caster minions (1 auto, 1 Tower, 1 auto) is essential for keeping your CS up whilst under pressure. CS is arguably one of the most important statistics for champions to improve upon, and mid lane is no exception.
More specifically, to address your question regarding characters with high harassment capabilities, there are several ways you can improve upon.
1) Call for a gank. If you have a jungler, they're the obvious choice to do so. If you aren't running with a jungler in lower level games, either one of the sidelanes can come up and attempt a gank.
2) Punish them when they harass you: harass them back! Typically if an enemy is harassing you, they're opening themselves up to punishment in the form of:
Watching for an opening is crucial to monopolizing on your strengths as a caster in the laning phase. In your example of Ryze vs. Brand, as soon as Brand uses his Pillar of Flame to try to set you alight, you should know that he's looking for an opening to stun you with Fireball. However, if you keep yourself behind minions, he wont be able to do that, and if he tries to come close, you can Q - W - Q combo him. At early levels, most casters are very squishy and have poor sustainability, so even something as simple as 3 spells may very well outright kill them, especially if paired with Ignite.
3) Change your starting items. As Ryze, it's incredibly tempting to start with a Mana Crystal for that extended time in lane and the extra power on your Q and W. However, since many AP champs are strong at harassing with a lot of range and/or spammy spells, it's not always the best option. Boots 1 and 3 health pots is a very safe way to start the game. It allows you that extra speed to dodge skillshots and get out of ground effects, plus 3 "crap I messed up" buttons as opposed to 2 or less. Specifically in the case vs. Brand, dodging his Pillar is the fastest way to put him behind, as it's his only great harassment tool until level 8 or so, when he can start getting more points in E.
4) Get that blue buff. Unless you're a manaless champion like Kennen, Vladimir or Morde in mid, your jungler should be giving you the Blue Golem buff no later than on the 3rd spawn, if not earlier. This depends on the jungler, of course (Fiddlesticks and Amumu are much more mana reliant than others, for example, while Lee Sin and Shyvana don't even use mana), but having Blue buff drastically reduces your reliance on Mana and allows you to harass / last hit with less discretion.
Lastly, and not really a point, but don't be discouraged by certain pair ups. There are a lot of clear winner matchings, and Ryze is one of those champs that suffers a little bit from early game weakness simply because he doesn't have the items to provide him the sustainability that he needs to fall into the chain caster category. Some great champs to learn for mid lane if you want to be the one doing the harassing fall into a few categories: