4

そこで、WCF サービス アプリケーションを作成し、IIS7 でホストしました。現在、いくつかのテスト 'helloworld' メソッドがあります。ブラウザで実行すると、次の画面が表示されます。 ここに画像の説明を入力

現在、サービス自体はうまく機能していますが、次のような操作を表示するにはどうすればよいですか。 ここに画像の説明を入力

リンクの marc_s に感謝します: http://www.dotnetcurry.com/ShowArticle.aspx?ID=399これをたどったので、Web 構成は次のようにセットアップされました。

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <services>
      <service name="WcfServer.Service1">
        <endpoint address="" binding="webHttpBinding" contract="WcfServer.IService1" behaviorConfiguration="HelpBehaviour" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true" />
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="AjaxBehavior">
          <enableWebScript />
        </behavior>
        <behavior name="HelpBehaviour">
          <webHttp helpEnabled="true"/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
        <directoryBrowse enabled="true" showFlags="Date, Time, Size, Extension" />
  </system.webServer>
</configuration>

ただし、これはローカルでのみ機能します。IIS7 のサーバーに発行すると、ヘルプ リンクをクリックすると 404 エラー ページが表示されます。これがなぜなのか、または以前に遭遇したことがある理由を誰かが知っていますか?

(最後のビットは実行して解決しました: aspnet_regiis.exe -iru)

4

1 に答える 1

9

SOAP バインディングを備えた WCF サービスを使用している場合、残念ながらうまくいきません。WCF をそのまま使用して、すべてのサービスで ASMX と同様のリストを取得する方法はありません。

REST バインディング ( webHttpBinding) と .NET 4.0 を使用すると、URI テンプレート、サポートされている HTTP メソッドなどを一覧表示する自動ヘルプ ページを生成できます。そのページをある程度微調整することもできます。

自動ヘルプ ページを生成するには、エンドポイントの動作を定義 (および参照) する必要があります。

<behaviors>
   <endpointBehaviors>
       <behavior name="HelpBehavior">
           <webHttp helpEnabled="true" />
       </behavior>
   </endpointBehaviors>
</behaviors>

次に、webHttpBindingエンドポイントからその動作を参照すれば完了です。

それについてのすべてを読む:

于 2011-02-03T12:19:08.377 に答える