0

ServiceStack 3.9.17.0 で IAsyncService インターフェイスを実装しようとしています。

私のサービス定義のコードは次のとおりです。

public class TestService : IAsyncService<int>
{
    object IAsyncService<int>.ExecuteAsync(int request)
    {
        return "Yup that worked";
    }
}

そして、これが私の Global.asax.cs のコードです。

public class Global : System.Web.HttpApplication
{
    public class TestServiceAppHost : AppHostBase
    {
        public TestServiceAppHost() : base("Test Async Web Services", typeof(TestService).Assembly) { }

        public override void Configure(Funq.Container container)
        {
            Routes.Add<int>("/Test");   
        }
    }
}

実行してメタデータ ページに移動すると、IService を実装するだけのこのプロジェクトに存在する他の 2 つのサービスが表示されますが (サンプルをクリーンに保つために削除されています)、IAsyncService が表示されず、ヒットしようとすると次のメッセージが表示されます。 :

<Int32Response xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="">
    <ResponseStatus>
        <ErrorCode>KeyNotFoundException</ErrorCode>
        <Message>The given key was not present in the dictionary.</Message>
        <StackTrace>
                at System.Collections.Generic.Dictionary`2.get_Item(TKey key) 
                at ServiceStack.WebHost.Endpoints.Utils.FilterAttributeCache.GetRequestFilterAttributes(Type requestDtoType) 
                at ServiceStack.WebHost.Endpoints.EndpointHost.ApplyRequestFilters(IHttpRequest httpReq, IHttpResponse httpRes, Object requestDto) 
                at ServiceStack.WebHost.Endpoints.RestHandler.ProcessRequest(IHttpRequest httpReq, IHttpResponse httpRes, String operationName)
         </StackTrace>
    </ResponseStatus>
</Int32Response>

ありとあらゆる助けをいただければ幸いです。

編集:

mythz からの提案を受けて、コードを次のように更新しました (返信ありがとうございます)。

DTO とサービス:

[Route("/test")]
public class TestDTO
{
    public int request { get; set; }
}

public class TestService : IAsyncService<TestDTO>
{
    object IAsyncService<TestDTO>.ExecuteAsync(TestDTO request)
    {
        return "Yup that worked";
    }
}

DTO を使用するようにルートを変更し、DTO の属性と一致するようにルートを小文字にしたことを除いて、Global.asax.cs は同じままにしました。私はまだ同じ問題を抱えています。

編集 #2: v3.9.71 にアップグレードしましたが、まだ同じ問題が発生しています。

4

1 に答える 1