/// <summary> /// Parse the Response For Deployments And Return Them /// </summary> /// <param name="httpWebResponse">The Response From the Web Service</param> /// <returns>List of Deployments</returns> private static DeploymentsResponse ParseResponseObjectsDeploymentsResponse(HttpWebResponse httpWebResponse) { //try //{ if (httpWebResponse.StatusCode == HttpStatusCode.OK) { //if (httpWebResponse.ContentType==) DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(DeploymentsResponse)); if (httpWebResponse.ContentLength > int.MaxValue) { throw new IndexOutOfRangeException(String.Format("Response From Web Service Exceeds {0}", int.MaxValue)); } // WWB: Read The Data From The Response Stream int length = (int)httpWebResponse.ContentLength; byte[] data = new byte[length]; using (Stream responseStream = httpWebResponse.GetResponseStream()) { responseStream.Read(data, 0, length); } // WWB: In A Memory Stream Convert the Json using (MemoryStream stream = new MemoryStream(data)) { var response = serializer.ReadObject(stream) as DeploymentsResponse; // WWB: Check The Response For Errors if (response.Status != DeploymentResponseStatus.Success) { var exception = new WebServiceException<DeploymentResponseStatus>() { Status = response.Status }; throw exception; } return response; } } else { DeploymentsResponse ErrorResponse = new DeploymentsResponse() { Status = DeploymentResponseStatus.IllegalResponse, Deployments=null, Trial=null //TrialResponse=1 }; return ErrorResponse; } }
private static DeploymentsResponse HandleResponseErrorObjectMoved() { DeploymentsResponse ErrorResponse = new DeploymentsResponse() { Status = DeploymentResponseStatus.IllegalResponse, Deployments=null, Trial=null //TrialResponse=0 }; return ErrorResponse; }