WCF服务的IIS托管(应用程序)

基本思路

建立与发布参考网站托管

在IIS中某一网站,选择添加应用程序

image

访问服务uri:
http://localhost/wcfAppTest/Service1.svc
wcfAppTest/Service1.svc 别名+.svc
访问具体的服务
http://localhost/wcfAppTest/Service1.svc/service/GetData/23
/service/GetData/23 endpoint中的address/方法名/参数

比网站托管多了一个wcfAppTest

配置文件参考

  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
  </system.web>
  <system.serviceModel>
    <bindings>
      <webHttpBinding>
        <binding name="NewBinding0" />
      </webHttpBinding>
    </bindings>
    <services>
      <service name="WcfService4.Service1">
        <endpoint address="/service" behaviorConfiguration="web" binding="webHttpBinding" bindingConfiguration="" contract="WcfService4.IService1" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 -->
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="web">
          <webHttp />
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <!--<protocolMapping>
        <add binding="basicHttpBinding" scheme="http" />
    </protocolMapping>-->
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <!--
        若要在调试过程中浏览 Web 应用程序根目录,请将下面的值设置为 True。
        在部署之前将该值设置为 False 可避免泄露 Web 应用程序文件夹信息。
      -->
    <directoryBrowse enabled="true" />
<!--以下是IIS托管后自动添加的部分-->
        <handlers>
            <remove name="ISAPI-dll" />
            <add name="test2" path="*.svc" verb="*" modules="IsapiModule" scriptProcessor="D:\WcfService4\bin\WcfService4.dll" resourceType="File" preCondition="bitness32" />
            <add name="test" path="*.dll" verb="*" modules="IsapiModule" scriptProcessor="D:\WcfService4\bin\WcfService4.dll" resourceType="File" preCondition="bitness32" />
        </handlers>
  </system.webServer>

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,973评论 19 139
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 173,447评论 25 708
  • Spring Boot 参考指南 介绍 转载自:https://www.gitbook.com/book/qbgb...
    毛宇鹏阅读 46,969评论 6 342
  • 长夜思,弯月愁 千般思量,何处不舍亭楼 雨夜浸润,秋霜来后 应是满城孤寂却奈何酒漫伊愁 漫伊愁,何人嗅 明月不解风...
    帅气的大西瓜阅读 254评论 1 3
  • 将浮躁和混乱过滤,回归童年般的简单诚挚,大概就是通往宁静的路了。 2017.8.27 星期天 晴 一 早晨上班,...
    xhy0606阅读 365评论 5 7