How do a simplest WCF service work on Win7 with VS2010

Source: Internet
Author: User

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. :)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.