/// <summary> /// Configure the Bindings, endpoints and open the service using the specified address. /// </summary> /// <returns>An instance of the Web Service.</returns> public static DocumentConverterServiceClient OpenService(string address) { DocumentConverterServiceClient client = null; try { BasicHttpBinding binding = new BasicHttpBinding(); // ** Use standard Windows Security. binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly; binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows; // ** Increase the client Timeout to deal with (very) long running requests. binding.SendTimeout = TimeSpan.FromMinutes(120); binding.ReceiveTimeout = TimeSpan.FromMinutes(120); // ** Set the maximum document size to 50MB binding.MaxReceivedMessageSize = 50 * 1024 * 1024; binding.ReaderQuotas.MaxArrayLength = 50 * 1024 * 1024; binding.ReaderQuotas.MaxStringContentLength = 50 * 1024 * 1024; // ** Specify an identity (any identity) in order to get it past .net3.5 sp1 EndpointIdentity epi = EndpointIdentity.CreateUpnIdentity("unknown"); EndpointAddress epa = new EndpointAddress(new Uri(address), epi); client = new DocumentConverterServiceClient(binding, epa); client.Open(); return(client); } catch (Exception) { CloseService(client); throw; } }
//private void InsertSeedRecords(bool associated, bool primaryDoc, int consentTypeId, string fName, string lName, int pcid) //{ // System.Configuration.Configuration config = WebConfigurationManager.OpenWebConfiguration(HttpContext.Current.Request.ApplicationPath); // var conStr = config.AppSettings.Settings["DBConnection"].Value; // using (var sqlConnection = new SqlConnection(conStr)) // { // sqlConnection.Open(); // var cmdTreatment = new SqlCommand("insert into Physican(Associated,Primary_Doctor,ConsentTypeID,Fname,Lname,PCID) values('" + (associated == true ? 1 : 0) + ",'" + (primaryDoc == true ? 1 : 0) + ",'" + consentTypeId + ",'" + fName + ",'" + lName + "'," + pcid + "," + "')", sqlConnection); // cmdTreatment.ExecuteNonQuery(); // } //} private DocumentConverterServiceClient OpenService(string address) { DocumentConverterServiceClient client = null; try { var binding = new BasicHttpBinding(); // ** Use standard Windows Authentication binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly; binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows; // ** Allow long running conversions binding.SendTimeout = TimeSpan.FromMinutes(30); binding.ReceiveTimeout = TimeSpan.FromMinutes(30); // ** Allow file sizes of 50MB binding.MaxReceivedMessageSize = 50 * 1024 * 1024; binding.ReaderQuotas.MaxArrayLength = 50 * 1024 * 1024; binding.ReaderQuotas.MaxStringContentLength = 50 * 1024 * 1024; // ** We need to specify an identity (any identity) in order to get it past .net3.5 sp1 EndpointIdentity epi = EndpointIdentity.CreateUpnIdentity("unknown"); var epa = new EndpointAddress(new Uri(address), epi); client = new DocumentConverterServiceClient(binding, epa); client.Open(); return client; } catch (Exception) { CloseService(client); throw; } }