public static BasicHttpBinding GetBufferedModeBinding(BasicHttpSecurityMode mode) { var binding = new BasicHttpBinding(mode); ApplyDebugTimeouts(binding); return(binding); }
public void CreateFileChannel(string url) { int tryCount = 0; int maxCount = 10; BasicHttpSecurityMode securityMode = BasicHttpSecurityMode.None; BasicHttpBinding binding = new BasicHttpBinding(securityMode); binding.TransferMode = TransferMode.Streamed; binding.MaxReceivedMessageSize = 500000000; EndpointAddress address = new EndpointAddress(url); ChannelFactory <IFileService> factory = new ChannelFactory <IFileService>(binding, address); while (true) { try { channel = factory.CreateChannel(); tryCount = 0; break; } catch (Exception ex) { if (++tryCount <= maxCount) { Thread.Sleep(500); } else { throw ex; } } } }
public static CustomBinding CreateCustomBinding() { ProxyUtils.ByPassCertificate(); WSMessageEncoding msgEncoding; msgEncoding = WSMessageEncoding.Mtom; BasicHttpSecurityMode sec = BasicHttpSecurityMode.TransportWithMessageCredential; BasicHttpBinding basicBinding = new BasicHttpBinding(sec) { Security = { Message = { ClientCredentialType = BasicHttpMessageCredentialType.UserName } }, MessageEncoding = msgEncoding, }; var elements = basicBinding.CreateBindingElements(); if (msgEncoding == WSMessageEncoding.Text) { TextMessageEncodingBindingElement te = elements.Find <TextMessageEncodingBindingElement>(); te.MessageVersion = MessageVersion.Soap12; } else { MtomMessageEncodingBindingElement te = elements.Find <MtomMessageEncodingBindingElement>(); te.MessageVersion = MessageVersion.Soap12; } CustomBinding customBinding = new CustomBinding(elements); return(customBinding); }
private static void InitialiseService() { try { if (object.Equals(_iBankingService, null)) { var svssAddrService = SVSSAdapter.GetItemsByTag("VCB_IBanking"); var client = ConfigurationManager.GetSection("system.serviceModel/client") as ClientSection; var endpoint = client.Endpoints.Cast <ChannelEndpointElement>().FirstOrDefault(x => x.Name == "IBSAperioSoap"); BasicHttpSecurityMode securityMode = ServiceHost.Equals("https", StringComparison.InvariantCultureIgnoreCase) ? BasicHttpSecurityMode.Transport : BasicHttpSecurityMode.None;; BasicHttpBinding binding = new BasicHttpBinding(securityMode); binding.MaxReceivedMessageSize = int.MaxValue; binding.MaxBufferSize = int.MaxValue; var svssValue = svssAddrService.FirstOrDefault().Value; if (string.IsNullOrEmpty(svssValue)) { svssValue = "http://10.10.107.174:8088/IBS_Aperio.asmx"; } Uri uri = new Uri(svssValue); //Uri uri = new Uri("http://10.10.107.174:8088/IBS_Aperio.asmx"); //Uri uri = new Uri(endpoint.Address); _iBankingService = new BSAperioSoapClient(binding, new EndpointAddress(uri)); if (object.Equals(_iBankingService, null)) { Utilities.WriteToEventLog("VCB IBanking Service", "Failed to initialise ServiceWithTokenSoap", "ServiceWithTokenSoap", 1, EventLogEntryType.Error); } } } catch (Exception ex) { Utilities.WriteToEventLog("VCB IBanking Service", ex, "Failed to initialise the ServiceWithTokenSoap adapter.", 1, EventLogEntryType.Error); } }
private BasicHttpSecurity(BasicHttpSecurityMode mode, HttpTransportSecurity transportSecurity, BasicHttpMessageSecurity messageSecurity) { Fx.Assert(BasicHttpSecurityModeHelper.IsDefined(mode), string.Format("Invalid BasicHttpSecurityMode value: {0}.", mode.ToString())); Mode = mode; _transportSecurity = transportSecurity == null ? new HttpTransportSecurity() : transportSecurity; _messageSecurity = messageSecurity == null ? new BasicHttpMessageSecurity() : messageSecurity; }
// BasicHttpSecurityMode.Message is not supported public static void Create_HttpBinding_SecurityMode_Message_Throws_NotSupported(BasicHttpSecurityMode securityMode) { Assert.Throws<PlatformNotSupportedException>(() => { new BasicHttpBinding(securityMode); }); }
// In the Win8 profile, some settings for the binding security are not supported. internal virtual void CheckSettings() { BasicHttpSecurity security = this.BasicHttpSecurity; if (security == null) { return; } BasicHttpSecurityMode mode = security.Mode; if (mode == BasicHttpSecurityMode.None) { return; } else if (mode == BasicHttpSecurityMode.Message) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(string.Format(SRServiceModel.UnsupportedSecuritySetting, "Mode", mode))); } // Transport.ClientCredentialType = InheritedFromHost is not supported. Fx.Assert( (mode == BasicHttpSecurityMode.Transport) || (mode == BasicHttpSecurityMode.TransportCredentialOnly) || (mode == BasicHttpSecurityMode.TransportWithMessageCredential), "Unexpected BasicHttpSecurityMode value: " + mode); HttpTransportSecurity transport = security.Transport; if (transport?.ClientCredentialType == HttpClientCredentialType.InheritedFromHost) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(string.Format(SRServiceModel.UnsupportedSecuritySetting, "Transport.ClientCredentialType", transport.ClientCredentialType))); } }
public static BasicHttpBinding GetBasicHttpBinding(BasicHttpSecurityMode mode) { var binding = new BasicHttpBinding(mode); Configure(binding); return(binding); }
public static void Snippet3() { // <Snippet3> BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Message); binding.Name = "binding1"; binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard; BasicHttpSecurityMode sMode = binding.Security.Mode; Uri baseAddress = new Uri("http://localhost:8000/servicemodelsamples/service"); Uri address = new Uri("http://localhost:8000/servicemodelsamples/service/calc"); // Create a ServiceHost for the CalculatorService type and provide the base address. ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress); serviceHost.AddServiceEndpoint(typeof(ICalculator), binding, address); // Open the ServiceHostBase to create listeners and start listening for messages. serviceHost.Open(); // The service can now be accessed. Console.WriteLine("The service is ready."); Console.WriteLine("Press <ENTER> to terminate service."); Console.WriteLine(); Console.ReadLine(); // Close the ServiceHostBase to shutdown the service. serviceHost.Close(); // </Snippet3> }
public static void Snippet8() { // <Snippet8> BasicHttpBinding binding = new BasicHttpBinding(); binding.Name = "binding1"; binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard; binding.Security.Mode = BasicHttpSecurityMode.Message; // <Snippet9> BasicHttpSecurity security = binding.Security; BasicHttpMessageSecurity msgSecurity = security.Message; // </Snippet9> // <Snippet10> BasicHttpSecurityMode secMode = security.Mode; // </Snippet10> // <Snippet11> HttpTransportSecurity transSec = security.Transport; // </Snippet11> Console.WriteLine("The message-level security setting is {0}", secMode.ToString()); Console.WriteLine("The transport-level security setting is {0}", transSec.ToString()); // </Snippet8> }
internal static bool TryCreate(SecurityBindingElement sbe, UnifiedSecurityMode mode, HttpTransportSecurity transportSecurity, out BasicHttpSecurity security) { security = null; BasicHttpMessageSecurity messageSecurity = null; if (sbe != null) { mode &= UnifiedSecurityMode.Message | UnifiedSecurityMode.TransportWithMessageCredential; bool isSecureTransportMode; if (!BasicHttpMessageSecurity.TryCreate(sbe, out messageSecurity, out isSecureTransportMode)) { return(false); } } else { mode &= ~(UnifiedSecurityMode.Message | UnifiedSecurityMode.TransportWithMessageCredential); } BasicHttpSecurityMode basicHttpSecurityMode = BasicHttpSecurityModeHelper.ToSecurityMode(mode); Fx.Assert(BasicHttpSecurityModeHelper.IsDefined(basicHttpSecurityMode), string.Format("Invalid BasicHttpSecurityMode value: {0}.", basicHttpSecurityMode.ToString())); security = new BasicHttpSecurity(basicHttpSecurityMode, transportSecurity, messageSecurity); throw ExceptionHelper.PlatformNotSupported("BasicHttpSecurity MessageSecurity is not supported"); }
internal static bool TryCreate(SecurityBindingElement sbe, UnifiedSecurityMode mode, HttpTransportSecurity transportSecurity, out BasicHttpSecurity security) { security = null; BasicHttpMessageSecurity messageSecurity = null; if (sbe != null) { mode &= UnifiedSecurityMode.Message | UnifiedSecurityMode.TransportWithMessageCredential; bool isSecureTransportMode; if (!BasicHttpMessageSecurity.TryCreate(sbe, out messageSecurity, out isSecureTransportMode)) { return(false); } } else { mode &= ~(UnifiedSecurityMode.Message | UnifiedSecurityMode.TransportWithMessageCredential); } BasicHttpSecurityMode basicHttpSecurityMode = BasicHttpSecurityModeHelper.ToSecurityMode(mode); Fx.Assert(BasicHttpSecurityModeHelper.IsDefined(basicHttpSecurityMode), string.Format("Invalid BasicHttpSecurityMode value: {0}.", basicHttpSecurityMode.ToString())); security = new BasicHttpSecurity(basicHttpSecurityMode, transportSecurity, messageSecurity); return(System.ServiceModel.Configuration.SecurityElement.AreBindingsMatching(security.CreateMessageSecurity(), sbe)); }
internal static BasicHttpsSecurityMode ToBasicHttpsSecurityMode(BasicHttpSecurityMode mode) { Fx.Assert(mode == BasicHttpSecurityMode.Transport || mode == BasicHttpSecurityMode.TransportWithMessageCredential, string.Format(CultureInfo.InvariantCulture, "Invalid BasicHttpSecurityMode value: {0}.", mode.ToString())); BasicHttpsSecurityMode basicHttpsSecurityMode = (mode == BasicHttpSecurityMode.Transport) ? BasicHttpsSecurityMode.Transport : BasicHttpsSecurityMode.TransportWithMessageCredential; return basicHttpsSecurityMode; }
// BasicHttpSecurityMode.Message is not supported public static void Create_HttpBinding_SecurityMode_Message_Throws_NotSupported(BasicHttpSecurityMode securityMode) { Assert.Throws <PlatformNotSupportedException>(() => { new BasicHttpBinding(securityMode); }); }
BasicHttpSecurity(BasicHttpSecurityMode mode, HttpTransportSecurity transportSecurity, BasicHttpMessageSecurity messageSecurity) { Fx.Assert(BasicHttpSecurityModeHelper.IsDefined(mode), string.Format("Invalid BasicHttpSecurityMode value: {0}.", mode.ToString())); this.Mode = mode; this.transportSecurity = transportSecurity == null ? new HttpTransportSecurity() : transportSecurity; this.messageSecurity = messageSecurity == null ? new BasicHttpMessageSecurity() : messageSecurity; }
private static void InitialiseService() { try { var svssAddrService = SVSSAdapter.GetItemsByTag("VCB_AutoDebit"); var client = ConfigurationManager.GetSection("system.serviceModel/client") as ClientSection; var endpoint = client.Endpoints.Cast <ChannelEndpointElement>().FirstOrDefault(x => x.Name == "AutoDebitServiceMSSoap"); BasicHttpSecurityMode securityMode = ServiceHost.Equals("https", StringComparison.InvariantCultureIgnoreCase) ? BasicHttpSecurityMode.Transport : BasicHttpSecurityMode.None;; BasicHttpBinding binding = new BasicHttpBinding(securityMode); binding.MaxReceivedMessageSize = int.MaxValue; binding.MaxBufferSize = int.MaxValue; var svssValue = svssAddrService.FirstOrDefault().Value; if (string.IsNullOrEmpty(svssValue)) { svssValue = "http://10.1.9.228:8089/MosaicServiceTest/AutoDebitServiceMS.asmx"; } Uri uri = new Uri(svssValue); //Uri uri = //new Uri("http://10.1.9.228:8089/MosaicServiceTest/AutoDebitServiceMS.asmx"); //Uri uri = new Uri(endpoint.Address); _autoDebitService = new AutoDebitServiceMSSoapClient(binding, new EndpointAddress(uri)); // _autoDebitSoap1 = new AutoDebitServiceMSSoap1Client(binding, new EndpointAddress(uri)); } catch (Exception ex) { //Utilities.WriteToEventLog("VCB AutoDebit Service", ex, "Failed to initialise the AutoDebitService adapter.", 1, EventLogEntryType.Error); } }
/// <summary> /// Initializes a new instance of the System.ServiceModel.BasicHttpBinding class /// with a specified type of security used by the binding. /// </summary> /// <param name="securityMode"> /// The value of System.ServiceModel.BasicHttpSecurityMode that specifies the /// type of security that is used with the SOAP message and for the client. /// </param> public BasicHttpBinding(BasicHttpSecurityMode securityMode) { Security = new BasicHttpSecurity() { Mode = securityMode }; }
internal static BasicHttpsSecurityMode ToBasicHttpsSecurityMode(BasicHttpSecurityMode mode) { Debug.Assert(mode == BasicHttpSecurityMode.Transport || mode == BasicHttpSecurityMode.TransportWithMessageCredential, string.Format(CultureInfo.InvariantCulture, "Invalid BasicHttpSecurityMode value: {0}.", mode.ToString())); BasicHttpsSecurityMode basicHttpsSecurityMode = (mode == BasicHttpSecurityMode.Transport) ? BasicHttpsSecurityMode.Transport : BasicHttpsSecurityMode.TransportWithMessageCredential; return(basicHttpsSecurityMode); }
/// <summary> /// Loads up the loggingConfiguration from the remote web service. /// </summary> protected virtual void LoadConfiguration(Uri loggerServiceUri) { lock (this.lockObject) { try { BasicHttpSecurityMode securityMode = loggerServiceUri.Scheme.ToUpper(CultureInfo.InvariantCulture) == "HTTPS" ? BasicHttpSecurityMode.Transport : BasicHttpSecurityMode.None; BasicHttpBinding binding = new BasicHttpBinding(securityMode) { MaxBufferSize = 2147483647, MaxReceivedMessageSize = 2147483647 }; this.client = new LoggerServiceClient(binding, new EndpointAddress(loggerServiceUri)); this.client.DistributeConfigurationCompleted += this.ConfigurationLoaded; this.client.LogEntriesCompleted += this.CollectEnteries; this.client.DistributeConfigurationAsync(); } catch (InvalidOperationException) { // unable to load the client configuration. // this error will be ignored and no messages will be sent out. // instead they will get stored in the queue and sent once a config is loaded. } } }
public static void BasicHttpBinding( TestContext context, MetadataSet doc, BasicHttpSecurityMode security, TestLabel label) { BasicHttpBinding( context, doc, security, WSMessageEncoding.Text, HttpClientCredentialType.None, AuthenticationSchemes.Anonymous, label); }
internal static bool IsDefined(BasicHttpSecurityMode value) { return (value == BasicHttpSecurityMode.None || value == BasicHttpSecurityMode.Transport || value == BasicHttpSecurityMode.Message || value == BasicHttpSecurityMode.TransportWithMessageCredential || value == BasicHttpSecurityMode.TransportCredentialOnly); }
internal static bool IsDefined(BasicHttpSecurityMode value) { if (((value != BasicHttpSecurityMode.None) && (value != BasicHttpSecurityMode.Transport)) && ((value != BasicHttpSecurityMode.Message) && (value != BasicHttpSecurityMode.TransportWithMessageCredential))) { return(value == BasicHttpSecurityMode.TransportCredentialOnly); } return(true); }
internal static bool IsDefined(BasicHttpSecurityMode value) { if (((value != BasicHttpSecurityMode.None) && (value != BasicHttpSecurityMode.Transport)) && ((value != BasicHttpSecurityMode.Message) && (value != BasicHttpSecurityMode.TransportWithMessageCredential))) { return (value == BasicHttpSecurityMode.TransportCredentialOnly); } return true; }
public void ConfigurationService(BasicHttpSecurityMode basicHttpSecurityMode, HttpClientCredentialType httpClientCredentialType, string Uri, TimeSpan tiempoCierre, TimeSpan tiempoRespuesta) { BasicHttpBinding = new BasicHttpBinding(basicHttpSecurityMode); BasicHttpBinding.Security.Transport.ClientCredentialType = httpClientCredentialType; BasicHttpBinding.CloseTimeout = tiempoCierre; BasicHttpBinding.ReceiveTimeout = tiempoRespuesta; EndpointAddress = new EndpointAddress(new Uri(Uri)); }
internal static bool IsDefined(BasicHttpSecurityMode value) { return(value == BasicHttpSecurityMode.None || value == BasicHttpSecurityMode.Transport || value == BasicHttpSecurityMode.Message || value == BasicHttpSecurityMode.TransportWithMessageCredential || value == BasicHttpSecurityMode.TransportCredentialOnly); }
private BasicHttpBindingElement CreateBasicHttpBinding(string name, BasicHttpSecurityMode mode, HttpClientCredentialType credentialType) { BasicHttpBindingElement basicHttpBinding = new BasicHttpBindingElement(); basicHttpBinding.Name = name; basicHttpBinding.Security.Mode = mode; basicHttpBinding.Security.Transport.ClientCredentialType = credentialType; return(basicHttpBinding); }
public SIPSorceryWebServicePersistor(string serverURL, string authid) { BasicHttpSecurityMode securitymode = (serverURL.StartsWith("https")) ? BasicHttpSecurityMode.Transport : BasicHttpSecurityMode.None; SIPSorcerySecurityHeader securityHeader = new SIPSorcerySecurityHeader(authid); SIPSorceryCustomHeader sipSorceryHeader = new SIPSorceryCustomHeader(new List <MessageHeader>() { securityHeader }); BasicHttpCustomHeaderBinding binding = new BasicHttpCustomHeaderBinding(sipSorceryHeader, securitymode); binding.MaxReceivedMessageSize = MAX_WCF_MESSAGE_SIZE; EndpointAddress address = new EndpointAddress(serverURL); m_provisioningServiceProxy = new ProvisioningServiceClient(binding, address); // Provisioning web service delegates. m_provisioningServiceProxy.IsAliveCompleted += IsAliveCompleted; m_provisioningServiceProxy.TestExceptionCompleted += TestExceptionCompleted; m_provisioningServiceProxy.AreNewAccountsEnabledCompleted += AreNewAccountsEnabledCompleted; m_provisioningServiceProxy.CheckInviteCodeCompleted += CheckInviteCodeCompleted; m_provisioningServiceProxy.LoginCompleted += LoginCompleted; m_provisioningServiceProxy.LogoutCompleted += LogoutCompleted; m_provisioningServiceProxy.GetCustomerCompleted += GetCustomerCompleted; m_provisioningServiceProxy.UpdateCustomerCompleted += UpdateCustomerCompleted; m_provisioningServiceProxy.UpdateCustomerPasswordCompleted += UpdateCustomerPasswordCompleted; m_provisioningServiceProxy.GetSIPAccountsCompleted += GetSIPAccountsCompleted; m_provisioningServiceProxy.GetSIPAccountsCountCompleted += GetSIPAccountsCountCompleted; m_provisioningServiceProxy.AddSIPAccountCompleted += AddSIPAccountCompleted; m_provisioningServiceProxy.UpdateSIPAccountCompleted += UpdateSIPAccountCompleted; m_provisioningServiceProxy.DeleteSIPAccountCompleted += DeleteSIPAccountCompleted; m_provisioningServiceProxy.GetDialPlansCountCompleted += GetDialPlansCountCompleted; m_provisioningServiceProxy.GetDialPlansCompleted += GetDialPlansCompleted; m_provisioningServiceProxy.UpdateDialPlanCompleted += UpdateDialPlanCompleted; m_provisioningServiceProxy.AddDialPlanCompleted += AddDialPlanCompleted; m_provisioningServiceProxy.DeleteDialPlanCompleted += DeleteDialPlanCompleted; m_provisioningServiceProxy.GetSIPProvidersCountCompleted += GetSIPProvidersCountCompleted; m_provisioningServiceProxy.GetSIPProvidersCompleted += GetSIPProvidersCompleted; m_provisioningServiceProxy.AddSIPProviderCompleted += AddSIPProviderCompleted; m_provisioningServiceProxy.UpdateSIPProviderCompleted += UpdateSIPProviderCompleted; m_provisioningServiceProxy.DeleteSIPProviderCompleted += DeleteSIPProviderCompleted; m_provisioningServiceProxy.GetSIPDomainsCompleted += GetSIPDomainsCompleted; m_provisioningServiceProxy.GetSIPRegistrarBindingsCompleted += GetSIPRegistrarBindingsCompleted; m_provisioningServiceProxy.GetSIPRegistrarBindingsCountCompleted += GetSIPRegistrarBindingsCountCompleted; m_provisioningServiceProxy.GetSIPProviderBindingsCompleted += GetSIPProviderBindingsCompleted; m_provisioningServiceProxy.GetSIPProviderBindingsCountCompleted += GetSIPProviderBindingsCountCompleted; m_provisioningServiceProxy.GetCallsCountCompleted += m_provisioningServiceProxy_GetCallsCountCompleted; m_provisioningServiceProxy.GetCallsCompleted += m_provisioningServiceProxy_GetCallsCompleted; m_provisioningServiceProxy.GetCDRsCountCompleted += GetCDRsCountCompleted; m_provisioningServiceProxy.GetCDRsCompleted += GetCDRsCompleted; m_provisioningServiceProxy.CreateCustomerCompleted += CreateCustomerCompleted; m_provisioningServiceProxy.DeleteCustomerCompleted += DeleteCustomerCompleted; m_provisioningServiceProxy.GetTimeZoneOffsetMinutesCompleted += GetTimeZoneOffsetMinutesCompleted; m_provisioningServiceProxy.ExtendSessionCompleted += ExtendSessionCompleted; }
public static void Create_HttpBinding_SecurityMode_Without_SecurityBindingElement(BasicHttpSecurityMode securityMode) { BasicHttpBinding binding = new BasicHttpBinding(securityMode); var bindingElements = binding.CreateBindingElements(); var securityBindingElement = bindingElements.FirstOrDefault(x => x is SecurityBindingElement) as SecurityBindingElement; Assert.True(securityBindingElement == null, string.Format("securityBindingElement should be null when BasicHttpSecurityMode is '{0}'", securityMode)); Assert.True(binding.CanBuildChannelFactory<IRequestChannel>(), string.Format("CanBuildChannelFactory should return true for BasicHttpSecurityMode:'{0}'", securityMode)); binding.BuildChannelFactory<IRequestChannel>(); }
private static void InitialiseService() { try { if (object.Equals(_mBankingService, null)) { //var mBankUrl = SVSSAdapter.GetItemsByTag("VCB_MBanking"); //if (mBankUrl != null & mBankUrl.Count() > 0) //{ // BasicHttpSecurityMode securityMode = ServiceHost.Equals("https", StringComparison.InvariantCultureIgnoreCase) ? BasicHttpSecurityMode.Transport : BasicHttpSecurityMode.None; ; // BasicHttpBinding binding = new BasicHttpBinding(securityMode); // binding.MaxReceivedMessageSize = int.MaxValue; // binding.MaxBufferSize = int.MaxValue; // Uri uri = new Uri(mBankUrl.FirstOrDefault().Value); // _mBankingService = new VcbInternetBankingSoapClient(binding, new EndpointAddress(uri)); //} //else //{ // Utilities.WriteToEventLog("VCB Mobilebanking Service", "No URL for web service VCB_MBanking", "VCB_MBanking", 1, EventLogEntryType.Error); //} //if (object.Equals(_mBankingService, null)) //{ // Utilities.WriteToEventLog("VCB Mobilebanking Service", "Failed to initialise BasicHttpsBinding_VcbInternetBankingSoap", "BasicHttpsBinding_VcbInternetBankingSoap", 1, EventLogEntryType.Error); //} var svssAddrService = SVSSAdapter.GetItemsByTag("VCB_MBanking"); var client = ConfigurationManager.GetSection("system.serviceModel/client") as ClientSection; var endpoint = client.Endpoints.Cast <ChannelEndpointElement>().FirstOrDefault(x => x.Name == "VcbInternetBankingSoap"); BasicHttpSecurityMode securityMode = ServiceHost.Equals("https", StringComparison.InvariantCultureIgnoreCase) ? BasicHttpSecurityMode.Transport : BasicHttpSecurityMode.None;; BasicHttpBinding binding = new BasicHttpBinding(securityMode); binding.MaxReceivedMessageSize = int.MaxValue; binding.MaxBufferSize = int.MaxValue; var svssValue = svssAddrService.FirstOrDefault().Value; if (string.IsNullOrEmpty(svssValue)) { svssValue = "http://192.168.186.220:8090/IBSvr/InternetBankingSvc.asmx"; } Uri uri = new Uri(svssValue); //Uri uri = new Uri("http://192.168.186.220/IBSrv/InternetBankingSvc.asmx"); //Uri uri = new Uri(endpoint.Address); //_mBankingService = new VcbInternetBankingSoapClient(binding, new EndpointAddress(uri)); _mBankingService = new AperioWebServiceSoapClient(binding, new EndpointAddress(uri)); if (object.Equals(_mBankingService, null)) { Utilities.WriteToEventLog("VCB VcbInternetBankingSoapClient Service", "Failed to initialise VcbInternetBankingSoapClient", "VcbInternetBankingSoapClient", 1, EventLogEntryType.Error); } } } catch (Exception ex) { Utilities.WriteToEventLog("VCB Mobilebanking Service", ex, "Failed to initialise the BasicHttpsBinding_VcbInternetBankingSoap adapter.", 1, EventLogEntryType.Error); } }
private BasicHttpSecurity(BasicHttpSecurityMode mode, HttpTransportSecurity transportSecurity) { Fx.Assert(BasicHttpSecurityModeHelper.IsDefined(mode), string.Format("Invalid BasicHttpSecurityMode value: {0}.", mode.ToString())); if (mode == BasicHttpSecurityMode.Message || mode == BasicHttpSecurityMode.TransportWithMessageCredential) { throw new PlatformNotSupportedException($"{nameof(BasicHttpSecurityMode.Message)}, {nameof(BasicHttpSecurityMode.TransportWithMessageCredential)}"); } Mode = mode; _transportSecurity = transportSecurity ?? new HttpTransportSecurity(); }
public List <CurrencyInfo> GetCurrentCurrencyExchangeRate()//ICurrency FromCurrency, ICurrency ToCurrency) { string[] series = new string[] { SEKTOEURSERIE, SEKTOUSDSERIE }; List <CurrencyInfo> oCurrencyInfo = new List <CurrencyInfo>(); try { string s_RemoteAddress = "https://swea.riksbank.se:443/sweaWS/services/SweaWebServiceHttpSoap12Endpoint"; Uri oRemoteUri; try { oRemoteUri = new Uri(s_RemoteAddress); } catch (System.Exception ex) { throw new System.Exception(string.Format("Remoteaddress is not correct formatted {0} ({1})", s_RemoteAddress, ex.Message)); } BasicHttpSecurityMode oSecuritymode = oRemoteUri.Scheme.Equals("https", StringComparison.InvariantCultureIgnoreCase) ? BasicHttpSecurityMode.Transport : BasicHttpSecurityMode.None; BasicHttpBinding oBinding = new BasicHttpBinding(oSecuritymode); oBinding.MaxReceivedMessageSize = int.MaxValue; oBinding.MaxBufferSize = int.MaxValue; SweaWebServicePortTypeClient oClient = new SweaWebServicePortTypeClient(oBinding, new EndpointAddress(s_RemoteAddress)); //SweaWebServicePortTypeClient oClient = new SweaWebServicePortTypeClient(System.ServiceModel.BasicHttpsBinding , "https://swea.riksbank.se:443/sweaWS/services/SweaWebServiceHttpSoap12Endpoint"); Result oResult = oClient.getLatestInterestAndExchangeRates(LanguageType.en, series ); foreach (var ResultGroup in oResult.groups) { foreach (var ResultSerie in ResultGroup.series) { oCurrencyInfo.AddRange(ResultSerie.resultrows.Select(s => new CurrencyInfo { Currency = ResultSerie.seriesid.Trim().Equals(SEKTOUSDSERIE) ? ImperaturGlobal.GetMoney(0, "USD").CurrencyCode : ImperaturGlobal.GetMoney(0, "EUR").CurrencyCode, Date = s.date.Value, Price = Convert.ToDecimal(s.value) } ).ToArray()); } } } catch (System.Exception ex) { int gg = 0; } return(oCurrencyInfo); }
public static void BasicHttpsBinding( TestContext context, MetadataSet doc, BasicHttpSecurityMode security, WSMessageEncoding encoding, HttpClientCredentialType clientCred, AuthenticationSchemes authScheme, TestLabel label) { label.EnterScope("basicHttpsBinding"); BasicHttpBinding_inner( context, doc, security, encoding, clientCred, authScheme, true, label); label.LeaveScope(); }
internal static BasicHttpSecurityMode ToBasicHttpSecurityMode(BasicHttpsSecurityMode mode) { if (!BasicHttpsSecurityModeHelper.IsDefined(mode)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("mode")); } BasicHttpSecurityMode basicHttpSecurityMode = (mode == BasicHttpsSecurityMode.Transport) ? BasicHttpSecurityMode.Transport : BasicHttpSecurityMode.TransportWithMessageCredential; return(basicHttpSecurityMode); }
/// <summary> /// Instantiates an instance of the web service and configures the url /// and the credentials in the message header before returning the /// instance. /// </summary> /// <returns>An instance of the web service</returns> public static BackendDataServiceClient GetService() { BasicHttpSecurityMode securityMode = (IsSecure ? BasicHttpSecurityMode.Transport : BasicHttpSecurityMode.None); EndpointAddress address = new EndpointAddress(WebServiceUrlPath); BasicHttpMessageInspectorBinding binding = new BasicHttpMessageInspectorBinding(new HDServiceMessageInspector(), securityMode); BackendDataServiceClient service = new BackendDataServiceClient(binding, address); return(service); }
public BasicHttpBinding(BasicHttpSecurityMode securityMode) : base() { if (securityMode == BasicHttpSecurityMode.Message) { throw ExceptionHelper.PlatformNotSupported(SR.Format(SR.UnsupportedSecuritySetting, nameof(securityMode), securityMode)); } Initialize(); _basicHttpSecurity.Mode = securityMode; }
private static void InitialiseService() { try { if (object.Equals(_smsService, null)) { //var smsUrl = SVSSAdapter.GetItemsByTag("VCB_SMS"); //if (smsUrl != null & smsUrl.Count() > 0) //{ // BasicHttpSecurityMode securityMode = ServiceHost.Equals("https", StringComparison.InvariantCultureIgnoreCase) ? BasicHttpSecurityMode.Transport : BasicHttpSecurityMode.None; // BasicHttpBinding binding = new BasicHttpBinding(securityMode); // binding.MaxReceivedMessageSize = int.MaxValue; // binding.MaxBufferSize = int.MaxValue; // Uri uri = new Uri("http://10.1.9.228/SMSWS/SMSService.asmx"); // _smsService = new VCBWSSoapClient(binding, new EndpointAddress(uri)); //} //else //{ // Utilities.WriteToEventLog("VCB SMS Service", "No URL for web service VCBWSSoap", "VCBWSSoap", 1, EventLogEntryType.Error); //} //if (object.Equals(_smsService, null)) //{ // Utilities.WriteToEventLog("VCB SMS Service", "Failed to initialise VCBWSSoap", "VCBWSSoap", 1, EventLogEntryType.Error); //} var svssAddrService = SVSSAdapter.GetItemsByTag("VCB_SMS"); var client = ConfigurationManager.GetSection("system.serviceModel/client") as ClientSection; var endpoint = client.Endpoints.Cast <ChannelEndpointElement>().FirstOrDefault(x => x.Name == "SMSWSSoap"); BasicHttpSecurityMode securityMode = ServiceHost.Equals("https", StringComparison.InvariantCultureIgnoreCase) ? BasicHttpSecurityMode.Transport : BasicHttpSecurityMode.None;; BasicHttpBinding binding = new BasicHttpBinding(securityMode); binding.MaxReceivedMessageSize = int.MaxValue; binding.MaxBufferSize = int.MaxValue; var svssValue = svssAddrService.FirstOrDefault().Value; if (string.IsNullOrEmpty(svssValue)) { svssValue = "http://10.1.9.228:8089/SMSWS/SMSService.asmx"; } Uri uri = new Uri(svssValue); //Uri uri = new Uri("http://10.1.9.228:8089/SMSWS/SMSService.asmx"); //Uri uri = new Uri(endpoint.Address); _smsService = new SMSWSSoapClient(binding, new EndpointAddress(uri)); if (object.Equals(_smsService, null)) { Utilities.WriteToEventLog("VCB SMS Service", "Failed to initialise SMSWSSoapClient", "SMSWSSoapClient", 1, EventLogEntryType.Error); } } } catch (Exception ex) { Utilities.WriteToEventLog("VCB SMS Service", ex, "Failed to initialise the VCBWSSoap adapter.", 1, EventLogEntryType.Error); } }
static void BasicHttpBinding_inner ( TestContext context, MetadataSet doc, BasicHttpSecurityMode security, WSMessageEncoding encoding, HttpClientCredentialType clientCred, AuthenticationSchemes authScheme, bool isHttps, TestLabel label) { var sd = (WS.ServiceDescription)doc.MetadataSections [0].Metadata; label.EnterScope ("wsdl"); label.EnterScope ("bindings"); Assert.That (sd.Bindings.Count, Is.EqualTo (1), label.Get ()); var binding = sd.Bindings [0]; Assert.That (binding.ExtensibleAttributes, Is.Null, label.Get ()); Assert.That (binding.Extensions, Is.Not.Null, label.Get ()); bool hasPolicyXml; switch (security) { case BasicHttpSecurityMode.None: if (isHttps) throw new InvalidOperationException (); hasPolicyXml = encoding == WSMessageEncoding.Mtom; break; case BasicHttpSecurityMode.Message: case BasicHttpSecurityMode.Transport: case BasicHttpSecurityMode.TransportWithMessageCredential: if (encoding == WSMessageEncoding.Mtom) throw new InvalidOperationException (); hasPolicyXml = true; break; case BasicHttpSecurityMode.TransportCredentialOnly: if (isHttps) throw new InvalidOperationException (); hasPolicyXml = true; break; default: throw new InvalidOperationException (); } label.LeaveScope (); WS.SoapBinding soap = null; XmlElement xml = null; foreach (var ext in binding.Extensions) { if (ext is WS.SoapBinding) soap = (WS.SoapBinding)ext; else if (ext is XmlElement) xml = (XmlElement)ext; } CheckSoapBinding (soap, WS.SoapBinding.HttpTransport, label); label.LeaveScope (); label.EnterScope ("policy-xml"); if (!hasPolicyXml) Assert.That (xml, Is.Null, label.Get ()); else { Assert.That (xml, Is.Not.Null, label.Get ()); var assertions = AssertPolicy (sd, xml, label); Assert.That (assertions, Is.Not.Null, label.Get ()); if (clientCred == HttpClientCredentialType.Ntlm) AssertPolicy (assertions, NtlmAuthenticationQName, label); if (encoding == WSMessageEncoding.Mtom) AssertPolicy (assertions, MtomEncodingQName, label); switch (security) { case BasicHttpSecurityMode.Message: AssertPolicy (assertions, AsymmetricBindingQName, label); AssertPolicy (assertions, Wss10QName, label); break; case BasicHttpSecurityMode.Transport: AssertPolicy (assertions, TransportBindingQName, label); break; case BasicHttpSecurityMode.TransportWithMessageCredential: AssertPolicy (assertions, SignedSupportingQName, label); AssertPolicy (assertions, TransportBindingQName, label); AssertPolicy (assertions, Wss10QName, label); break; default: break; } Assert.That (assertions.Count, Is.EqualTo (0), label.Get ()); } label.LeaveScope (); label.EnterScope ("services"); Assert.That (sd.Services, Is.Not.Null, label.Get ()); Assert.That (sd.Services.Count, Is.EqualTo (1), label.Get ()); var service = sd.Services [0]; Assert.That (service.Ports, Is.Not.Null, label.Get ()); Assert.That (service.Ports.Count, Is.EqualTo (1), label.Get ()); var port = service.Ports [0]; label.EnterScope ("port"); Assert.That (port.Extensions, Is.Not.Null, label.Get ()); Assert.That (port.Extensions.Count, Is.EqualTo (1), label.Get ()); WS.SoapAddressBinding soap_addr_binding = null; foreach (var extension in port.Extensions) { if (extension is WS.SoapAddressBinding) soap_addr_binding = (WS.SoapAddressBinding)extension; else Assert.Fail (label.Get ()); } Assert.That (soap_addr_binding, Is.Not.Null, label.Get ()); label.LeaveScope (); label.LeaveScope (); // wsdl var importer = new WsdlImporter (doc); label.EnterScope ("bindings"); var bindings = importer.ImportAllBindings (); CheckImportErrors (importer, label); Assert.That (bindings, Is.Not.Null, label.Get ()); Assert.That (bindings.Count, Is.EqualTo (1), label.Get ()); string scheme; if ((security == BasicHttpSecurityMode.Transport) || (security == BasicHttpSecurityMode.TransportWithMessageCredential)) scheme = "https"; else scheme = "http"; CheckBasicHttpBinding ( bindings [0], scheme, security, encoding, clientCred, authScheme, label); label.LeaveScope (); label.EnterScope ("endpoints"); var endpoints = importer.ImportAllEndpoints (); CheckImportErrors (importer, label); Assert.That (endpoints, Is.Not.Null, label.Get ()); Assert.That (endpoints.Count, Is.EqualTo (1), label.Get ()); var uri = isHttps ? MetadataSamples.HttpsUri : MetadataSamples.HttpUri; CheckEndpoint (endpoints [0], uri, label); label.LeaveScope (); }
public static void BasicHttpsBinding ( TestContext context, MetadataSet doc, BasicHttpSecurityMode security, WSMessageEncoding encoding, HttpClientCredentialType clientCred, AuthenticationSchemes authScheme, TestLabel label) { label.EnterScope ("basicHttpsBinding"); BasicHttpBinding_inner ( context, doc, security, encoding, clientCred, authScheme, true, label); label.LeaveScope (); }
public static void BasicHttpBinding ( TestContext context, MetadataSet doc, BasicHttpSecurityMode security, TestLabel label) { BasicHttpBinding ( context, doc, security, WSMessageEncoding.Text, HttpClientCredentialType.None, AuthenticationSchemes.Anonymous, label); }
internal static bool TryCreate(SecurityBindingElement sbe, UnifiedSecurityMode mode, HttpTransportSecurity transportSecurity, out BasicHttpSecurity security) { security = null; BasicHttpMessageSecurity security2 = null; if (sbe != null) { bool flag; mode &= UnifiedSecurityMode.TransportWithMessageCredential | UnifiedSecurityMode.Message; if (!BasicHttpMessageSecurity.TryCreate(sbe, out security2, out flag)) { return false; } } else { mode &= ~(UnifiedSecurityMode.TransportWithMessageCredential | UnifiedSecurityMode.Message); } BasicHttpSecurityMode mode2 = BasicHttpSecurityModeHelper.ToSecurityMode(mode); security = new BasicHttpSecurity(mode2, transportSecurity, security2); return SecurityElementBase.AreBindingsMatching(security.CreateMessageSecurity(), sbe); }
public NetHttpBinding ( BasicHttpSecurityMode securityMode, bool reliableSessionEnabled) { throw new NotImplementedException (); }
internal BasicHttpSecurity (BasicHttpSecurityMode mode) { this.mode = mode; this.message = new BasicHttpMessageSecurity (); this.transport = new HttpTransportSecurity (); }
private Binding CreateBasicBinding(BasicHttpSecurityMode securityMode) { BasicHttpBinding binding = new BasicHttpBinding(securityMode) { MaxBufferSize = 2147483647, MaxReceivedMessageSize = 2147483647 }; #if WPF binding.ReaderQuotas.MaxStringContentLength = 2147483647; #endif return binding; }
public BasicHttpBinding ( BasicHttpSecurityMode securityMode) { security = new BasicHttpSecurity (securityMode); }
public BasicHttpBinding(BasicHttpSecurityMode securityMode) { this.security = new BasicHttpSecurity(); this.Initialize(); this.security.Mode = securityMode; }
public BasicHttpContextBinding(BasicHttpSecurityMode securityMode) : base(securityMode) { this.contextManagementEnabled = true; base.AllowCookies = true; }
internal static bool TryCreate(SecurityBindingElement sbe, UnifiedSecurityMode mode, HttpTransportSecurity transportSecurity, out BasicHttpSecurity security) { security = null; BasicHttpMessageSecurity messageSecurity = null; if (sbe != null) { mode &= UnifiedSecurityMode.Message | UnifiedSecurityMode.TransportWithMessageCredential; bool isSecureTransportMode; if (!BasicHttpMessageSecurity.TryCreate(sbe, out messageSecurity, out isSecureTransportMode)) { return false; } } else { mode &= ~(UnifiedSecurityMode.Message | UnifiedSecurityMode.TransportWithMessageCredential); } BasicHttpSecurityMode basicHttpSecurityMode = BasicHttpSecurityModeHelper.ToSecurityMode(mode); Fx.Assert(BasicHttpSecurityModeHelper.IsDefined(basicHttpSecurityMode), string.Format("Invalid BasicHttpSecurityMode value: {0}.", basicHttpSecurityMode.ToString())); security = new BasicHttpSecurity(basicHttpSecurityMode, transportSecurity, messageSecurity); return SecurityElement.AreBindingsMatching(security.CreateMessageSecurity(), sbe); }
internal BasicHttpSecurity (BasicHttpSecurityMode mode) { this.mode = mode; }
private BasicHttpSecurity(BasicHttpSecurityMode mode, HttpTransportSecurity transportSecurity, BasicHttpMessageSecurity messageSecurity) { this.Mode = mode; this.transportSecurity = (transportSecurity == null) ? new HttpTransportSecurity() : transportSecurity; this.messageSecurity = (messageSecurity == null) ? new BasicHttpMessageSecurity() : messageSecurity; }
/// <summary> /// Initializes a new instance of the BasicHttpBinaryBinding class. /// </summary> /// <param name="securityMode"> /// The value of System.ServiceModel.BasicHttpSecurityMode that specifies /// the type of security that is used with the SOAP message and for the client. /// </param> /// <param name="binaryEncoding"> /// Indicates whether the binary encoding is enabled or not /// </param> public BasicHttpBinaryBinding( BasicHttpSecurityMode securityMode, bool binaryEncoding ) : base(securityMode) { BinaryEncoding = true; BinaryEncoding = binaryEncoding; }
internal HttpBindingBase(BasicHttpSecurityMode securityMode) { }
public BasicHttpContextBinding(BasicHttpSecurityMode securityMode) : base(securityMode) { this.AllowCookies = true; }
public BasicHttpCustomHeaderBinding(IClientCustomHeader customHeader, BasicHttpSecurityMode securityMode) : base(securityMode) { channelBindingElement = new CustomHeaderBindingElement(); channelBindingElement.CustomHeader = customHeader; }
public NetHttpBinding (BasicHttpSecurityMode securityMode) { throw new NotImplementedException (); }
public BasicHttpBinding(BasicHttpSecurityMode securityMode) { }
public static void init(string bindingAddress, BasicHttpSecurityMode sMode) { _addr = bindingAddress; _sMode = sMode; }
/// <summary> /// Initializes a new instance of the BasicHttpBinaryBinding class. /// </summary> /// <param name="securityMode"> /// The value of System.ServiceModel.BasicHttpSecurityMode that specifies /// the type of security that is used with the SOAP message and for the client. /// </param> public BasicHttpBinaryBinding( BasicHttpSecurityMode securityMode ) : this(securityMode, true) { }
/// <summary> /// Initializes a new instance of the <see cref="NetHttpBinding"/> class. /// </summary> /// <param name="securityMode">The security mode.</param> public NetHttpBinding(BasicHttpSecurityMode securityMode) : base(securityMode) { }
public static void CheckBasicHttpBinding ( Binding binding, string scheme, BasicHttpSecurityMode security, WSMessageEncoding encoding, HttpClientCredentialType clientCred, AuthenticationSchemes authScheme, TestLabel label) { label.EnterScope ("http"); if (security == BasicHttpSecurityMode.Message) { Assert.That (binding, Is.InstanceOfType (typeof(CustomBinding)), label.Get ()); } else { Assert.That (binding, Is.InstanceOfType (typeof(BasicHttpBinding)), label.Get ()); var basicHttp = (BasicHttpBinding)binding; Assert.That (basicHttp.EnvelopeVersion, Is.EqualTo (EnvelopeVersion.Soap11), label.Get ()); Assert.That (basicHttp.MessageVersion, Is.EqualTo (MessageVersion.Soap11), label.Get ()); Assert.That (basicHttp.Scheme, Is.EqualTo (scheme), label.Get ()); Assert.That (basicHttp.TransferMode, Is.EqualTo (TransferMode.Buffered), label.Get ()); Assert.That (basicHttp.MessageEncoding, Is.EqualTo (encoding), label.Get ()); Assert.That (basicHttp.Security, Is.Not.Null, label.Get ()); Assert.That (basicHttp.Security.Mode, Is.EqualTo (security), label.Get ()); Assert.That (basicHttp.Security.Transport.ClientCredentialType, Is.EqualTo (clientCred), label.Get ()); Assert.That (basicHttp.Security.Message.AlgorithmSuite, Is.EqualTo (SecurityAlgorithmSuite.Basic256), label.Get ()); } label.EnterScope ("elements"); var elements = binding.CreateBindingElements (); Assert.That (elements, Is.Not.Null, label.Get ()); if ((security == BasicHttpSecurityMode.Message) || (security == BasicHttpSecurityMode.TransportWithMessageCredential)) Assert.That (elements.Count, Is.EqualTo (3), label.Get ()); else Assert.That (elements.Count, Is.EqualTo (2), label.Get ()); TextMessageEncodingBindingElement textElement = null; TransportSecurityBindingElement securityElement = null; HttpTransportBindingElement transportElement = null; AsymmetricSecurityBindingElement asymmSecurityElement = null; MtomMessageEncodingBindingElement mtomElement = null; foreach (var element in elements) { if (element is TextMessageEncodingBindingElement) textElement = (TextMessageEncodingBindingElement)element; else if (element is HttpTransportBindingElement) transportElement = (HttpTransportBindingElement)element; else if (element is TransportSecurityBindingElement) securityElement = (TransportSecurityBindingElement)element; else if (element is AsymmetricSecurityBindingElement) asymmSecurityElement = (AsymmetricSecurityBindingElement)element; else if (element is MtomMessageEncodingBindingElement) mtomElement = (MtomMessageEncodingBindingElement)element; else Assert.Fail (string.Format ( "Unknown element: {0}", element.GetType ()), label.Get ()); } label.EnterScope ("text"); if (encoding == WSMessageEncoding.Text) { Assert.That (textElement, Is.Not.Null, label.Get ()); Assert.That (textElement.WriteEncoding, Is.InstanceOfType (typeof(UTF8Encoding)), label.Get ()); } else { Assert.That (textElement, Is.Null, label.Get ()); } label.LeaveScope (); label.EnterScope ("mtom"); if (encoding == WSMessageEncoding.Mtom) { Assert.That (mtomElement, Is.Not.Null, label.Get ()); } else { Assert.That (mtomElement, Is.Null, label.Get ()); } label.LeaveScope (); label.EnterScope ("security"); if (security == BasicHttpSecurityMode.TransportWithMessageCredential) { Assert.That (securityElement, Is.Not.Null, label.Get ()); Assert.That (securityElement.SecurityHeaderLayout, Is.EqualTo (SecurityHeaderLayout.Lax), label.Get ()); } else { Assert.That (securityElement, Is.Null, label.Get ()); } label.LeaveScope (); label.EnterScope ("asymmetric"); if (security == BasicHttpSecurityMode.Message) { Assert.That (asymmSecurityElement, Is.Not.Null, label.Get ()); } else { Assert.That (asymmSecurityElement, Is.Null, label.Get ()); } label.LeaveScope (); label.EnterScope ("transport"); Assert.That (transportElement, Is.Not.Null, label.Get ()); Assert.That (transportElement.Realm, Is.Empty, label.Get ()); Assert.That (transportElement.Scheme, Is.EqualTo (scheme), label.Get ()); Assert.That (transportElement.TransferMode, Is.EqualTo (TransferMode.Buffered), label.Get ()); label.EnterScope ("auth"); Assert.That (transportElement.AuthenticationScheme, Is.EqualTo (authScheme), label.Get ()); label.LeaveScope (); // auth label.LeaveScope (); // transport label.LeaveScope (); // elements label.LeaveScope (); // http }
public static Binding GetNetHttpBinding(BasicHttpSecurityMode mode) { var binding = new NetHttpBinding(mode); Configure(binding); return binding; }