private bool VerifyWebServiceCommand( WebSession session, string webServiceURL, TestWebServiceCall webServiceCall, int command_index) { bool success = true; UriBuilder uriBuilder = new UriBuilder(webServiceURL + "/" + webServiceCall.command); string fullUrl = uriBuilder.ToString(); JavaScriptSerializer serializer = new JavaScriptSerializer(); string jsonResultString = ""; _logger.WriteLine("WebServiceValidator: INFO: Sending command #{0}", command_index + 1); _logger.WriteLine("url: {0}", fullUrl); try { SessionWebClient webClient = new SessionWebClient(session); object jsonResultObject = null; if (webServiceCall.queryParameters != null) { jsonResultString = webClient.POST(fullUrl, (Dictionary <string, object>)webServiceCall.queryParameters); } else { jsonResultString = webClient.GET(fullUrl); } jsonResultObject = serializer.DeserializeObject(jsonResultString); success = AreObjectsEqual("", webServiceCall.ignoreFields, webServiceCall.result, jsonResultObject); } catch (System.Exception ex) { _logger.WriteLine("WebServiceValidator: ERROR: Exception sending command"); _logger.WriteLine(ex.Message); _logger.WriteLine(ex.StackTrace); success = false; } if (success) { _logger.WriteLine("WebServiceValidator: INFO: Received expected result"); } else { _logger.WriteLine("WebServiceValidator: ERROR: Received unexpected result"); } _logger.WriteLine("Result: {0}", jsonResultString); _logger.WriteLine(); return(success); }
private bool VerifyWebServiceCommand( WebSession session, string webServiceURL, TestWebServiceCall webServiceCall, int command_index) { bool success= true; UriBuilder uriBuilder = new UriBuilder(webServiceURL + "/" + webServiceCall.command); string fullUrl = uriBuilder.ToString(); JavaScriptSerializer serializer = new JavaScriptSerializer(); string jsonResultString = ""; _logger.WriteLine("WebServiceValidator: INFO: Sending command #{0}", command_index+1); _logger.WriteLine("url: {0}", fullUrl); try { SessionWebClient webClient = new SessionWebClient(session); object jsonResultObject= null; if (webServiceCall.queryParameters != null) { jsonResultString = webClient.POST(fullUrl, (Dictionary<string, object>)webServiceCall.queryParameters); } else { jsonResultString = webClient.GET(fullUrl); } jsonResultObject = serializer.DeserializeObject(jsonResultString); success = AreObjectsEqual("", webServiceCall.ignoreFields, webServiceCall.result, jsonResultObject); } catch (System.Exception ex) { _logger.WriteLine("WebServiceValidator: ERROR: Exception sending command"); _logger.WriteLine(ex.Message); _logger.WriteLine(ex.StackTrace); success = false; } if (success) { _logger.WriteLine("WebServiceValidator: INFO: Received expected result"); } else { _logger.WriteLine("WebServiceValidator: ERROR: Received unexpected result"); } _logger.WriteLine("Result: {0}", jsonResultString); _logger.WriteLine(); return success; }