Know as a beginner to learn WCF, the first thing are to make a simplest WCF service work like a classic "Hello World" C Onsole application. Now I'll introduce the steps by following:
1.Create a "WCF application Service" like this:
2. Rename the ' IService1 ' to ' icalculatorservice ' and ' Service1 ' to ' CalculatorService ' for both project file name and int Erface/class name in source code, and then update the generated code by default to following:
3. Set as Start page for "Calculatorservice.svc" and then hit F5 to lauch the wcfservicetestclient
4. Open IIS and "Sites->add Website ...", click OK button as below:
5. Right click the new added site and select "Add Virtual Directory ...", after then, switch to "Content View" you can see Below
6. Right click the new added virtual directory ' Calculator ' and then select ' Convert to Application ', click OK button
7. Right click on the converted "Calculator" and then "Manage Applicataion->browse"
8. If happen below error, need to change the application Pool's. NET Framework version to 4.0 as following:
9. If happen below error, need to enable the "Directory browsing" as the guided steps:
Repeat STEP7 and then click on the link "calculatorservice.svc" If you can see the second picture, congratulations!
If you is failed to see above picture, probably some ASP is not installed, so please first check If t He 6 items are existing:
If not, please make sure below features is installed:
Below is the optional steps, if above doesn ' t work:
Run cmd as Administrator and then CD to "C:\Windows\Microsoft.NET\Framework\v3.0\Windows communication Foundation", EXECU Te below commandline:
Servicemodelreg.exe-i
If above step generate any bad Impact/result, I mean browse the created WCF service would happen some strange errors, we CA n rollback by executing below commandline:
Servicemodelreg.exe-u
Another optional step is (probably it doesn ' t need to do):
I believe the WCF service is published successfully are above several steps given, from and on, I'll create a consol E Applicaiton named "Calculatorclient" to consume the published WCF service.
Right click "References" and then select "Add Service Reference ...", input the WCF Service address and then click "OK "Button:
ADD client code to call WCF service, the calling result was showed as below picture, till now our first WCF Learning SA Mple is do here. :)