简体   繁体   中英

How to enable WCF help pages through ServiceBehavior configuration?

I am looking to enable generated Help Pages for a WCF service that is configured with a <ServiceBehavior> instead of a <EndpointBehavior> . 95% of my searches result in something to do with <EndpointBehavior> and what few I do find for the <ServiceBehavior> are either unanswered, lack detail, or simply do not seem to work.

I'm not the creator of this service which is hosted on IIS, but was tasked with enabling the Help Pages for the service. From what I have found, I should simply be able to enable the httpHelpPageEnabled attribute under the ServiceDebug element, but this does nothing and adding httpHelpPageUrl breaks the entire service when viewing in a browser.

Config: relevant section anyway.

<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>

If this is not the right approach for whatever reason, perhaps someone could point me in the right direction of hosting custom Help Pages? I have been reading this post on a solution for hosting one from a windows service but I am unsure of how to add this to a WCF Service that will be hosted alongside the service in the same manner.

The ServiceDebugElement HttpHelpPageEnabled and HttpHelpPageUrl properties provide a mechanism to enable a custom help page. The properties will not, however, automatically tell the server to generate a custom page. In order to provide your own custom help content, you will need to provide a URL for either a static html help page or an endpoint that returns the custom help page (as discussed in the article you referenced).
Regards,

<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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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