在本地IIS 6上托管多个Wcf服务 [英] Host Multiple Wcf Services On Local IIS 6

查看:73
本文介绍了在本地IIS 6上托管多个Wcf服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试了很多有关Google的工作,以找到解决方案,以了解如何在本地IIS 6上托管多个WCF Web服务.

所以我在这里问.如果我可以采取程序的话,那我会很高兴的.

解决方案

要实现您的目标,这是方法:

  • 创建新的解决方案,或仅重用现有的解决方案.
  • 在Visual C#下创建新项目,然后选择WCF服务应用程序.出于示例目的,我们将其命名为MultipleHostService项目.
    • 它将生成名为IService1.cs,Service1.svc和Web.config的三个文件
  • 在MultipleHostService项目下,在Visual C#下添加另一个新项.选择WCF Service,并保持名称不变.
    • 它将添加两个名为Iservice2.cs和Service2.svc的文件
  • 打开您的Web.Config添加行为和绑定"配置,并以红色框突出显示.

如果您注意到我们在其下添加了 Services节点 service ?这就是允许我们指定多种服务的部分.

我使用的工具和设置:

  • Visual Studio 2013
  • IIS 7
  • .Net Framework 4.5

改进:

  • 您可以重构服务的正确命名.
  • 删除配置文件中不必要的XML节点,例如未使用的行为.

免责声明:我尚未使用IIS 6对其进行过测试,但我确信它可以在IIS7上运行.关于IIS的配置不是本主题的一部分,因此您可以运行一些我不知道的问题.还有其他一些方法可以完成服务的多个宿主,但是本主题重点是使用配置文件.并请对适当的绑定,行为和MetaDataExhange进行一些研究,这些我在这里没有讨论.

I have tried to google a lot to find a solution to how to host multiple WCF web services on local IIS 6.

So i am asking here. If I can get a step of procedure then i would be glad.

解决方案

To accomplish your goal this is how to do it:

  • Create your new solution or just reuse current solution you have.
  • Create new Project under Visual C# and select WCF Service Application. For sample purposes we name it MultipleHostService project.
    • It will produce three files named IService1.cs, Service1.svc and Web.config
  • Under your MultipleHostService project add another New item, under Visual C# Select WCF Service and leave name as is.
    • It will product addition two files named Iservice2.cs and Service2.svc
  • Open your Web.Config add Behaviors and Binding configuration highlighted with red box.

If you notice we added Services node and service under it? That is the part that allows us to specify multiple services.

Tools and settings I've used:

  • Visual Studio 2013
  • IIS 7
  • .Net Framework 4.5

Improvements :

  • You can refactor proper naming for your services.
  • Remove unnecessary XML node in the configuration file like unused behavior.

Disclaimer : I haven't tested it using IIS 6 but I'm confident that it works on IIS7. Configuration about IIS is not part of this topic so you migt run some issues which I'm not aware of. There are also some other ways to accomplish multiple hosting of services but this topic is focusing on usage of configuration file. And please do some study on proper Bindings, Behavior and MetaDataExhange which I didn't discuss here.

这篇关于在本地IIS 6上托管多个Wcf服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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