I’m learning that one of the biggest hurdles to getting back into the day-to-day development game is that a minor wrong turn can send you down a misguided path for a couple of days. If you’re not coding daily, your development intuition muscle doesn’t respond like it used to. I ran into this issue the other day when trying to consume the Community Megaphone API.
The first hint that I was doing something seriously wrong is when I suggested to Andrew Duthie (developer of Community Megaphone, and Mid-Atlantic Microsoft Developer Evangelist) that his documentation was a bit outdated, and he reacted with surprise. I got the familiar “been-out-of-programming-too-long inferiority complex” feeling in the pit of my stomach, which, by the way, absolutely has to be worked through to get back into programming “shape”.
After a couple of email exchanges, he asked me if I added a web reference to the web service URL of the API. I quickly began my intended response, claiming that I definitely did, when something clicked — this is an “original” web service. An ASMX. Not a WCF service (Andrew wrote it before .NET 3.0 was out). I checked and saw that I added a Service Reference, which was surfaced back in Visual Studio 2008 I believe, and it used to sit side-by-side in the context menu with Add Web Reference. But in VS 2010 (and apparently in VS 2008?), the Web Reference option looks to be deprecated. You now have to select Add Service Reference, click the Advanced button, and then click the Add Web Reference button:
Apparently, my initial selection of Service Reference caused the creation of a proxy where all the classes were appended with “SoapClient”, which totally confused me. The functionality still worked for the most part when instantiating those classes, but I was not making use of the proxy / interface intended for its use. That’s what caused me to claim that the API documentation was wrong.
So the moral of my story is, don’t confuse Service Reference with Web Reference. In the current version of VS you have to get through one to select the other, but if you start noticing “SoapClient” appended to the class names, that should be a hint that you’re referencing a ASMX web service via WCF.
I’m still digging into the mechanics of this behavior. I’m sure there’s a completely logical reason. And when I fully understand it (comments would help here), I will blog about it. But in the meantime, consider this a public service announcement.
And when doing development in .NET 3.0 or later, just use WCF instead.