2011-12-23 19 views
3

をしようとしたとき、私はREST経由で公開する非常に基本的なWCFサービスに404を得続ける - 私はデバッグするとき、このURLに行くことによってそれにアクセスしようとしている: http://localhost:62888/Service1.svc/xml/data/testWCF REST 404 GET

I http://localhost:62888/Service1.svcでサービス情報を表示できますが、http://localhost:62888/Service1.svc/xml

私は.Net 4とそのWCFサービスアプリケーションプロジェクトを使用しています。私は、カッシーニだけでなく、IIS Expressの

のWeb.Config

<?xml version="1.0"?> 
<configuration> 

    <system.web> 
    <compilation debug="true" targetFramework="4.0" /> 
    </system.web> 
    <system.serviceModel> 
    <services> 
     <service name="Service1"> 
     <!-- address is relative--> 
     <endpoint address="xml" binding="webHttpBinding" behaviorConfiguration="webHttp" contract="IService1" /> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     </service> 
    </services> 

    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <serviceMetadata httpGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="false"/> 
     </behavior> 
     </serviceBehaviors> 
     <endpointBehaviors> 
     <behavior name="webHttp"> 
      <webHttp />   <!-- enables RESTful in conjunction with webHttpBinging --> 
      <enableWebScript /> <!-- allows ajax communication --> 
     </behavior> 
     </endpointBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
<system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 

</configuration> 

IService.cs

using System.ServiceModel; 
using System.ServiceModel.Web; 

namespace CI.WcfRestTest 
{ 
    public interface IService1 
    { 
     [OperationContract] 
     [WebGet(UriTemplate = "/data/{id}")] 
     string GetData(string id); 
    } 
} 

Service1.svc.cs

namespace CI.WcfRestTest 
{ 
    public class Service1 : IService1 
    { 
     public string GetData(string id) 
     { 
      return string.Format("You entered: {0}", id); 
     } 
    } 
} 
でデバッグを試してみました

私はこの1つを含む件に関する記事の束を読みましたREST/SOAP endpoints for a WCF service。おそらく、カッシーニには何かがあるのでしょうか、私のマシンの設定は何かのことに気づいていますか?私はWindows Vistaの問題を読みましたが、私はWindows 7 Proを使用しています。おそらく、WCFサービスライブラリとは対照的に、WCFサービスアプリケーションと何か関係がありますか?

答えて

3

あなたの設定で間違ったサービス名を持つのと同じくらい簡単かもしれません。

現在、あなたが持っている:

<services> 
    <service name="Service1"> 

しかし:をこれは完全修飾サービス名である必要があります - 任意の名前空間を含めました!

<services> 
    <service name="CI.WcfRestTest.Service1"> 
     <!-- address is relative--> 
     <endpoint address="xml" 
       binding="webHttpBinding" behaviorConfiguration="webHttp" 
       contract="CI.WcfRestTest.IService1" /> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
    </service> 
</services> 

だけCI.WcfRestTest.Service1Service1を交換(および契約のために同じ):

ので、代わりにこれを試してみてください。それはあなたの問題を解決しますか?

+1

ありがとうございます!それはうまくいった(facepalm)ので、UriTemplateでは動作しないので、も削除しなければならなかった –