IIS で WCF Rest ベースのサービスをホストする際に、次の問題が発生しました。
インターフェース:
[ServiceContract]
public interface ITestService
{
[OperationContract]
[WebInvoke(Method = "GET", UriTemplate = "/GetEmployee/{userid}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json,BodyStyle=WebMessageBodyStyle.Bare)]
IEnumerable<Employee> GetPlans(string userid);
}
TestService.svc.cs:
public class TestService : ITestService
{
public IEnumerable<Employee> GetEmployee(string userid)
{
return Employee
}
}
Cassini サーバーを使用すると、正常に動作し、json 形式で結果が返されます。URL は次のとおりです。
http://localhost:58764/TestService/TestService.svc/GetEmployee/2
しかし、それを IIS Express 7.5 の URL でホストすると、次のようになります。
http://localhost/TestService/TestService.svc/GetEmployee/2)
それは単に言う:
「リクエストエラー
サーバーでリクエストの処理中にエラーが発生しました。サービスへの有効なリクエストを作成するには、サービスのヘルプ ページを参照してください。」
しかし、URL
http://localhost/TestService/TestService.svc/help
利用可能なすべてのメソッドを問題なく返します。