简体   繁体   English

在IIS中托管Web服务-无法访问该服务

[英]Hosting Web Service in IIS - Not able to access the service

I have a WCF Service Application project in Visual Studio that contains the following files 我在Visual Studio中有一个WCF服务应用程序项目,其中包含以下文件

  • ZooWebService.svc ZooWebService.svc
  • WebConfig Web配置

I attempted to host the Web Service in IIS but when i browse to my web service from IIS the Web Service does not load at all. 我试图将Web Service托管在IIS中,但是当我从IIS浏览到Web Service时,Web Service根本无法加载。 It just says "loading" in the browser. 它只是在浏览器中说“正在加载”。

Here is my WebConfig file: 这是我的WebConfig文件:

 <?xml version="1.0"?>
    <configuration>
    <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
     </appSettings>
     <system.web>
    <compilation debug="false" targetFramework="4.6.1" />
    <httpRuntime targetFramework="4.6.1"/>
     </system.web>
      <system.serviceModel>
    <services>
      <service behaviorConfiguration="Default" 
     name="WCFWebService.ZooWCFService">
        <endpoint address="" binding="basicHttpBinding" 
     contract="WCFWebService.IZooWCFService" />
        <endpoint address="mex" binding="mexHttpBinding" 
        contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8080/" />
          </baseAddresses>
        </host>
        </service>
      </services>
       <behaviors>
      <endpointBehaviors>
        <behavior name="webBehavior">
          <webHttp />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="Default">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
         </serviceBehaviors>
       </behaviors>
     </system.serviceModel>
     </configuration>

I did the following so what have i done wrong? 我做了以下事情,所以我做错了什么?

  1. Open IIS 打开IIS
  2. Right clicked on Default Website 右键单击默认网站
  3. Selected "Add Application" 选择“添加应用程序”
  4. Populated "Alias" field 填充的“别名”字段
  5. Populated "Physical Path" to directory of where the solution contents are 填充“物理路径”到解决方案内容所在的目录
  6. Clicked OK 点击确定
  7. Rebuilt the solution in Visual Studio 在Visual Studio中重建解决方案

For enabling the WCF in IIS, you may have to enable the HTTP activation feature for the .net framework first. 为了在IIS中启用WCF,您可能必须首先为.net框架启用HTTP激活功能。

Some of links to do this https://docs.sdl.com/LiveContent/content/en-US/SDL%20Tridion%20full%20documentation-v1/GUID-326D6F7B-08EC-43EB-A5A7-9C51DD9E555C 一些链接可以做到这一点https://docs.sdl.com/LiveContent/content/zh-CN/SDL%20Tridion%20full%20documentation-v1/GUID-326D6F7B-08EC-43EB-A5A7-9C51DD9E555C

https://pubs.vmware.com/mirage-56/index.jsp?topic=%2Fcom.vmware.mirage.api.pg.doc%2FGUID-552D845B-E530-4898-A06B-4F73E668BEFF.html https://pubs.vmware.com/mirage-56/index.jsp?topic=%2Fcom.vmware.mirage.api.pg.doc%2FGUID-552D845B-E530-4898-A06B-4F73E668BEFF.html

Once this is done you may try to deploy WCF directly from the visual studio to your local IIS> 完成此操作后,您可以尝试将WCF直接从Visual Studio部署到本地IIS>

Right click on the WCFproject -> go to properties -> in properties window -> select web tab -> in servers section select Local IIS and click on Create Virtual Directory. 右键单击WCFproject->转到属性->在属性窗口中->选择Web选项卡->在服务器部分中,选择本地IIS,然后单击创建虚拟目录。

Now run the WCF from Visual studio, this will host the WCF in local IIS. 现在从Visual Studio运行WCF,它将在本地IIS中托管WCF。

样品

We don't need to specify the base address in the configuration file which needs to be set up in the web site binding module. 我们不需要在配置文件中指定需要在网站绑定模块中设置的基地址。
https://social.msdn.microsoft.com/Forums/vstudio/en-US/d42fc165-052d-476a-9580-1240b3d0293d/specify-endpoint-in-wcf-webconfig?forum=wcf https://social.msdn.microsoft.com/Forums/vstudio/zh-CN/d42fc165-052d-476a-9580-1240b3d0293d/specify-endpoint-in-wcf-webconfig?forum=wcf
then we should enable the WCF feature in the IIS. 那么我们应该在IIS中启用WCF功能。 在此处输入图片说明
At last we could see the web service description in http://ip:port/xxxx.svc . 最后,我们可以在http:// ip:port / xxxx.svc中看到Web服务描述。 在此处输入图片说明 Feel free to let me know if there is anything I can help with. 请随时告诉我是否有什么我可以帮助的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM