ServiceStack uses the .NET XML DataContract serializer under the hood. It is not configurable beyond what is offered by the underlying .NET Framework.
To support custom queries, you can override the default query processing. The ServiceStack wiki page for serializing and deserializing shows various ways to configure request processing:
Register DTO request for user request
base.RequestBinders.Add(typeof(MyRequest), httpReq => ... requestDto);
Skip automatic deserialization and read directly from InputStream request
Tell ServiceStack to skip deserialization and process it yourself by providing a DTO to implement IRequiresRequestStream and deserialize the request yourself (in your service):
//Request DTO public class Hello : IRequiresRequestStream { /// <summary> /// The raw Http Request Input Stream /// </summary> Stream RequestStream { get; set; } }
Override default XML content format
If you prefer to use a different XML serializer, you can override the default content types in ServiceStack by registering your own custom material type , for example:
string contentType = "application/xml"; var serialize = (IRequest request, object response, Stream stream) => ...; var deserialize = (Type type, Stream stream) => ...; //In AppHost.Configure method pass two delegates for serialization and deserialization this.ContentTypes.Register(contentType, serialize, deserialize);
mythz source share