2009-06-08 15 views
0

私は現在、VS 2005を使用してC#でRESTful WCFサービスを作成しています。私はIIS経由でサービスをホストしていますが、.svcを参照できますが、 404エラー。 wcftestclient(VS 2008に含まれています)を実行すると、そのメソッドを見ることができるので、サービスが機能していることがわかります。この問題は実装のREST部分にあるようです。IISでRESTful WCFをホストする

これは私のweb.configファイルである:

<system.serviceModel> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/> 
    <services> 
     <service behaviorConfiguration="ServiceBehavior" name="MyAPI"> 
     <endpoint binding="webHttpBinding" contract="IExternalAPI"/> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
     </service> 
    </services> 
    <behaviors> 
     <endpointBehaviors> 
     <behavior name="ServiceBehavior"> 
      <webHttp/> 
     </behavior> 
     </endpointBehaviors> 
     <serviceBehaviors> 
     <behavior name="ServiceBehavior"> 
      <serviceMetadata httpGetEnabled="true"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 

は、これは契約です:

[ServiceContract()] 
    interface IExternalAPI { 
    [OperationContract] 
    [WebGet (BodyStyle=WebMessageBodyStyle.Bare,ResponseFormat=WebMessageFormat.Json,UriTemplate="{APIKey}/Favorites/{userId}")] 
    string GetFavoritesList(string APIKey, string userId); 

    [OperationContract] 
    [WebGet(BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, UriTemplate = "{APIKey}/Addresses/{userId}")] 
    string GetAddressList(string APIKey, string userId); 

    [OperationContract] 
    [WebInvoke(BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, UriTemplate = "{APIKey}/Authenticate/{userName}/{password}")] 
    string Authenticate(string APIKey, string username, string password); 

    [OperationContract] 
    [WebInvoke(BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, UriTemplate = "{APIKey}/Checkout/{orderId}/{userId}/{tip}/{addressId}")] 
    string Checkout(string APIKey, string orderId, string userId, string tip, string addressId); 

    [OperationContract] 
    [WebInvoke(BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, UriTemplate = "{APIKey}/AddToOrder/{templateId}/{userId}")] 
    string AddFavoriteToOrder(string APIKey, string templateId, string userId); 

    [OperationContract] 
    [WebGet(BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, UriTemplate = "{APIKey}/Pending/{userId}")] 
    string GetPendingOrders(string APIKey, string userId); 

    [OperationContract] 
    [WebGet(BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, UriTemplate = "Bob")] 
    string TestMethod(); 
    } 

任意の助けをいただければ幸いです。

+0

使用しているソフトウェアのバージョンは何ですか? –

+0

あなたはどのURIにナビゲートしていますか?あなたにサンプルを教えてもらえますか? //localhost/MemberServices/MemberServices.svc/Bob ます。http: –

+0

URIは 、HTTPのようなものです//localhost/MemberServices/MemberServices.svc/1234/Favorites/567 私はすべてのサービスパックとVS 2005を実行しています、IIS 5.1、および.NET 3.5 –

答えて

2

あなたの投稿から4ヶ月後ですが、私は同様の状況に陥っています。私の設定はあなたとほぼ同じですが、endpointBehaviorキーを追加するまでは同じ問題がありました。エンドポイントの動作への明示的な参照をサービスエンドポイントで指定してみてください。多分それが助けになるでしょう。

<service behaviorConfiguration="ServiceBehavior" name="MyAPI"> 
    <endpoint binding="webHttpBinding" behaviorConfiguration="ServiceBehavior" contract="IExternalAPI"/> 
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
</service> 
関連する問題