首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何通过ServiceBehavior配置启用WCF帮助页?

如何通过ServiceBehavior配置启用WCF帮助页?
EN

Stack Overflow用户
提问于 2014-01-28 21:21:10
回答 2查看 5.9K关注 0票数 2

我希望为使用<ServiceBehavior>而不是<EndpointBehavior>配置的WCF服务启用生成的帮助页。95%的搜索结果与<EndpointBehavior>有关,而我为<ServiceBehavior>找到的东西要么没有答案,要么缺乏细节,或者根本不起作用。

我不是此服务的创建者,该服务托管在IIS上,但任务是为该服务启用帮助页。根据我所发现的,我应该能够在ServiceDebug元素下启用ServiceDebug属性,但是这没有任何作用,在浏览器中查看时添加httpHelpPageUrl会破坏整个服务。

Config:相关部分。

代码语言:javascript
复制
<system.serviceModel>  
  <serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true" />
  <bindings>
    <basicHttpBinding>
      <binding name="serviceBinding">
        <security mode="None">
        </security>
      </binding>
    </basicHttpBinding>
    <wsHttpBinding>
      <binding name="serviceWsBinding">
        <security mode="None">
        </security>
      </binding>
    </wsHttpBinding>
  </bindings>
  <client />
  <services>
    <service behaviorConfiguration="ServiceBehavior" name="ServicesLib.Service">
      <endpoint listenUri="soap" name="soap" address="http://servicesdev.mySite.com/services/Service.svc/soap" binding="basicHttpBinding" bindingConfiguration="serviceBinding" contract="ServicesLib.IService" />
      <endpoint listenUri="soap12" name="soap12" address="http://servicesdev.mySite.com/services/Service.svc/soap12" binding="wsHttpBinding" bindingConfiguration="serviceWsBinding" contract="ServicesLib.IService" />
      <host>
        <baseAddresses>
          <add baseAddress="http://servicesdev.mySite.com/services" />
        </baseAddresses>
      </host>
    </service>
  </services>
  <behaviors>
    <!-- These EndpointBehaviors aren't used, they are just here :? -->
    <endpointBehaviors>
      <behavior name="restBehavior">
        <webHttp />
      </behavior>
      <behavior name="soapBehavior">
        <webHttp helpEnabled="true" />
      </behavior>
    </endpointBehaviors>
    <serviceBehaviors>
      <behavior name="ServiceBehavior">
        <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" externalMetadataLocation="../Services.wsdl" />
        <serviceDebug includeExceptionDetailInFaults="true" httpHelpPageEnabled="true" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
</system.serviceModel>

如果无论出于什么原因,这不是正确的方法,也许有人可以为我指明托管自定义帮助页面的正确方向?我一直在阅读这个职位关于从windows服务中托管一个解决方案的文章,但我不知道如何将其添加到WCF服务中,该服务将以同样的方式与该服务一起托管。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-01-28 22:21:29

ServiceDebugElement HttpHelpPageEnabledHttpHelpPageUrl属性提供了启用自定义帮助页的机制。但是,这些属性不会自动告诉服务器生成自定义页。为了提供您自己的自定义帮助内容,您需要为静态html帮助页或返回自定义帮助页的端点提供URL (如您所引用的文章中所讨论的)。

致以敬意,

票数 1
EN

Stack Overflow用户

发布于 2014-01-28 22:20:51

代码语言:javascript
复制
<endpoint listenUri="soap" name="soap" address="http://servicesdev.mySite.com/services/Service.svc/soap" binding="basicHttpBinding" bindingConfiguration="serviceBinding" contract="ServicesLib.IService" behaviorConfiguration="restBehavior" />
      <endpoint listenUri="soap12" name="soap12" address="http://servicesdev.mySite.com/services/Service.svc/soap12" binding="wsHttpBinding" bindingConfiguration="serbviceWsBinding" contract="ServicesLib.IService" behaviorConfiguration="soapBehavior" />

    <endpointBehaviors>  
          <behavior name="restBehavior">
            <webHttp helpEnabled="true"/>
          </behavior>
          <behavior name="soapBehavior">
            <webHttp helpEnabled="true" />
          </behavior>
    </endpointBehaviors>
票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21417110

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档