ServiceStack SOAP Error serialization

浪子不回头ぞ 提交于 2019-12-11 14:23:42

问题


In a ServiceStack project I've added api key authorization as follows

this.RequestFilters.Add((req, res, dto) =>
{
    var apiKey = req.Headers["X-ApiKey"];
    if (apiKey == null || !ApiKeyValidation.VerifyKey(apiKey))
    {
        throw HttpError.Unauthorized("Unknown ApiKey");
    }
});

When accessing the service via REST I get a response as I expect:

{
    "ResponseStatus": {
        "ErrorCode": "Unknown ApiKey",
        "Message": "Unknown ApiKey"
    }
}

When accessing the SOAP 1.2 endpoint, I get an HTML response from the IIS server with an error message and stacktrace. This seems to happen for other (Input string was not in a correct format) errors as well.

Unknown ApiKey

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: ServiceStack.Common.Web.HttpError: Unknown ApiKey

My DTO's are written as follows:

[DataContract]
public class UserDetails : IReturn<UserDetailsResponse>
{
    [DataMember]
    public string Email { get; set; }
}

[DataContract]
public class UserDetailsResponse
{
    [DataMember]
    public Account User { get; set; }
    [DataMember]
    public ResponseStatus ResponseStatus { get; set; }
}

I've set the DebugMode = false in the configuration. Am I missing some configuration option?

来源:https://stackoverflow.com/questions/18824944/servicestack-soap-error-serialization

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!