zoukankan      html  css  js  c++  java
  • How to make a simplest WCF service work on Win7 with VS2010

    You know as a beginner to learn WCF, the first thing is to make a simplest WCF service work like a classic "Hello World" console application. Now I will 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 interface/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 that, 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 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:

    10. Repeat step7 and then click the link "CalculatorService.svc", if you can see the second picture, congratulations!

    11. If you are failed to see above picture, probably some ASP.NET components are not installed, so please first check if the 6 items are existing:

    If not, please make sure below features are installed:

    12. Below is the optional steps, if above doesn't work:

    Run cmd as administrator and then cd to "C:WindowsMicrosoft.NETFrameworkv3.0Windows Communication Foundation", execute below commandline:

    ServiceModelReg.exe -i

    If above step generate any bad impact/result, I mean browse the created WCF service will happen some strange errors, we can rollback by executing below commandline:

    ServiceModelReg.exe -u

    13. Another optional step is(probably it doesn't need to do):

    14. I believe the WCF service is published successfully be above several steps given, from then on, I will create a console applicaiton named "CalculatorClient" to consume the published WCF service.

     

     14. Right click "References" and then select "Add Service Reference...",  input the WCF service address and then click "OK" button:

    15. Add client code to call WCF service, the calling result is showed as below picture, till now our first WCF learning sample is done here. :)

  • 相关阅读:
    用ASP+DLL实现WEB方式修改服务器时间
    参加了 湖南.NET俱乐部成立大会
    Asp.Net中文本换行
    一直在思考的问题
    GRIDVIEW排序 动态实现和静态实现
    在VS 2005中使用TREEVIEW控件
    GRIDVIEW 中当数据行数未满时,填充空白行
    为了自己的心身健康 合理安排生活 特做了张时间安排表
    在VS 2005后台代码中创建用户控件
    CSS IE7 IE6 Firefox多浏览器兼容(转&摘)
  • 原文地址:https://www.cnblogs.com/researcher/p/3775793.html
Copyright © 2011-2022 走看看