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:\Windows\Microsoft.NET\Framework\v3.0\Windows 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. :)

How to make a simplest WCF service work on Win7 with
VS2010

时间: 2024-11-07 03:08:49

How to make a simplest WCF service work on Win7 with VS2010的相关文章

如何创建一个AJAX-Enabled WCF Service

  原创地址:http://www.cnblogs.com/jfzhu/p/4041638.html 转载请注明出处   前面的文章中介绍过<Step by Step 创建一个WCF Service >以及<如何使用WCF的Trace与Message Log功能>,本文介绍如何创建一个AJAX-Enabled WCF Service. (一)创建一个WCF AJAX-enabled service 1. 打开Visual Studio 2012,创建一个ASP.NET Empty

ASP.NET MVC提交一个较复杂对象至WCF Service

前一篇<jQuery.Ajax()执行WCF Service的方法>http://www.cnblogs.com/insus/p/3727875.html 我们有练习在asp.net mvc应用程序中,POST 数据去wcf service并执行方法.本篇的练习是提交较复对象至wcf service执行方法.前一篇中,它只传递两个参数.如果我们平时开发,需要传递过多的参数时,那得需要写很多个参数.因此产生此篇,把较多个参数,创建为一个对象.然后只传递这个对象至wcf service即可. 下面

用JavaScript调用WCF Service

原文:用JavaScript调用WCF Service 原创地址:http://www.cnblogs.com/jfzhu/p/4039604.html 转载请注明出处 前面介绍过<Step by Step 创建一个WCF Service>和<使用WCF的Trace与Message Log功能>,本文介绍一下如何用JavaScript来调用WCF Service. WCF Service的代码如下: IHelloService.cs using System.ServiceMode

WCF Service Configuration Editor的使用

WCF Service Configuration Editor的使用 2014-06-13 通过WCF Service Configuration Editor的配置修改Client端 在上篇文章创建一个简单的WCF程序中, 使用WCF Service Configuration Editor工具生成XML文件来进行WCF的配置,而不是在CS文件中敲代码. 通过WCF Service Configuration Editor的配置 返回 以下是使用WCF Service Configurati

WCF Service Configuration Editor的使用【转】

原文:http://www.cnblogs.com/Ming8006/p/3772221.html 通过WCF Service Configuration Editor的配置修改Client端 参考 在上篇文章创建一个简单的WCF程序中, 通过编码的方式进行终结点的添加和服务行为的定义,但在进行真正的WCF应用开发时,一般会直接是通过配置的方式进行. 对于初学者来说,WCF的配置显得过于复杂,直接对配置文件进行手工编辑不太现实.在这种情况下,可以直接使用VS提供的配置工具WCF Service

MVC应用程序使用Wcf Service

原文:MVC应用程序使用Wcf Service 前一篇Insus.NET有演示过MVC应用程序使用Web Service, 此篇Insus.NET想继续演示Service,不过是WCF Service. 两者实施起来,多少有些不一样. 在Services目录下,创建一个Calculator.svc 服务.创建成功之后,它会生生成一个接口以及一个svc的文件: 在Calculator.svc中,它是实作上面的接口,而且均实现了四个方法: WCF Service创建好之后,正常的话,它能浏览: 下面

不写画面的网页程序设计,Web API、Web Service、WCF Service

客户有一个系统,经常要连上我方,查询数据 以前的作法是给对方一个账号,让他可以连上我们的DB来查询. 所以,早期的同仁,真的给他们DB链接字符串 客户的Windows程序.网站就真的靠这么危险的方式,连上我们公司的DB. 但怎么想都觉得危险,而且...... 如果对方SQL指令乱下,把效能搞得更烂,岂不是惨兮兮? 如果对方不小心,配置文件被偷走,看到我方DB Connection String怎么办? 几年前的 Internet还没有那么大的带宽,所以还得种种限制,避免他们一次查询太多数据 我接

Fixing common issues when hosting a .NET 4.0 WCF service in IIS 7

http://sandrinodimattia.net/fixing-common-issues-when-hosting-a-net-4-0-wcf-service-in-iis-7/ Until today I never had to host a WCF service in IIS… I always prefered using a ServiceHost in a Windows Service. Before getting my service up and running I

WCF - Hosting WCF Service

After creating a WCF service, the next step is to host it so that the client applications can consume it. This is known as WCF service hosting. A WCF service can be hosted by using any of the four ways given below: 在创建wcf服务后,下一个步骤就是托管该服务,确保客户端应用可以使用它