/// <summary>
  /// Create a new Registration (Instance of a user taking a course)
  /// </summary>
  /// <param name="registrationId">Unique Identifier for the registration</param>
  /// <param name="courseId">Unique Identifier for the course</param>
  /// <param name="versionId">Optional versionID, if Int32.MinValue, latest course version is
  // used.</param>
  /// <param name="learnerId">Unique Identifier for the learner</param>
  /// <param name="learnerFirstName">Learner's first name</param>
  /// <param name="learnerLastName">Learner's last name</param>
  /// <param name="learnerLastName">Learner's email address</param>
  /// <param name="resultsPostbackUrl">URL to which the server will post results back to</param>
  /// <param name="authType">Type of Authentication used at results postback time</param>
  /// <param name="postBackLoginName">If postback authentication is used, the logon name</param>
  /// <param name="postBackLoginPassword">If postback authentication is used, the password</param>
  /// <param name="learnerTags">Comma separated list of learner tags</param>
  /// <param name="courseTags">Comma separated list of course tags</param>
  /// <param name="registrationTags">Comma separated list of registration tags</param>
  /// <param name="resultsFormat">The Format of the results XML sent to the postback URL</param>
  public void CreateRegistration(
      String registrationId,
      String courseId,
      int versionId,
      String learnerId,
      String learnerFirstName,
      String learnerLastName,
      String email,
      String resultsPostbackUrl,
      RegistrationResultsAuthType authType,
      String postBackLoginName,
      String postBackLoginPassword,
      String learnerTags,
      String courseTags,
      String registrationTags,
      RegistrationResultsFormat resultsFormat)
      throws Exception {
    ServiceRequest request = new ServiceRequest(configuration);
    request.getParameters().add("regid", registrationId);
    request.getParameters().add("courseid", courseId);
    request.getParameters().add("fname", learnerFirstName);
    request.getParameters().add("lname", learnerLastName);
    request.getParameters().add("learnerid", learnerId);

    // Required on this signature but not by the actual service
    request.getParameters().add("authtype", authType.toString().toLowerCase());
    request.getParameters().add("resultsformat", resultsFormat.toString().toLowerCase());

    // Optional:
    if (!Utils.isNullOrEmpty(email)) request.getParameters().add("email", email);
    if (!Utils.isNullOrEmpty(resultsPostbackUrl))
      request.getParameters().add("postbackurl", resultsPostbackUrl);
    if (!Utils.isNullOrEmpty(postBackLoginName))
      request.getParameters().add("urlname", postBackLoginName);
    if (!Utils.isNullOrEmpty(postBackLoginPassword))
      request.getParameters().add("urlpass", postBackLoginPassword);
    if (versionId != Integer.MIN_VALUE) request.getParameters().add("versionid", versionId);

    if (!Utils.isNullOrEmpty(learnerTags)) {
      request.getParameters().add("learnerTags", learnerTags);
    }
    if (!Utils.isNullOrEmpty(courseTags)) {
      request.getParameters().add("courseTags", courseTags);
    }
    if (!Utils.isNullOrEmpty(registrationTags)) {
      request.getParameters().add("registrationTags", registrationTags);
    }

    request.callService("rustici.registration.createRegistration");
  }
  /// <summary>
  /// Returns the current state of the registration, including completion
  /// and satisfaction type data.  Amount of detail depends on format parameter.
  /// </summary>
  /// <param name="registrationId">Unique Identifier for the registration</param>
  /// <param name="resultsFormat">Degree of detail to return</param>
  /// <returns>Registration data in XML Format</returns>
  public String GetRegistrationResult(
      String registrationId, RegistrationResultsFormat resultsFormat, DataFormat dataFormat)
      throws Exception {
    ServiceRequest request = new ServiceRequest(configuration);
    request.getParameters().add("regid", registrationId);
    request.getParameters().add("resultsformat", resultsFormat.toString().toLowerCase());
    if (dataFormat == DataFormat.JSON) request.getParameters().add("format", "json");

    if (dataFormat == DataFormat.XML) {
      Document response = request.callService("rustici.registration.getRegistrationResult");
      // Return the subset of the xml starting with the top <summary>
      Node reportElem = response.getElementsByTagName("registrationreport").item(0);
      return XmlUtils.getXmlString(reportElem);
    } else {
      return request.getStringFromService("rustici.registration.getRegistrationResult");
    }
  }
  public void TestRegistrationPostUrl(
      String resultsPostbackUrl,
      RegistrationResultsAuthType authType,
      String postBackLoginName,
      String postBackLoginPassword,
      RegistrationResultsFormat resultsFormat)
      throws Exception {
    ServiceRequest request = new ServiceRequest(configuration);

    // Required on this signature but not by the actual service
    request.getParameters().add("authtype", authType.toString().toLowerCase());
    request.getParameters().add("resultsformat", resultsFormat.toString().toLowerCase());

    // Optional:
    if (!Utils.isNullOrEmpty(resultsPostbackUrl))
      request.getParameters().add("postbackurl", resultsPostbackUrl);
    if (!Utils.isNullOrEmpty(postBackLoginName))
      request.getParameters().add("urlname", postBackLoginName);
    if (!Utils.isNullOrEmpty(postBackLoginPassword))
      request.getParameters().add("urlpass", postBackLoginPassword);

    request.callService("rustici.registration.testRegistrationPostUrl");
  }