Friday, March 7, 2008

Adding a WebReference to a Windows Forms Application in VS2008

I'm on a blog posting frenzy this week, since I'm not training :) What with country elections rapidly approaching this weekend!!

So adding a webreference was very straight forward in VS2005, just right click the project and select Add WebReference.

In VS2008 it is still easy if you are making the reference from a Website ASP.NET app, but try and do it from Windows!!! This is usually one of my favourite demos to show how VS makes it so easy for a windows forms to consume data server across the web. Well we all know that SOA is upon us and so the asnwer is in just that. Ideally we would have a WCF app to consume, not the Webservice directly.

We could go down this route but I will save that for another post ;) To do it the 'old way' we start with a right click on the project and select Add Service Reference. You should now see a new window like this.

Two options exist: The WS way or the WCF way.
  • Clicking Discover will find the Webservice in the solution and create a Service reference that must be consumed via the WCF route.
  • The other way is to click Advanced at the bottom and then select WebService. The rest should be very familiar!!

    What's really interesting is that fact that once you have one WebService Reference you can now do it the old way!!! Right click and you get the image below !!

No comments: