/// <summary> /// Initialize the BWS and BWSUtil services. /// </summary> /// <returns>Returns true when the setup is successful, and false otherwise.</returns> private static bool Setup() { const string methodName = "Setup()"; logMessage("Entering {0}", methodName); bool returnValue = false; Metadata.clientVersion = ClientVersion; Metadata.locale = Locale; Metadata.organizationUid = OrgUid; logMessage("Initializing BWS web service stub"); bwsService = new BWSService(); logMessage("BWS web service stub initialized"); logMessage("Initializing BWSUtil web service stub"); bwsUtilService = new BWSUtilService(); logMessage("BWSUtil web service stub initialized"); // These are the URLs that point to the web services used for all calls. bwsService.Url = "https://" + BWSHostName + "/enterprise/admin/ws"; bwsUtilService.Url = "https://" + BWSHostName + "/enterprise/admin/util/ws"; // Set the connection timeout to 60 seconds. bwsService.Timeout = 60000; bwsUtilService.Timeout = 60000; Authenticator authenticator = GetAuthenticator(AuthenticatorName); if (authenticator != null) { string encodedUsername = GetEncodedUserName(Username, authenticator); if (!string.IsNullOrEmpty(encodedUsername)) { /* * Set the HTTP basic authentication on the BWS service. * BWSUtilService is a utility web service that does not require * authentication. */ bwsService.Credentials = new NetworkCredential(encodedUsername, Password); /* * Send an HTTP Authorization header with requests after authentication * has taken place. */ bwsService.PreAuthenticate = true; returnValue = true; } else { logMessage("'encodedUsername' is null or empty"); } } else { logMessage("'authenticator' is null"); } logMessage("Exiting {0} with value \"{1}\"", methodName, returnValue); return returnValue; }
/// <summary> /// Initialize the BWS and BWSUtil services. /// </summary> /// /// <returns>Returns true when the setup is successful, and false otherwise.</returns> private static bool setup(String hostname, String bwsPort, String username, String password, String authenticatorName, CredentialType credentialType, String domain) { const string METHOD_NAME = "setup()"; logMessage("Entering {0}", METHOD_NAME); bool returnValue = false; REQUEST_METADATA.clientVersion = CLIENT_VERSION; REQUEST_METADATA.locale = LOCALE; REQUEST_METADATA.organizationUid = ORG_UID; logMessage("Initializing BWS web service stub"); bwsService = new BWSService(); logMessage("BWS web service stub initialized"); logMessage("Initializing BWSUtil web service stub"); bwsUtilService = new BWSUtilService(); logMessage("BWSUtil web service stub initialized"); // These are the URLs that point to the web services used for all calls. // e.g. with no port: // https://server01.example.net/enterprise/admin/ws // e.g. with port: // https://server01.example.net:38443/enterprise/admin/ws String port = ""; if (bwsPort != null) { port = ":" + bwsPort; } bwsService.Url = "https://" + hostname + port + "/enterprise/admin/ws"; bwsUtilService.Url = "https://" + hostname + port + "/enterprise/admin/util/ws"; // Set the connection timeout to 60 seconds. bwsService.Timeout = 60000; bwsUtilService.Timeout = 60000; Authenticator authenticator = getAuthenticator(authenticatorName); if (authenticator != null) { string encodedUsername = getEncodedUserName(username, authenticator, credentialType, domain); if (!string.IsNullOrEmpty(encodedUsername)) { /* * Set the HTTP basic authentication on the BWS service. * BWSUtilService is a utility web service that does not require * authentication. */ bwsService.Credentials = new NetworkCredential(encodedUsername, password); /* * Send an HTTP Authorization header with requests after authentication * has taken place. */ bwsService.PreAuthenticate = true; returnValue = true; } else { logMessage("'encodedUsername' is null or empty"); } } else { logMessage("'authenticator' is null"); } logMessage("Exiting {0} with value \"{1}\"", METHOD_NAME, returnValue); return returnValue; }