/// <summary>
        /// Called to create the response.
        /// </summary>
        /// <param name="proposedResponse">The proposed response.</param>
        /// <returns>The response.</returns>
        protected override async Task <WebServiceResponse> CreateResponseAsync(WebServiceResponse proposedResponse)
        {
            HttpStatusCode statusCode = proposedResponse.StatusCode;
            HttpHeaders    headers    = proposedResponse.Headers;
            var            content    = proposedResponse.Content;

            // check for content
            if (content is object)
            {
                // check content type
                if (proposedResponse.HasJson())
                {
                    string responseJson = await proposedResponse.GetJsonAsync().ConfigureAwait(false);

                    // success
                    return(new JsonWebServiceResponse(this, statusCode, headers, JsonWebServiceContent.FromJson(responseJson)));
                }
                else
                {
                    // got content with the wrong content type (HTML error information, perhaps; allowed for non-OK)
                    string message = "Response content type is not JSON: {0}".FormatInvariant(content.Headers.ContentType);
                    if (statusCode == HttpStatusCode.OK)
                    {
                        throw WebServiceResponseUtility.CreateWebServiceException(proposedResponse, message);
                    }
                }
            }

            // missing or non-JSON content
            return(new JsonWebServiceResponse(this, statusCode, headers, content));
        }
 /// <summary>
 /// Sets the Content of the WebServiceRequest.
 /// </summary>
 /// <typeparam name="TWebServiceRequest">The type of the web service request.</typeparam>
 /// <typeparam name="TContentValue">The type of the content value.</typeparam>
 /// <param name="request">The request.</param>
 /// <param name="contentValue">The content value.</param>
 /// <param name="settings">The settings.</param>
 /// <returns>The request.</returns>
 public static TWebServiceRequest WithJsonContent <TWebServiceRequest, TContentValue>(this TWebServiceRequest request, TContentValue contentValue, JsonSettings settings) where TWebServiceRequest : WebServiceRequestBase
 {
     request.Content = JsonWebServiceContent.FromValue(contentValue, settings);
     return(request);
 }