Created
March 15, 2018 10:47
-
-
Save jhorsman/ebefd5826715ddf461166badb1873f39 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void Main() | |
| { | |
| var client = | |
| getClient("SERVER", "USER", "PASSWORD", "DOMAIN"); | |
| Console.WriteLine("Starting V" + client.GetApiVersion()); | |
| } | |
| SessionAwareCoreServiceClient getClient(string hostName, string username,string password, string domain = null) | |
| { | |
| var httpBinding = new WSHttpBinding | |
| { | |
| MaxReceivedMessageSize = 2147483647, | |
| ReaderQuotas = new XmlDictionaryReaderQuotas | |
| { | |
| MaxStringContentLength = 2147483647, | |
| MaxArrayLength = 2147483647 | |
| } | |
| }; | |
| var remoteAddress = | |
| new EndpointAddress( | |
| string.Format("http://{0}/webservices/CoreService2013.svc/wsHttp", hostName)); | |
| var coreServiceClient = new SessionAwareCoreServiceClient(httpBinding, remoteAddress); | |
| if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password)) | |
| { | |
| coreServiceClient.ClientCredentials.Windows.ClientCredential.UserName = username; | |
| coreServiceClient.ClientCredentials.Windows.ClientCredential.Password = password; | |
| } | |
| if (!string.IsNullOrEmpty(domain)) | |
| coreServiceClient.ClientCredentials.Windows.ClientCredential.Domain = domain; | |
| return coreServiceClient; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment