1.Confirm IIS is enable in local
2.Confirm WCF Service is enable in IIS
3.Add a Site in Application pool
4.Add Mime Type of svc File in IIS
Open Vs command :
C:\> DISM /Online /Enable-Feature /FeatureName:WCF-HTTP-Activation C:\> DISM /Online /Enable-Feature /FeatureName:WCF-HTTP-Activation45
1. before publish WCF service , confirm you arerunning as administrator opened visual studio .
2. For Win8 + vs2010 , Need to install vs2010 SP1 , For win8 , another choice is using vs2012
1.Add Service Reference
static void Main(string[] args) { var proxy = new ServiceReference1.LocalWcfClient(); var result = proxy.GetData(1); Console.WriteLine(result); Console.ReadLine(); }
2.Using channel Factory
Config :
<system.serviceModel> <bindings> <basicHttpBinding> <binding name="BasicHttpBinding_ILocalWcf"/> </basicHttpBinding> </bindings> <client> <endpoint address="http://localhost:80/WcfLocalTestService.svc" binding="basicHttpBinding" contract="LocalWcfTestLibrary.ILocalWcf" name="BasicHttpBinding_ILocalWcf"/> </client> </system.serviceModel>
Code:
static void Main(string[]args) { var proxy = new ChannelFactory<ILocalWcf>( "BasicHttpBinding_ILocalWcf").CreateChannel(); var result = proxy.GetData(1); Console.WriteLine(result); Console.ReadLine(); }
3.Using wsdl.exe generate WSDL proxy
a.
wsdl.exe /out:(no space)proxy.cs(exist file) http://localhost/localWcfService1.svc?wsdl
b.add proxy.cs into project
c.invoke:
static void Main(string[] args) { var proxy = new WcfLocalClient(); var content = proxy.GetData(2, true); Console.WriteLine(content); Console.ReadLine(); }