WCF 服务.在哪里添加..svc 文件 [英] WCF service. Where to add . svc file

查看:38
本文介绍了WCF 服务.在哪里添加..svc 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个新的WCF 服务库"类型的项目.我为我的合同创建了一个文件和一个实现接口的文件.这两个文件的扩展名为 .cs.

I have created a new "WCF service library" type project. I have created a file for my contract and one file which implements the interface. Both files have the .cs extension.

请谁能告诉我如何食用它.我的意思是我应该在哪里添加我的 .svc 文件

Please can anyone tell me how can I consume it. I mean where should I add my .svc file

推荐答案

您必须创建另一个项目 - Web 应用程序或 WCF 服务应用程序(通常与 Web 应用程序相同,但添加了一些引用).然后您必须在新项目中引用您的服务库并添加 .svc 文件.从新创建的 .svc 文件中删除代码隐藏文件并打开该文件的标记.修改 @ServiceHost 指令的服务属性.该属性必须指向您在库中实现的服务(带命名空间的全名).然后将配置添加到 web 配置中.

You have to create another project - Web application or WCF Service application (generally it is the same as Web application with some added references). Then you have to reference your service library in the new project and add .svc file. Delete code behind file from newly created .svc file and open markup of that file. Modify Service attribute of @ServiceHost directive. The attribute has to point to your service implemented in library (full name with namespace). Then add configuration to web config.

如果您使用 WCF 4.0,则不必创建配置(将使用默认配置),甚至不需要定义 .svc 文件.WCF 4.0 支持基于配置的激活.

If you use WCF 4.0 you don't have to create configuration (default will be used) and you even don't need to define .svc file. WCF 4.0 supports configuration based activation.

这篇关于WCF 服务.在哪里添加..svc 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆