The word is generally used with negative connotations, but sometimes a bit of fanservice can be a good thing, at least when done right by the right people.
Monday night's episode of "Castle", "The Final Frontier", is a perfect example of how to do fanservice right. The episode was chock full of references to "Firefly", the series that launched Nathan Fillion's career, and other sci-fi and fantasy shows, movies, books and more. I counted at least four direct or indirect references to "Firefly" itself within the first 10 minutes of the show, each one making me more giddy than the last.
The reason the fanservice worked is because the episode didn't exist to support the fanservice, the fanservice supported the episode. Sure, it was a little convenient that Kate had been a cosplaying sci-fi geek in her past, but it's not like that was the crux of the episode. It was a fun thing the creators -- including director Jonathan Frakes (who had a great cameo early in the episode) -- threw in there.
"Castle" has had success doing this in the past. There have been multiple "Firefly" references, the most notable of which had to be Fillion's Halloween costume where he dressed up as a "space cowboy". There was an episode investigating a murder of a comic book artist/real-life superhero, a "vampire" episode... it goes on and on. This episode was more direct with its references, but it's not out of character for the show to do this.
What made this episode more amazing was that it was one of the lighter and breezier episodes of "Castle", coming just a week after what had to be one of the darkest and heaviest episodes the show has ever done. That "Castle" can bounce back and forth between two disparate methods of entertainment is a testament to the characters on the show and the actors playing them. Not many procedurals could pull off having one of its main characters accused of murder one week then set an episode at a sci-fi convention a week later. Few would even try. That "Castle" does is what makes it worth watching every week.