【发布时间】:2016-10-22 09:07:10
【问题描述】:
在使用 servicestack MsgPackServiceClient 时尝试反序列化来自服务的响应时出现以下错误。
异常:{“无法反序列化类型为‘System.Int32’的成员‘test1’。”}
InnerException : {"Cannot convert 'System.Int32' type value from type 'FixedRaw'(0xA4) in offset 1."}
服务器端Servicestack服务:
public class TestService : Service
{
public test Get(test s)
{
return new test { test1 = 12, test2 = "testvalue", Domian = "1234" };
}
}
服务器端 DTO:
[Route("/test")]
public class test
{
public int test1 { get; set; }
public string test2 { get; set; }
public string Domain { get; set; }
}
客户端代码:
class Program
{
static void Main(string[] args)
{
MsgPackServiceClient c = new MsgPackServiceClient(@"http://localhost:52862/");
var result = c.Get<test>(@"/test");
}
}
客户端dto:
public class test
{
public int test1 { get; set; }
public string test2 { get; set; }
}
客户端我们不需要域属性。当我们尝试获取值时,会抛出上述异常。
当我们添加域属性时,它可以正常工作并且我们能够获取值。
我们真的需要拥有所有属性吗?
请帮我解决这个问题。谢谢你的时间。
【问题讨论】: