繁体   English   中英

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

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

我在Visual Studio中有一个WCF服务应用程序项目,其中包含以下文件

  • ZooWebService.svc
  • Web配置

我试图将Web Service托管在IIS中,但是当我从IIS浏览到Web Service时,Web Service根本无法加载。 它只是在浏览器中说“正在加载”。

这是我的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>

我做了以下事情,所以我做错了什么?

  1. 打开IIS
  2. 右键单击默认网站
  3. 选择“添加应用程序”
  4. 填充的“别名”字段
  5. 填充“物理路径”到解决方案内容所在的目录
  6. 点击确定
  7. 在Visual Studio中重建解决方案

为了在IIS中启用WCF,您可能必须首先为.net框架启用HTTP激活功能。

一些链接可以做到这一点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

完成此操作后,您可以尝试将WCF直接从Visual Studio部署到本地IIS>

右键单击WCFproject->转到属性->在属性窗口中->选择Web选项卡->在服务器部分中,选择本地IIS,然后单击创建虚拟目录。

现在从Visual Studio运行WCF,它将在本地IIS中托管WCF。

样品

我们不需要在配置文件中指定需要在网站绑定模块中设置的基地址。
https://social.msdn.microsoft.com/Forums/vstudio/zh-CN/d42fc165-052d-476a-9580-1240b3d0293d/specify-endpoint-in-wcf-webconfig?forum=wcf
那么我们应该在IIS中启用WCF功能。 在此处输入图片说明
最后,我们可以在http:// ip:port / xxxx.svc中看到Web服务描述。 在此处输入图片说明 请随时告诉我是否有什么我可以帮助的。

暂无
暂无

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

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