The only dependency your Service Models need is ServiceStack.Interfaces which is a portable library that supports multiple .NET platforms:
.NET 4.5, Silverlight 5, Windows 8, Windows Phone 8.1, Windows Phone Silverlight 8, Xamarin.Android, Xamarin.iOS, Xamarin.iOS (classic)
If you’re trying to reuse these DTOs in a non-supported .NET platform you’re going to be extremely limited since you’re not going to be able to use many of the other data annotations like IReturn<T>
which simplifies the usability of your Services.
Most serializers don’t rely on exact types so you could just take a copy of the ResponseStatus DTO:
namespace ServiceStack
{
[DataContract]
public class ResponseStatus
{
[DataMember(Order = 1)]
public string ErrorCode { get; set; }
[DataMember(Order = 2)]
public string Message { get; set; }
[DataMember(Order = 3)]
public string StackTrace { get; set; }
[DataMember(Order = 4)]
public List<ResponseError> Errors { get; set; }
[DataMember(Order = 5)]
public Dictionary<string, string> Meta { get; set; }
}
[DataContract]
public class ResponseError
{
[DataMember(IsRequired = false, EmitDefaultValue = false, Order = 1)]
public string ErrorCode { get; set; }
[DataMember(IsRequired = false, EmitDefaultValue = false, Order = 2)]
public string FieldName { get; set; }
[DataMember(IsRequired = false, EmitDefaultValue = false, Order = 3)]
public string Message { get; set; }
[DataMember(IsRequired = false, EmitDefaultValue = false, Order = 4)]
public Dictionary<string, string> Meta { get; set; }
}
[DataContract] //Structured Error Responses can be deserialized in this DTO
public class ErrorResponse
{
[DataMember(Order = 1)]
public ResponseStatus ResponseStatus { get; set; }
}
}
And instead of trying to reuse your ServiceModel.dll, use the C# Add ServiceStack Reference feature to download a source copy of your server DTOs and compile it on your platform which will make use your local copies for any missing Types, e.g. ResponseStatus
, ResponseError
. If you’re not using a major IDE we have integration for you can use our ssutil.exe command line utility to download your Server DTOs, e.g:
ssutil http://example.org -file MyDtos -lang CSharp
Or just go to /types/csharp
on your Server in a browser and save the generated C# DTOs.
This would be the recommended option since you’re not limiting your Service to not have the ServiceStack.Interfaces dependency.