public Soap(string url, string serviceMethod, int?timeout = null, IWebProxy proxy = null, string userAgent = null, int connectionLimit = 20, WebServiceMethod webServiceMethod = WebServiceMethod.POST) { Url = url; WebServiceMethod = webServiceMethod; Headers = new NameValueCollection() { { "SOAPAction", serviceMethod }, { "Content-Type", @"text/xml" }, { "charset", "UTF-8" }, }; Timeout = timeout ?? Timeout; Proxy = proxy; UserAgent = userAgent; ConnectionLimit = connectionLimit; }
public void SendToRestService(string url, WebServiceMethod method, string service, Table parameters) { this.serviceContext.Services.SingleOrDefault(key => key.Key == service).Value.Should() .BeNull($"Сервис с названием '{service}' уже существует"); url.Should().NotBeEmpty("Ссылка на сервис не задана"); parameters.Should().NotBeNull("Параметры не заданы"); NameValueCollection headersCollection; List <KeyValuePair <string, string> > queryCollection; (url, headersCollection, queryCollection) = this.InitializationRestService(url, parameters); this.consoleOutputHelper.WriteLine($"url (сериализован): {url}"); using (var rest = new Rest(url, webServiceMethod: method)) { rest.Headers = headersCollection; var(statusCode, errors) = rest.CallWebService(); this.serviceContext.Services.Add(service, new WebService() { Url = url, Service = (Core.Data.Services.Service)rest.Clone(), Body = string.Empty, HeadersCollection = headersCollection, ParametersCollection = queryCollection, StatusCode = statusCode, Errors = errors, }); } }
protected override void CreateChildControls() { base.CreateChildControls(); string text = "filter or search"; if (!string.IsNullOrEmpty(this.WatermarkText)) { text = this.WatermarkText; } this.hiddenForSRLabel = Util.CreateHiddenForSRLabel(text, this.ID); this.Controls.Add(this.hiddenForSRLabel); this.imageButtonFilter = new HyperLink(); this.imageButtonFilter.NavigateUrl = "#"; this.imageButtonFilter.Attributes.Add("onclick", "javascript:return false;"); this.imageButtonFilter.ToolTip = this.SearchButtonToolTip; this.imageButtonFilter.ID = this.ID + "_SearchButton"; CommandSprite commandSprite = new CommandSprite(); if (this.SearchButtonImageId != null) { commandSprite.ImageId = this.SearchButtonImageId.Value; } else { commandSprite.ImageId = CommandSprite.SpriteId.SearchDefault; } commandSprite.ID = this.imageButtonFilter.ID + "_ImageSearchButton"; commandSprite.AlternateText = this.SearchButtonToolTip; this.imageButtonFilter.Controls.Add(commandSprite); EncodingLabel encodingLabel = new EncodingLabel(); encodingLabel.Text = RtlUtil.SearchDefaultMock; encodingLabel.ToolTip = this.SearchButtonToolTip; encodingLabel.CssClass = "filterIndicatorImageAlter"; this.imageButtonFilter.Controls.Add(encodingLabel); this.Controls.Add(this.imageButtonFilter); this.watermarkExtender = new TextBoxWatermarkExtender(); this.watermarkExtender.TargetControlID = this.UniqueID; this.watermarkExtender.WatermarkCssClass = "TextBoxWatermark"; this.watermarkExtender.WatermarkText = this.WatermarkText; this.Controls.Add(this.watermarkExtender); if (this.enableAutoSuggestion) { this.autoCompleteExtender = new EcpAutoCompleteExtender(); this.autoCompleteExtender.TargetControlID = this.UniqueID; WebServiceMethod webServiceMethod = new WebServiceMethod(); webServiceMethod.ServiceUrl = new WebServiceReference(string.Format("{0}&workflow={1}", this.suggestionServicePath, this.SuggestionServiceWorkFlow)); webServiceMethod.ID = this.autoCompleteExtender.ID + "WebServiceMethod"; webServiceMethod.Method = this.SuggestionServiceMethod; webServiceMethod.ParameterNames = (WebServiceParameterNames)Enum.Parse(typeof(WebServiceParameterNames), "GetList"); this.autoCompleteExtender.WebServiceMethod = webServiceMethod; this.autoCompleteExtender.AutoSuggestionPropertyNames = this.autoSuggestionPropertyNames; this.autoCompleteExtender.AutoSuggestionPropertyValues = this.autoSuggestionPropertyValues; this.Controls.Add(this.autoCompleteExtender); } }
public Rest(string url, int?timeout = null, IWebProxy proxy = null, string userAgent = null, ICredentials credentials = null, int connectionLimit = 20, WebServiceMethod webServiceMethod = WebServiceMethod.POST) { Url = url; WebServiceMethod = webServiceMethod; Timeout = timeout ?? Timeout; Proxy = proxy; UserAgent = userAgent; ConnectionLimit = connectionLimit; Credentials = credentials; }
public void SendToRestServiceWithBodyAndAuth(string url, WebServiceMethod method, string body, string service, string varCredentials, Table parameters) { this.serviceContext.Services.SingleOrDefault(key => key.Key == service).Value.Should() .BeNull($"Сервис с названием '{service}' уже существует"); url.Should().NotBeEmpty("Ссылка на сервис не задана"); parameters.Should().NotBeNull("Параметры не заданы"); this.variableContext.Variables.ContainsKey(body).Should().BeTrue($"Переменной '{body}' не существует"); var credentials = this.variableContext.GetVariableValue(varCredentials); credentials.Should().NotBeNull("Полномочия для входа были не созданы"); NameValueCollection headersCollection; List <KeyValuePair <string, string> > queryCollection; (url, headersCollection, queryCollection) = this.InitializationRestService(url, parameters); var serviceBody = this.variableContext.GetVariableValueText(body); serviceBody = this.TransformBody(headersCollection, serviceBody); this.consoleOutputHelper.WriteLine($"url (сериализован): {url}"); this.consoleOutputHelper.WriteLine($"Запрос (сериализован): {Environment.NewLine}{serviceBody}"); using (var rest = new Rest(url, webServiceMethod: method)) { rest.Headers = headersCollection; rest.Credentials = credentials as ICredentials; var(statusCode, errors) = rest.CallWebService(serviceBody); this.serviceContext.Services.Add(service, new WebService() { Url = url, Service = (Core.Data.Services.Service)rest.Clone(), Body = serviceBody, HeadersCollection = headersCollection, ParametersCollection = queryCollection, StatusCode = statusCode, Errors = errors, }); } }
protected (HttpWebRequest, List <Error>) CreateRequest() { var errors = new List <Error>(); try { var request = (HttpWebRequest)WebRequest.Create(Url); if (!string.IsNullOrWhiteSpace(UserAgent)) { request.UserAgent = UserAgent; } request.Timeout = Math.Max(0, Timeout); request.Proxy = Proxy; request.ServicePoint.ConnectionLimit = ConnectionLimit; request.Credentials = Credentials; request.PreAuthenticate = true; if (Headers != null) { request.Headers.Add(Headers); } request.Method = WebServiceMethod.ToString(); return(request, errors); } catch (Exception e) { errors.Add(new Error { TargeBase = e.TargetSite, Message = e.Message, Type = e.GetType() }); return(null, errors); } }
public Iis(string url, WebServiceMethod method, int?timeout = null) { Url = url; Method = method; Timeout = timeout ?? Timeout; }