Host Multiple Wcf Services On Local IIS 6

做~自己de王妃 提交于 2019-12-25 06:59:01

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/31515594/host-multiple-wcf-services-on-local-iis-6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!