public static void Main() { // demonstrates how to intellegently get the zone information. // autotask will tell you which zone URL to use based on the userID var client = new ATWSSoapClient (); zoneInfo = client.getZoneInfo (auth_user_id); Console.WriteLine ("ATWS Zone Info: \n\n" + "URL = " + zoneInfo.URL); // Create the binding. // must use BasicHttpBinding instead of WSHttpBinding // otherwise a "SOAP header Action was not understood." is thrown. BasicHttpBinding myBinding = new BasicHttpBinding (); myBinding.Security.Mode = BasicHttpSecurityMode.Transport; myBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic; // 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. myBinding.MaxReceivedMessageSize = 2147483647; // Create the endpoint address. EndpointAddress ea = new EndpointAddress (zoneInfo.URL); client = new ATWSSoapClient (myBinding, ea); client.ClientCredentials.UserName.UserName = auth_user_id; client.ClientCredentials.UserName.Password = auth_user_password; // query for any account. This should return all accounts since we are retreiving anything greater than 0. StringBuilder sb = new StringBuilder (); sb.Append ("<queryxml><entity>Account</entity>").Append (System.Environment.NewLine); sb.Append ("<query><field>id<expression op=\"greaterthan\">0</expression></field></query>").Append (System.Environment.NewLine); sb.Append ("</queryxml>").Append (System.Environment.NewLine); // have no clue what this does. AutotaskIntegrations at_integrations = new AutotaskIntegrations (); // this example will not handle the 500 results limitation. // Autotask only returns up to 500 results in a response. if there are more you must query again for the next 500. var r = client.query (at_integrations, sb.ToString ()); Console.WriteLine ("response ReturnCode = " + r.ReturnCode); if (r.ReturnCode == 1) { if (r.EntityResults.Length > 0) { foreach (var item in r.EntityResults) { Account acct = (Account)item; Console.WriteLine ("Account Name = " + acct.AccountName); Console.WriteLine ("Account number = " + acct.AccountNumber); } } } Console.ReadLine (); }
public static void Main() { var client = new ATWSSoapClient (); zoneInfo = client.getZoneInfo (auth_user_id); Console.WriteLine ("ATWS Zone Info: \n\n" + "URL = " + zoneInfo.URL); // Create the binding. // must use BasicHttpBinding instead of WSHttpBinding // otherwise a "SOAP header Action was not understood." is thrown. BasicHttpBinding myBinding = new BasicHttpBinding (); myBinding.Security.Mode = BasicHttpSecurityMode.Transport; myBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic; // 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. myBinding.MaxReceivedMessageSize = 2147483647; // Create the endpoint address. EndpointAddress ea = new EndpointAddress (zoneInfo.URL); client = new ATWSSoapClient (myBinding, ea); client.ClientCredentials.UserName.UserName = auth_user_id; client.ClientCredentials.UserName.Password = auth_user_password; // query for any account. This should return all accounts since we are retreiving anything greater than 0. StringBuilder sb = new StringBuilder (); //sb.Append ("<queryxml><entity>Account</entity>").Append (System.Environment.NewLine); //sb.Append ("<query><field>id<expression op=\"greaterthan\">0</expression></field></query>").Append (System.Environment.NewLine); //sb.Append ("</queryxml>").Append (System.Environment.NewLine); sb.Append("<queryxml><entity>Ticket</entity>").Append(System.Environment.NewLine); sb.Append("<query>").Append(System.Environment.NewLine); sb.Append("<field>TicketNumber<expression op=\"Equals\">T20130623.0113</expression>").Append(System.Environment.NewLine); sb.Append("</field>").Append(System.Environment.NewLine); //sb.Append("T20130623.0113").Append(System.Environment.NewLine); sb.Append("</query></queryxml>").Append(System.Environment.NewLine); Console.WriteLine("Output the query string: {0}", sb.ToString()); // have no clue what this does. AutotaskIntegrations at_integrations = new AutotaskIntegrations (); // this example will not handle the 500 results limitation. // Autotask only returns up to 500 results in a response. if there are more you must query again for the next 500. var r = client.query (at_integrations, sb.ToString ()); Console.WriteLine ("response ReturnCode = " + r.ReturnCode); if (r.ReturnCode == 1) { if (r.EntityResults.Length > 0) { foreach (var item in r.EntityResults) { //Account acct = (Account)item; //Console.WriteLine ("Account Name = " + acct.AccountName); //Console.WriteLine ("Account number = " + acct.AccountNumber); Ticket ticket = (Ticket)item; Console.WriteLine("Ticket Number =" + ticket.TicketNumber); Console.WriteLine("Ticket Note =" + ticket.Description); Console.WriteLine("Ticket Date =" + ticket.CreateDate); Console.WriteLine("Tictet Status =" + ticket.Status); ticket.Description = "Stephen Chen update this ticket at 1/16/2013 to make sure the update function is actually working correctly"; //Ticket[] ticketarr = new Ticket[1]; //ticketarr[0] = ticket; //var result = client.update(at_integrations, ticketarr); //Console.WriteLine("response return code = " + result.ReturnCode); } } } Console.ReadLine (); }
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(); }
public static void Main() { // demonstrates how to intellegently get the zone information. // autotask will tell you which zone URL to use based on the userID var client = new ATWSSoapClient(); zoneInfo = client.getZoneInfo(auth_user_id); Console.WriteLine("ATWS Zone Info: \n\n" + "URL = " + zoneInfo.URL); // Create the binding. // must use BasicHttpBinding instead of WSHttpBinding // otherwise a "SOAP header Action was not understood." is thrown. BasicHttpBinding myBinding = new BasicHttpBinding(); myBinding.Security.Mode = BasicHttpSecurityMode.Transport; myBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic; // 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. myBinding.MaxReceivedMessageSize = 2147483647; // Create the endpoint address. EndpointAddress ea = new EndpointAddress(zoneInfo.URL); client = new ATWSSoapClient(myBinding, ea); client.ClientCredentials.UserName.UserName = auth_user_id; client.ClientCredentials.UserName.Password = auth_user_password; // query for any account. This should return all accounts since we are retreiving anything greater than 0. StringBuilder sb = new StringBuilder(); sb.Append("<queryxml><entity>Account</entity>").Append(System.Environment.NewLine); sb.Append("<query><field>id<expression op=\"greaterthan\">0</expression></field></query>").Append(System.Environment.NewLine); sb.Append("</queryxml>").Append(System.Environment.NewLine); // have no clue what this does. AutotaskIntegrations at_integrations = new AutotaskIntegrations(); // this example will not handle the 500 results limitation. // Autotask only returns up to 500 results in a response. if there are more you must query again for the next 500. var r = client.query(at_integrations, sb.ToString()); Console.WriteLine("response ReturnCode = " + r.ReturnCode); if (r.ReturnCode == 1) { if (r.EntityResults.Length > 0) { foreach (var item in r.EntityResults) { Account acct = (Account)item; Console.WriteLine("Account Name = " + acct.AccountName); Console.WriteLine("Account number = " + acct.AccountNumber); } } } Console.ReadLine(); }
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; }