Level 1
I think you’re better off taking your first level in Fighter, or an alternative, than Artificer. It’s a difference between more HP and more skills, but I don’t think you’re going to use a lot of skills beyond Craft and Use Magic Device. But I’d probably rather something better than Fighter...
Problems with Fighter
I don’t think Fighter offers very much here. The class is generally quite poor, and only a good idea if there are a series of specific feats you have in mind that you cannot get any other way.
Note that tanking in 3.5 is not easy; the system does not offer very many ways to do it effectively. You cannot simply be capable of taking a lot of damage, you also have to be able to handle a wide variety of magical effects so you cannot get sidelined, and you need to be a real threat in your own right so you don’t get ignored.
Fighter can offer these things with very careful feat selection, but there are better ways. You don’t need proficiency in any particular armor, you’re not using Tower Shields, and Base Attack Bonus and large HD are available on other, better classes. The Fighter’s notoriously weak Will save (that 12 is quite likely to go into Wisdom) mean that spellcasters may be able to very trivially prevent you from protecting anyone.
If you insist on Fighter, though, you can do a lot to salvage the class by using the Dungeoncrasher alternate class feature in Dungeonscape. Get Improved Bull Rush, Shock Trooper (Complete Warrior), and go to town on enemies. If you go this route, you’ll want exactly 6 levels of Fighter. At which point, you’ll qualify for Warforged Juggernaut, which I strongly recommend here.
Alternative Martial Base Classes
Just from Core classes, Barbarian is a very good choice. You cannot use Infusions while Raging, but most melee Artificers are about long-term buffs, which don’t go away when you Rage. If you have Complete Champion, you can get Pounce instead of Fast Movement: getting the ability to move and full-attack is paramount to your ability to actually be threat enough to draw enemies’ fire away from your allies.
Of course, as is usually the case in these discussions, Crusader and Warblade from Tome of Battle are far superior choices. The Crusader, in particular, gets some of the very-few true aggro-controlling abilities in the game.
For completeness, I’ll also point out the Knight from Player’s Handbook II. It’s unfortunately rather underwhelming, but Test of Mettle is one of the other very few aggro-controlling abilities in 3.5. It’s got a lot of limitations, lots of things are immune to it, and the DC depends on Knight levels (of which, most are bad) and Charisma (which Warforged take a penalty to), so I don’t really recommend Knight.
Recommended Prestige Classes
The Warforged Juggernaut from Eberron Campaign Setting is an excellent choice for prestige class, regardless of how you start. The immunities it gives you are great for not getting sidelined too easily. It’s prerequisites are also ideal for a Dungeoncrasher; a Dungeoncrasher Fighter 6/Warforged Juggernaut 10 is a pretty solid, simple build. I wouldn’t bother with Artificer as a Dungeoncrasher, though; you won’t be able to fit in enough levels to make it worth it.
If you do go with a Barbarian/Artificer, you may find Rage interfering with your infusions/magic items. There is no official way around this, but you might ask your DM if you could adapt Rage Mage (Complete Warrior) to allow you to enter with 2nd-level Infusions instead of 2nd-level Spells, and have Spell Rage apply to infusions and magic items instead of spells. It’s a pretty minor change, and Rage Mage is hardly an amazing class, so it might fly. Personally, though, I think it’s unnecessary; simply being careful about when you start to Rage should be enough. Combat Casting is a pretty obnoxious feat tax.
Something Different: Straight Artificer
I’d also seriously consider straight Artificer, since the Warforged substitution levels in Races of Eberron are quite good. Your base HP will be low (but you should have high Constitution), and ¾ BAB will hurt (but probably not as much as you think), but personally I’d want to get Artificer 5 sooner rather than later. Artificers also get pretty solid tanking abilities, since they can get things like wand of shield other, and various survival spells and infusions. Magic items can go a very long way to shoring up the Artificer’s weaknesses (actually, at high levels of optimization, the Artificer is one of the strongest classes in the game, and capable of utterly devastating any of the other classes I’ve mentioned in this answer; that’s non-trivial to accomplish though).
Personal Suggestion
I'd probably dip Barbarian, take Artificer long enough to get some useful abilities, and then go with Warforged Juggernaut. You don’t quite qualify for Juggernaut as a Barbarian 1/Artificer 5, so a dip into Crusader for some maneuvers would be a good idea. Alternatively, I might drop that level into Rage Mage if I could convince my DM to allow the adaptation, but only if I really felt the like Rage was interfering too much; I don’t think it would really.
So I’d plan on something like Barbarian 1/Artificer 5/Crusader 1/Warforged Juggernaut 10 or Barbarian 1/Artificer 5/Rage Mage 1/Warforged Juggernaut 10.
If Fighter needs to be a part, I’d go Fighter 6 with Dungeoncrasher, and never look back: I’d enter Warforged Juggernaut at that point, and if I finished it, I’d find something else to do. Without Dungeoncrasher, I think Fighter levels are largely a waste of time.
“There is no point in doing this [from a game mechanic perspective].” The sorcerer is just the stronger class, and even the feature-heavy first level of bard does not compare to simply having better spells sooner (see 1. Spellcasters should not multiclass in this answer for more details). Thus, the best mix of nine levels for bard or sorcerer is Sorcerer 9. That said...
Sublime Chord
The best way to multiclass bard and “sorcerer” is to not have any sorcerer levels at all, but rather take the sublime chord prestige class from Complete Arcane. This class requires Bardic Mustic and 3rd-level spells, but rather than progress bard spellcasting, it has its own spellcasting with 3rd- to 9th-level spells from the bard and sorcerer/wizard lists. This spellcasting is Charisma-based and spontaneous. It also progresses bardic music, and gives several special “magic themed” songs.
So a Bard 10/Sublime Chord 10 casts as a 10th-level bard and also has separate spellcasting with spells of up to 9th-level that come from the sorcerer/wizard spell list (or bard list). It has the ability with music of a 20th-level bard, except some of the songs are changed to be more “magic themed.”
Since spellcasting is the only sorcerer class feature aside from the familiar, having spontaneous Charisma-based spellcasting off of the sorcerer/wizard list, and then taking the Obtain Familiar feat, makes you effectively identical to a sorcerer. But this progression is much smoother, you end up with level-appropriate power at higher levels, and sublime chord is really cool. The only problem here is that, before 11th level when you take your first level of sublime chord, you have no mechanical representation of being a sorcerer. But bard and sorcerer spellcasting are fairly similar, and you can take Obtain Familiar at Bard 1, so it should be easy to continue to call yourself a sorcerer at lower levels.
Spellswording
Worth mentioning: Champions of Valor has a variant paladin, the harmonizing knight, that gets Inspire Courage +1, 1/day instead of at-will detect evil at 1st level. In the Forgotten Realms, this requires you to worship Milil, a goddess of music; in other settings, it would have to be adapted to some appropriate patron. Anyway, all paladins get the excellent Divine Grace at 2nd level, adding Charisma bonus to all saving throws. As such, Paladin 2/Bard 8/Sublime Chord 10 becomes an excellent variant on the above build: you trade 1 daily use of Inspire Courage for full martial weapon proficiency, a bit more HP, +1 BAB, and adding your Charisma bonus to all saving throws. Since your Charisma should be high, that is a very nice bonus. Adding paladin is not an option for all characters, of course, but if it is, do consider it.
For spellswording as a bard, whether you dip paladin or not, I strongly recommend the Snowflake Wardance feat from Frostburn, if you have that book. Other excellent options include the harmonizing weapon property and crystal echoblade weapon from Magic Item Compendium.
Finally, if you have Tome of Battle, taking a level of crusader for the Song of the White Raven feat is an awesome option, dramatically amping up your physical prowess while allowing you to start performing Inspire Courage as a swift action. It also opens up the interesting possibility of using the jade phoenix mage prestige class to advance sublime chord spellcasting, which would be ideal. Note that Paladin 2/Bard 7/Crusader 1 still just qualifies for sublime chord, too, if you want to do both. I recommend taking the crusader level at precisely 9th level, so you can simultaneously take Song of the White Raven, and have Initiator Level 5 so 3rd-level maneuvers and stances are available to you.
Race
Generally speaking, race isn’t all that important; human is probably your best bet just because bonus feats are awesome. But anything without a penalty to Charisma or Constitution is probably fine (bonuses to Charisma are really rare and always paired with a penalty to Constitution, so there is little to be gained there). Even penalties to Charisma or Constitution are bearable, but why would you?
However, in the case of anyone with bardic music, the benefits of being a dragonblooded race have to be mentioned. And since there’s a dragonblooded human race, silverbrow humans from Dragon Magic are almost-certainly your best option. They trade the humans’ bonus skill point for the Dragonblood subtype, which among other things qualifies you for the excellent Dragonfire Inspiration feat from the same book. Highly recommended.
See Also
Best Answer
Build him by feel
SevenSidedDie has an excellent answer about why there's no definitive Gandalf build, but I think we can talk constructively about how to go creating a Gandalf build.
You want to "recreate Gandalf from the books" "in D&D3.5 terms." You can't, not precisely. D&D isn't a good fit at all for actually recreating LotR scenarios or characters: it has a different mythos, a different philosophy toward magic, and is built with mechanical considerations that Tolkien didn't have to worry about.
But we can create D&D characters who are like LotR characters. This is going to require choosing what to keep or emphasize, and what isn't as important so it can be left behind or diminished. We won't be making a character who can accomplish exactly what Gandalf could accomplish --no more, no less-- in the novels. We'll be making a Gandalf who is Gandalf in essence rather than in detail.
What defines Gandalf to you?
Because of the limitations of D&D build options, you'll have to focus on one particular "kind" of Gandalf. Deciding what kind of Gandalf you want to design needs to be deliberate and purposeful, and you'll need to own that decision.
If you were asked to describe Gandalf in a phrase of five words or less, what would you say? If he's an "ancient, angelic guardian of hope," you're going to build him differently than if he's a "crafty and manipulative magical hobo." Both are absolutely true descriptions of him, but each emphasize a different element of his character.
What does this say about race and/or templates?
Gandalf could be a human, an aasimar, a half-celestial, or a number of other choices depending on what kind of Gandalf you've chosen to make. Don't be concerned about whether it's an accurate representation of a Maia clothed in mortal flesh; get the race or template that best reflects the phrase that describes your personal Gandalf.
What does this say about how he gets things done?
What are your Gandalf's goals and how does he accomplish them? Does he ride a white horse at dawn to bring hope to the hopeless, or does he throw flaming pinecones at wolves? Is he a self-sacrificial hero or a guy who pranks his friends by throwing a party at their house without telling them?
The answers to this question will tell you a lot about his class and build. I think of Gandalf as a guy who gets other people to do things, but can handle himself in a pinch, so I consider him a bard.
Don't be afraid to go off canon
If your Gandalf is a powerful spellcaster, forget trying to map his powers in the books to D&D spells. Make him a powerful spellcaster by D&D standards, so he is deserving of the proper eldritch respect.
This is the essence of my advice: Don't try to recreate what Gandalf can do. Recreate the essence of who he is and what he means. At the end of the day we don't remember him as the level 5 human wizard who cast shatter on a bridge; we remember him as the man who sacrificed himself to a terrible monster so his friends could get away.