public Message SerializeReply(MessageVersion messageVersion, object[] parameters, object result)
        {
            var json = Serializer.Json(result, ContractResolver.Instance);
            var body = new RawBodyWriter(json);

            return(MessageBuilder.Build(messageVersion, OperationDescription.Messages[1].Action, body));
        }
Beispiel #2
0
        public Message Build(MessageVersion messageVersion, string action, RawBodyWriter body)
        {
            Message replyMessage = Message.CreateMessage(messageVersion, action, body);

            replyMessage.Properties.Add(WebBodyFormatMessageProperty.Name, new WebBodyFormatMessageProperty(WebContentFormat.Raw));
            HttpResponseMessageProperty respProp = new HttpResponseMessageProperty();

            respProp.Headers[HttpResponseHeader.ContentType] = Json;
            replyMessage.Properties.Add(HttpResponseMessageProperty.Name, respProp);
            return(replyMessage);
        }
Beispiel #3
0
        private static Message CreateResponse(Exception error, MessageVersion version, HttpStatusCode statusCode, string messageOverride = null)
        {
            var errorResponse = new ServiceErrorResponse(error, messageOverride);
            var json          = new Serializer().Json(errorResponse);
            var body          = new RawBodyWriter(json);
            var fault         = Message.CreateMessage(version, "", body);

            fault.Properties.Add(WebBodyFormatMessageProperty.Name, new WebBodyFormatMessageProperty(WebContentFormat.Raw));
            fault.Properties.Add(HttpResponseMessageProperty.Name, new HttpResponseMessageProperty
            {
                StatusCode        = statusCode,
                StatusDescription = "See ServiceErrorResponse object for more information."
            });
            return(fault);
        }