/// <include file='Avalara.AvaTax.Adapter.Doc.xml' path='adapter/common/members[@name="InternalConstructor"]/*' /> public ServiceConfig() { string configFileName = Utilities.ConfigFileName(); if (configFileName != null && configFileName != "") { _security = (RequestSecurity)XmlSerializerSectionHandler.CreateFromXmlFile(configFileName, "RequestSecurity"); } if (_security == null) { //no config file or an invalid config file was found. //let's create a default one in case the consumer wants to fill in all fields manually _security = new RequestSecurity(); } }
/// <summary> /// Sets a security token for SoapHeader to protect use of the SOAP request. /// </summary> /// <remarks> /// Because it has a timeout associated with it, this method should be called just prior to the request. /// </remarks> internal void SetUserToken() { _avaLog.Debug("SetUserToken"); RequestSecurity security = this.Configuration.Security; string tokenUserName = security.GetTokenUserName(); // Do not set credentials if not provided if (tokenUserName != string.Empty) { _security.UsernameToken = new UsernameToken(); _security.UsernameToken.Username = tokenUserName; _security.UsernameToken.Password = new Password(); _security.UsernameToken.Password.Value = security.GetTokenPassword(); } }