2017-01-06 42 views
-1

Json形式のデータを返すRESTfulなサービスを作成しようとしていますが、ブラウザで開くと「エンドポイントが見つかりません」と表示されます。WCFサービス「エンドポイントが見つかりません」エラー

は、ここでは、この

<system.serviceModel> 
<services> 
    <service name="RestService.HelloWorldService"> 
    <!--<endpoint address="" binding="basicHttpBinding" behaviorConfiguration="REST" contract="RestService.IHelloWorldService"> 
     <identity> 
     <dns value="localhost" /> 
     </identity> 
    </endpoint> 
    <endpoint address="mex" binding="mexHttpBinding" behaviorConfiguration="REST" contract="RestService.IHelloWorldService" />--> 
    <endpoint address="json" binding="webHttpBinding" behaviorConfiguration="REST" contract="RestService.IHelloWorldService" />   
    <host> 
     <baseAddresses> 
     <add baseAddress="http://localhost:52478/HelloWorldService.svc" /> 
     </baseAddresses> 
    </host> 
    </service> 
</services> 
<behaviors> 
    <endpointBehaviors> 
    <behavior name="REST"> 
     <webHttp/> 
    </behavior> 
    <!--<behavior name="SOAPDemoEndpointBehavior"> 
    <soapProcessing/> 
</behavior>--> 
    </endpointBehaviors> 
    <serviceBehaviors> 
    <behavior>   
     <!-- To avoid disclosing metadata information, set the values below to false before deployment --> 
     <serviceMetadata httpGetEnabled="true" httpsGetEnabled="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 aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> 

など私のweb.configの外観は、私もF5、またはCtrl F5を経由して(プロジェクトを開始しようとしたコード

[ServiceContract] 
public interface IHelloWorldService 
{ 
    [OperationContract] 
    [WebInvoke(Method = "GET", 
     ResponseFormat = WebMessageFormat.Json, 
     BodyStyle = WebMessageBodyStyle.Wrapped, 
     UriTemplate = "json/{id}")] 
    string JsonData(string id); 
} 

です)そしてページに移動すると、stackoverflowの答えがここにあるように、何も動作していないようです。

+0

なぜ否定的な投票ですか? –

答えて

3

問題が見つかりました。私はアドレスにweb.configファイル内のエンドポイントの名前を与えていました。また、UriTemplateにjson/before {id}を追加しました。私はそれらの1つを取り除く必要があったし、それは動作します。

関連する問題