当前位置: 动力学知识库 > 问答 > 编程问答 >

c# - Host Multiple Wcf Services On Local IIS 6

问题描述:

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.

  • Now click MultipleHostService project

    • Click Properties
    • Click Web Tab
    • In the Servers panel
    • Select Local IIS in the dropdown list
    • And under Project URL type this : http://localhost/MultipleHostService "You can change it later on if you want"
    • And click Create Virtual Directory.
  • Build the Project MultipleHostService ( Make it sure no failed shown in Error List )

  • Go to browser and type the follow:
    • http://localhost/MultipleHostService/Service1.svc
    • http://localhost/MultipleHostService/Service2.svc
  • You should see something in the browser like this:

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.

分享给朋友:
您可能感兴趣的文章:
随机阅读: