【发布时间】:2019-05-02 12:59:56
【问题描述】:
ServiceStack 不会填充 WebServiceException 的 responseDTO 属性中的原始响应。
我正在运行下面的代码,它应该总是返回一个 404 响应代码,其中 TestResponse 的 ResponseStatus 属性填充了“一些错误的请求”,但它似乎也应该返回原始的良好响应,它的输出属性是从请求的输入属性。但是,当我查看 WebServiceException responseDTO 时,我得到了 null
public TestResponse Post(Test request)
{
var response = new TestResponse() { Output = request.Input };
throw new HttpError(response, (int)HttpStatusCode.BadRequest, "Some bad request");
}
public TestResponse Get(Test request)
{
try
{
using (var client = new JsonServiceClient("http://localhost:5000"))
{
var response = client.Post(request);
return response;
}
}
catch (WebServiceException ex)
{
throw;
}
}
一般来说,我期望 WebServiceException 中的 responseDTO 属性将包含端点的 DTO,只要它在抛出 HttpError 时传入,但似乎并非如此。我只看到 responseDTO 中每个属性的默认值和空值。
【问题讨论】:
标签: error-handling servicestack