/// <summary> /// This operation is used to initialize sites service with authority information. /// </summary> /// <param name="userAuthentication">This parameter used to assign the authentication information of web service.</param> public void InitializeWebService(UserAuthenticationOption userAuthentication) { this.service = Proxy.CreateProxy <SitesSoap>(this.Site); // Configure the soap service timeout. string soapServiceTimeOut = Common.GetConfigurationPropertyValue(Constants.SoapServiceTimeOut, this.Site); this.service.Timeout = Convert.ToInt32(soapServiceTimeOut) * 1000; TransportProtocol transport = Common.GetConfigurationPropertyValue <TransportProtocol>("TransportType", this.Site); switch (transport) { case TransportProtocol.HTTP: this.transportProtocol = TransportType.HTTP; break; default: this.transportProtocol = TransportType.HTTPS; break; } SoapVersion soapVersion = Common.GetConfigurationPropertyValue <SoapVersion>("SoapVersion", this.Site); switch (soapVersion) { case SoapVersion.SOAP11: this.service.SoapVersion = SoapProtocolVersion.Soap11; break; default: this.service.SoapVersion = SoapProtocolVersion.Soap12; break; } this.service.Url = Common.GetConfigurationPropertyValue(Constants.ServiceUrl, this.Site); if (this.transportProtocol == TransportType.HTTPS) { Common.AcceptServerCertificate(); } this.SetLoginUser(userAuthentication); }
/// <summary> /// Select associated user account to login the server according to different user authentications. /// </summary> /// <param name="userAuthentication">Assign the authentication information of web service.</param> private void SetLoginUser(UserAuthenticationOption userAuthentication) { string domain = string.Empty; string userName = string.Empty; string userPassword = string.Empty; switch (userAuthentication) { case UserAuthenticationOption.Authenticated: domain = Common.GetConfigurationPropertyValue(Constants.Domain, this.Site); userName = Common.GetConfigurationPropertyValue(Constants.UserName, this.Site); userPassword = Common.GetConfigurationPropertyValue(Constants.Password, this.Site); break; case UserAuthenticationOption.Unauthenticated: domain = Common.GetConfigurationPropertyValue(Constants.UnauthorizedUserDomain, this.Site); userName = Common.GetConfigurationPropertyValue(Constants.UnauthorizedUserName, this.Site); userPassword = Common.GetConfigurationPropertyValue(Constants.UnauthorizedUserPassword, this.Site); break; } this.service.Credentials = new NetworkCredential(userName, userPassword, domain); }
/// <summary> /// This operation is used to initialize sites service with authority information. /// </summary> /// <param name="userAuthentication">This parameter used to assign the authentication information of web service.</param> public void InitializeWebService(UserAuthenticationOption userAuthentication) { this.service = Proxy.CreateProxy<SitesSoap>(this.Site); // Configure the soap service timeout. string soapServiceTimeOut = Common.GetConfigurationPropertyValue(Constants.SoapServiceTimeOut, this.Site); this.service.Timeout = Convert.ToInt32(soapServiceTimeOut) * 1000; TransportProtocol transport = Common.GetConfigurationPropertyValue<TransportProtocol>("TransportType", this.Site); switch (transport) { case TransportProtocol.HTTP: this.transportProtocol = TransportType.HTTP; break; default: this.transportProtocol = TransportType.HTTPS; break; } SoapVersion soapVersion = Common.GetConfigurationPropertyValue<SoapVersion>("SoapVersion", this.Site); switch (soapVersion) { case SoapVersion.SOAP11: this.service.SoapVersion = SoapProtocolVersion.Soap11; break; default: this.service.SoapVersion = SoapProtocolVersion.Soap12; break; } this.service.Url = Common.GetConfigurationPropertyValue(Constants.ServiceUrl, this.Site); if (this.transportProtocol == TransportType.HTTPS) { Common.AcceptServerCertificate(); } this.SetLoginUser(userAuthentication); }