2014-01-28 46 views
2

我正在尋找爲使用<ServiceBehavior>而不是<EndpointBehavior>配置的WCF服務啓用生成的幫助頁面。我的搜索結果中有95%與<EndpointBehavior>有關,我發現<ServiceBehavior>的內容很少或者沒有答案,缺少詳細信息,或者根本看起來不起作用。如何通過ServiceBehavior配置啓用WCF幫助頁面?

我不是IIS上託管的此服務的創建者,但其任務是爲該服務啓用幫助頁面。從我發現的情況來看,我應該可以簡單地啓用ServiceDebug元素下的httpHelpPageEnabled屬性,但這不起作用,並且在瀏覽器中查看時添加httpHelpPageUrl會中斷整個服務。

配置:無論如何。

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

如果這不是無論什麼原因,正確的方法,也許有人可以點我在託管自定義幫助頁面的正確方向?我一直在閱讀this post的解決方案,以從Windows服務託管一個解決方案,但我不確定如何將此添加到以相同方式與服務一起託管的WCF服務。

回答

1

的ServiceDebugElement HttpHelpPageEnabledHttpHelpPageUrl屬性提供一個機制,使自定義幫助頁面。但是,這些屬性不會自動告訴服務器生成自定義頁面。爲了提供您自己的自定義幫助內容,您需要爲靜態HTML幫助頁面或返回自定義幫助頁面的端點提供一個URL(如所引用的文章中所述)。
Regards,

+0

明天我會更加註意這條路,因爲我想我可能不得不走這條路。 – WebDevNewbie

+0

在做了一些進一步的研究之後,我們現在決定使用靜態html頁面。感謝您對此的澄清。 – WebDevNewbie

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

這兩個端點都是肥皂,嘗試使用您發佈的代碼會產生額外的錯誤。 「'*'上的端點沒有與無消息版本的綁定,'* .WebHttpBehavior'僅用於WebHttpBinding或類似的綁定。」通過搜索,看起來好像SOAP端點根本不能具有'webHttp'行爲,所以EndpointBehaviors不起作用。 – WebDevNewbie