/* protected System.IO.Stream MakeExceptionAnswer(Exception e) { String text = e.Message; while (e.InnerException != null) { text = text + "; " + e.InnerException.Message; e = e.InnerException; } text = text + e.StackTrace; return MakeTextAnswer(text); } private System.IO.Stream MakeTextAnswer(String text) { MemoryStream ms = new MemoryStream(); byte[] bytes = System.Text.Encoding.UTF8.GetBytes(text); ms.Write(bytes, 0, bytes.Length); ms.Position = 0; return ms; } */ private Message CreateLicenseExceptionMessage(HttpContextServiceHost ctx, string errorDescription) { ctx.StatusCode = HttpStatusCode.PaymentRequired; ctx.StatusDescription = errorDescription; var error = new ServiceError { ErrorDescription = errorDescription }; Message message; message = Message.CreateMessage(MessageVersion.None, String.Empty, error, new DataContractSerializer(typeof(ServiceError))); message.Properties.Add(WebBodyFormatMessageProperty.Name, new WebBodyFormatMessageProperty(WebContentFormat.Xml)); var property = new HttpResponseMessageProperty { StatusCode = ctx.StatusCode }; property.Headers.Add(HttpResponseHeader.ContentType, "application/atom+xml"); message.Properties.Add(HttpResponseMessageProperty.Name, property); return message; }