/// <summary> /// Configures the client with the appropriate security options. /// </summary> /// <param name="client"></param> private void ConfigureClient(AdministrativeClient client) { // Load the certificate from the Project Resources. // Note that this certificate has been generated from the default SOLA Development keystore.jks. Instructions on how to // generate the cert using the Java keytool can be found here. // http://stackoverflow.com/questions/5529541/developing-a-net-client-that-consumes-a-secure-metro-2-1-web-service // Note that it is also necessary to add DNS identity configuration to the app.config. The default DNS identity in this // certificate is xwssecurityserver. X509Certificate2 cert = new X509Certificate2(org.sola.services.boundary.wsclients.Properties.Resources.ServerCertificate); client.ClientCredentials.ServiceCertificate.DefaultCertificate = cert; client.ClientCredentials.UserName.UserName = uName; client.ClientCredentials.UserName.Password = pWord; }
/// <summary> /// Returns true of the web service client is able to successfully connect to the target web service. /// </summary> /// <returns></returns> public bool CheckConnection() { bool result = false; using (AdministrativeClient client = new AdministrativeClient()) { ConfigureClient(client); try { client.Open(); result = client.CheckConnection(); client.Close(); } catch (Exception ex) { client.Abort(); throw ex; } } return(result); }
/// <summary> /// Creates the baUnit and links it to the service indicated /// </summary> /// <param name="serviceId"></param> /// <param name="baUnit"></param> /// <returns></returns> public baUnitTO CreateBaUnit(string serviceId, baUnitTO baUnit) { baUnitTO result = null; using (AdministrativeClient client = new AdministrativeClient()) { ConfigureClient(client); try { client.Open(); result = client.CreateBaUnit(serviceId, baUnit); client.Close(); } catch (Exception ex) { client.Abort(); throw ex; } } return(result); }
/// <summary> /// Returns the BA Unit for the specified identifier. /// </summary> /// <returns></returns> public baUnitTO GetBaUnitById(string baUnitId) { baUnitTO result = null; using (AdministrativeClient client = new AdministrativeClient()) { ConfigureClient(client); try { client.Open(); result = client.GetBaUnitById(baUnitId); client.Close(); } catch (Exception ex) { client.Abort(); throw ex; } } return(result); }