Exemple #1
0
        public Client(string username, string password, ILogger logger = null)
        {
            _logger = logger ?? new NullLogger <Client>();
            var binding = new BasicHttpBinding
            {
                SendTimeout            = new TimeSpan(0, 0, 0, 0, 100000),
                OpenTimeout            = new TimeSpan(0, 0, 0, 0, 100000),
                MaxReceivedMessageSize = 10000,
                ReaderQuotas           =
                {
                    MaxStringContentLength = 10000,
                    MaxDepth       = 10000,
                    MaxArrayLength = 10000
                },
                Security = new BasicHttpSecurity
                {
                    Mode      = BasicHttpSecurityMode.Transport,
                    Transport = new HttpTransportSecurity
                    {
                        ClientCredentialType = HttpClientCredentialType.None,
                        ProxyCredentialType  = HttpProxyCredentialType.None,
                    }
                }
            };
            var endpoint = new EndpointAddress("https://webservices1.autotask.net/ATServices/1.5/atws.asmx");

            _autoTaskClient = new ATWSSoapClient(binding, endpoint);
            var zoneInfo = _autoTaskClient.getZoneInfoAsync(new getZoneInfoRequest(username)).GetAwaiter().GetResult();

            // Create the binding.
            // must use BasicHttpBinding instead of WSHttpBinding
            // otherwise a "SOAP header Action was not understood." is thrown.
            var myBinding = new BasicHttpBinding
            {
                Security =
                {
                    Mode      = BasicHttpSecurityMode.Transport,
                    Transport = { ClientCredentialType = HttpClientCredentialType.Basic }
                },
                MaxReceivedMessageSize = 2147483647
            };

            // Must set the size otherwise
            //The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.

            // Create the endpoint address.
            var ea = new EndpointAddress(zoneInfo.getZoneInfoResult.URL);

            _autoTaskClient.Close();
            _autoTaskClient = new ATWSSoapClient(myBinding, ea);

            AutoTaskLogger = new AutoTaskLogger(_logger);
            _autoTaskClient.Endpoint.EndpointBehaviors.Add(AutoTaskLogger);

            _autoTaskClient.ClientCredentials.UserName.UserName = username;
            _autoTaskClient.ClientCredentials.UserName.Password = password;

            // have no clue what this does.
            _autotaskIntegrations = new AutotaskIntegrations();
        }
Exemple #2
0
 public Client(
     string username,
     string password,
     string integrationCode,
     ILogger?logger = default,
     ClientOptions?clientOptions = default)
 {
     _logger               = logger ?? new NullLogger <Client>();
     AutoTaskLogger        = new AutoTaskLogger(_logger);
     _autotaskIntegrations = new AutotaskIntegrations {
         IntegrationCode = integrationCode
     };
     _clientOptions = clientOptions ?? new ClientOptions();
     _username      = username;
     _password      = password;
 }