tags:

views:

42

answers:

2

How can we consume WCF service in .Net 2.0 Winform. Please note that we don't have IIS on the client. an example or a sample would be great.

+1  A: 

It all depends on how your WCF endpoints are configured.

If you're using SOAP based WCF Services over HTTP, you should be able to simply add a Service Reference from your .NET 2.0 WinForms application and be on your way (which is what I would suggest doing).

If that's not the case, you'll have to provide a little more detail about what you're trying to do with your WCF Services.

Justin Niessner
I have full freedom to configure WCF service. What I can't get my head around is how .Net 2.0 will be able to access the service if it's not hosted in IIS?
Sheraz
+1  A: 

You can host your WCF service in a Windows Service as per this article. In that case, it will listen on the HTTP protocol on any port you configure.

Jesse C. Slicer
@Sheraz: it doesn't matter to the client where the WCF service is hosted. As long as the WCF service is configured for `basicHttpBinding` and as long as it is configured to expose the WSDL through HTTP, you can just use "Add Web Reference" in your .NET 2.0 project to consume it.
John Saunders
Thanks John, I'm gonna give it a shot.
Sheraz
Jesse, I'm trying it now. Thanks for the link
Sheraz
Jesse: I am able to host the service in windows service. In .Net 2.0 solution, I can see it by using Add Web Reference and giving it the url. What I"m not able to figure out is what to do next. it says to use svcutil.exe to create the client. When I use it, it creates a client class that refers to System.ServiceModel which is supporterd in .net 3.0. Funny thing is that this file on top says that "This code is generted by a tool Runtime Version: 2.0..." What am I missing. Thanks
Sheraz
Do what John Saunders said in the first comment: Don't use svcutil.exe, use "Add Web Reference" (or at the very least, use wsdl.exe instead). You will then have a proxy class in your project that will allow you to connect to the web service. Your class should be similarly named. So you can, on the client do `ServiceClient client = new ServiceClient(); client.DoOperation();` or whatever it's called.
Jesse C. Slicer