1

WebHttpBindingを使用してRESTサービスを開発しています。私のサービスではすべてが完璧ですが、実行中はそれが得られError Endpoint not Foundます。

web.configファイルは次のようになります。

 <configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0"/>
  </system.web>
  <system.serviceModel>
    <services>
      <service name="Service">
        <endpoint address="http://localhost:10492/Service.svc" binding="webHttpBinding" contract="IService" behaviorConfiguration="webby"/>
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="webby">
          <webHttp helpEnabled="true"/>
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false 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>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>

  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true"/>
  </system.webServer>
</configuration>

アドレスで私もこのように試しました:

<endpoint address="" binding="webHttpBinding" contract="IService" behaviorConfiguration="webby"/>

しかし、それはまだ機能していません。

4

1 に答える 1

1

開始するための適切なリンクは次のとおりです

どのアドレスで Web サービスに接続しようとしていますか? (Web ブラウザーでそのアドレスに移動しようとしましたか? また、どの URL を入力しましたか?)

[編集]

Web アプリケーションでホストしているため、IIS (または使用している Web サーバー) は、サービスのサービス記述子ファイルが存在することを期待します。web.config で URI を作成し、ファイル システムに関連する「サービス」ファイル (これは Service1.svc ファイル) なしで IIS でホストすることはできません。

これは、インターネット インフォメーション サービス内で WCF サービスをホストする場合に特有のニュアンスです。自己ホスト型のシナリオ向けに設計されたチュートリアルを読んでいると、この手順を忘れがちです。

Web サイトに「Service1.svc」というファイルがあり、次のような内容が含まれていることを確認してください。

<%@ServiceHost Language="C#" Service="MyNamespace.Service1" Factory="System.ServiceModel.Activation.WebServiceHostFactory" %>

IIS 内での REST サービスのホスティングに関するチュートリアルは次のとおりです: http://saravananarumugam.wordpress.com/2011/03/04/simple-rest-implementation-with-webhttpbinding/

私が思いつくもう 1 つの懸念は、定義したエンドポイント アドレス ("http://localhost:10492/Service.svc") が REST 規則に準拠していないことです。これがあなたの問題になるとは思いませんが、それは問題です。

于 2012-09-27T19:56:19.643 に答える