WSDL returning a valid response but object is null
Saturday, November 01, 2008 6:28:49 PM (GMT Standard Time, UTC+00:00)
We had an interesting problem the other day while integrating with a web service hosted on an apache server. Every time we called the WSDL methods we could see a valid request being sent and a valid response being returned (ok there were a few syntax errors but nothing that would stop it converting) but despite this every time, without fail, it would return null at code level.
The solution was actually amazingly simple. In short, since our last flurry with web services we've upgraded to Visual Studio 2008 and installed ReSharper (see below for how that's relevant). In VS2008 they've sneakily added a new menu "Add Service Reference" and although it's in the same menu location and a similar wording etc does something different. If you add your WSDL reference this way it will more than likely fail.
To add a "Web Reference" in Visual Studio 2008 follow the instructions below and hopefully you won't go down the same routes that I did trying to debug the XML...
Click the "Add Service Reference" menu option (obviously!)
The screen below should appear, instead of entering the address of the web service into the address bar, click the advanced button at the bottom (highlighted)
That'll then bring up the screen below, on which you need to click the "Add Web Reference" button at the bottom.
You should then be presented with the usual "Add Web Reference" screen (see below).
Why did I mention ReSharper? Well I've notice that as well as adding to the IDE they've also updated some of the menu items, most noticeably "Go to Definition" which is now "go to Declaration" (see below) so I figured this new menu option was thanks to them.
So the next time your WSDL is returning a null object even though a valid response is being retrieved, check how you added it in Visual Studio,.