ApplyPath() public method

public ApplyPath ( ) : void
return void
コード例 #1
0
ファイル: WebServices.cs プロジェクト: Robin--/Warewolf
 public static void ExecuteRequest(WebService service, bool throwError, out ErrorResultTO errors, WebExecuteString webExecute)
 {
     var requestHeaders = SetParameters(service.Method.Parameters, service.RequestHeaders);
     var headers = string.IsNullOrEmpty(requestHeaders)
                       ? new string[0]
                       : requestHeaders.Split(new[] { '\n', '\r', ';' }, StringSplitOptions.RemoveEmptyEntries);
     var requestUrl = SetParameters(service.Method.Parameters, service.RequestUrl);
     var requestBody = SetParameters(service.Method.Parameters, service.RequestBody);
     service.RequestResponse = webExecute(service.Source as WebSource, service.RequestMethod, requestUrl, requestBody, throwError, out errors, headers);
     if(!String.IsNullOrEmpty(service.JsonPath))
     {
         service.ApplyPath();
     }
 }
コード例 #2
0
ファイル: WebServices.cs プロジェクト: Robin--/Warewolf
        public WebService Test(string args, Guid workspaceId, Guid dataListId)
        {
            var service = new WebService();
            try
            {
                service = JsonConvert.DeserializeObject<WebService>(args);

                if(string.IsNullOrEmpty(service.RequestResponse))
                {
                    ErrorResultTO errors;
                    ExecuteRequest(service, true, out errors, _webExecute);
                    ((WebSource)service.Source).DisposeClient();
                }

                var preTestRsData = service.Recordsets;
                service.RequestMessage = string.Empty;
                service.JsonPathResult = string.Empty;

                if(service.RequestResponse.IsJSON() && String.IsNullOrEmpty(service.JsonPath))
                {
                    service.ApplyPath();
                    // we need to timeout this request after 10 seconds due to nasty pathing issues ;)
                    Thread jsonMapTaskThread = null;
                    var jsonMapTask = new Task(() =>
                    {
                        jsonMapTaskThread = Thread.CurrentThread;
                        service.Recordsets = FetchRecordset(service, true);
                    });

                    jsonMapTask.Start();
                    jsonMapTask.Wait(10000);

                    if(!jsonMapTask.IsCompleted)
                    {
                        if(jsonMapTaskThread != null)
                        {
                            jsonMapTaskThread.Abort();
                        }

                        service.Recordsets = preTestRsData;
                        service.RequestMessage = GlobalConstants.WebServiceTimeoutMessage;
                    }

                    jsonMapTask.Dispose();
                }
                else
                {
                    service.Recordsets = FetchRecordset(service, true);
                }

            }
            catch(Exception ex)
            {
                RaiseError(ex);
                if(service.Recordsets.Count > 0)
                {
                    service.Recordsets[0].HasErrors = true;
                    service.Recordsets[0].ErrorMessage = ex.Message;
                }
                service.RequestResponse = ex.Message;
            }

            return service;
        }
コード例 #3
0
ファイル: WebServices.cs プロジェクト: Robin--/Warewolf
        public WebService ApplyPath(string args, Guid workspaceId, Guid dataListId)
        {
            var service = new WebService();
            try
            {
                service = JsonConvert.DeserializeObject<WebService>(args);
                service.ApplyPath();
                var oldResult = service.RequestResponse;
                service.RequestResponse = service.JsonPathResult;
                service.Recordsets = FetchRecordset(service, true);
                service.RequestResponse = oldResult;
            }
            catch(Exception ex)
            {
                RaiseError(ex);
                if(service.Recordsets.Count > 0)
                {
                    service.Recordsets[0].HasErrors = true;
                    service.Recordsets[0].ErrorMessage = ex.Message;
                }

                service.JsonPathResult = ex.Message;
            }

            return service;
        }
コード例 #4
0
 public void WebService_ApplyPath_ResponseDataNotJsonData_ExceptionThrown()
 {
     //------------Setup for test--------------------------
     const string expected = "blah blah";
     var webService = new WebService { RequestResponse = expected, JsonPath = "some path" };
     //------------Execute Test---------------------------
     webService.ApplyPath();
     //------------Assert Results-------------------------
     Assert.AreEqual(expected, webService.RequestResponse);
 }
コード例 #5
0
 public void WebService_ApplyPath_WhenJsonPathEmpty_NothingHappens()
 {
     //------------Setup for test--------------------------
     var webService = new WebService();
     const string expected = "this is the response";
     webService.RequestResponse = expected;
     webService.JsonPath = "";
     //------------Execute Test---------------------------
     webService.ApplyPath();
     //------------Assert Results-------------------------
     Assert.AreEqual(expected, webService.RequestResponse);
 }
コード例 #6
0
 public void WebService_ApplyPath_WhenResponseDataEmpty_NothingHappens()
 {
     //------------Setup for test--------------------------
     var webService = new WebService { RequestResponse = "" };
     //------------Execute Test---------------------------
     webService.ApplyPath();
     //------------Assert Results-------------------------
     Assert.AreEqual("", webService.RequestResponse);
 }
コード例 #7
0
 public void WebService_ApplyPath_WhenResponseDataNull_NothingHappens()
 {
     //------------Setup for test--------------------------
     var webService = new WebService { RequestResponse = null };
     //------------Execute Test---------------------------
     webService.ApplyPath();
     //------------Assert Results-------------------------
     Assert.IsNull(webService.RequestResponse);
 }