ServiceStack客户端来自示例

时间:2013-11-24 05:20:50

标签: c# asp.net .net servicestack

我从 - https://github.com/ServiceStack/ServiceStack/wiki/C%23-client

尝试客户端示例
    public class Hello
    {
        public string Name { get; set; }
    }

    public class HelloResponse
    {
        public string Result { get; set; }
        public ResponseStatus ResponseStatus { get; set; } //Where Exceptions get auto-serialized
    }

    static void Main(string[] args)
    {
        var client = new JsonServiceClient("http://localhost:52849/hello");

        HelloResponse response = client.Get(new Hello { Name = "World!" });
    }

但是在最后一个字符串上:

HelloResponse response = client.Get(new Hello { Name = "World!" });

得到错误:

Error   3   The best overloaded method match for                 'ServiceStack.ServiceClient.Web.ServiceClientBase.Get(ServiceStack.ServiceHost.IReturnVoid)' has some invalid arguments    C:\Users\Maksim\Documents\Visual Studio 2013\Projects\DapperTest\DapperTest\Program.cs  32  38  DapperTest

我尝试替代API:

var response = client.Get<HelloResponse>("/hello/World!");

它的工作没有错误,但字符串:

response.Result.Print();

获得例外:

Error   4   'string' does not contain a definition for 'Print' and no extension method 'Print' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?) C:\Users\Maksim\Documents\Visual Studio 2013\Projects\DapperTest\DapperTest\Program.cs  34  29  DapperTest

0 个答案:

没有答案