ConnectorServiceClient CreateConnectorServiceClient(string url, string username, string password) { var basicHttpBinding = CreateBasicHttpBinding(); var endpointAddress = new EndpointAddress(url); var client = new ConnectorServiceClient(basicHttpBinding, endpointAddress); client.ClientCredentials.UserName.UserName = username; client.ClientCredentials.UserName.Password = password; return(client); }
/// <summary> /// UserServiceClient ve ConnectorServiceClient sınıflarından nesneler oluşturulur. /// Önce wsLogin ile kullanıcı girişi yapılır ve dönen cookie bilgisi connectorService nesnesine her talebi için atanır. /// </summary> /// <returns>ServiceResponse Türünde yanıt döner</returns> public async Task Execute() { var result = new ServiceResponse() { Hatali = false, }; if (Invoice == null) { throw new ArgumentNullException("Invoice boş olamaz!"); } try { this._connectorWsClient = EFinansHelper.CreateConnectorServiceClient( ServiceInfo.ServiceUrl, ServiceInfo.UserName, ServiceInfo.Password); this._userWsClient = EFinansHelper.CreateUserServiceClient( ServiceInfo.UserServiceUrl, ServiceInfo.UserName, ServiceInfo.Password); var cookie = EFinansHelper.GetValidCookie(_userWsClient, ServiceInfo.UserName, ServiceInfo.Password); string belgeOid; using (new OperationContextScope(_connectorWsClient.InnerChannel)) { var requestProp = new HttpRequestMessageProperty(); requestProp.Headers["Set-Cookie"] = cookie; OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = requestProp; var request = PrepareGidenBelgeParametreleri(); belgeOid = _connectorWsClient.belgeGonderExt(request); } result.Sonuc = string.IsNullOrEmpty(belgeOid) ? "İşlem tamamlandı!" : "İşlem başarıyla tamamlandı"; result.Data = new { belgeOid }; } catch (Exception ex) { result.Hatali = true; result.Istisna += ex.ToString(); } this.Result = Task.FromResult(result); }
public async Task Execute() { var serviceResponse = new ServiceResponse() { Hatali = false, }; _serviceProxy = EFinansHelper.CreateConnectorServiceClient( ServiceInfo.ServiceUrl, ServiceInfo.UserName, ServiceInfo.Password); string vergiTcKimlikNo = ServiceInfo.SupplierVkn; string[] ettnler = this.UUIDs; //new string[] { "291DB9EC-4FC4-4F7E-BDD2-C5C54F62A635", "3e60aad6-48cc-4f76-a20c-5fc892d1a837" }; string belgeTuru = "FATURA"; // "FATURA" ve "UYGULAMA_YANITI" string belgeFormati = "UBL"; // "HTML", "PDF", "UBL" byte[] ublZip = _serviceProxy.gelenBelgeleriIndir(vergiTcKimlikNo, ettnler, belgeTuru, belgeFormati); serviceResponse.Sonuc = "UBL Başarıyla alındı"; serviceResponse.Data = ublZip; this.Result = Task.FromResult(serviceResponse); }
/// <summary> /// Sets up the connector so it is able to open connections to the remote endpoint, and opens the channel. /// </summary> public void Open() { //TODO: Check if the connector is already open, or if the connector is in a faulted state. // Connection string if (ConnectionString == null) throw new ConnectorException(ConnectorException.MSG_NULL_CONNECTION_STRING, ConnectorException.ReasonType.NullConnectionString); else if (Formatter == null) throw new ConnectorException(ConnectorException.MSG_NULL_FORMATTER, ConnectorException.ReasonType.NullFormatter); Dictionary<string, List<string>> parameters = ConnectionStringParser.ParseConnectionString(ConnectionString); string endpointName = null, endpointAddress = null, bindingClass = null, bindingConfiguration = null; // Parameters foreach (KeyValuePair<string, List<string>> parm in parameters) switch (parm.Key) { case "binding": bindingClass = parm.Value[0]; break; case "bindingConfiguration": bindingConfiguration = parm.Value[0]; break; case "endpointname": endpointName = parm.Value[0]; break; case "endpointaddress": endpointAddress = parm.Value[0]; break; } if (bindingClass != null) { Binding binding = null; switch (bindingClass) { case "wsHttpBinding": if (!String.IsNullOrEmpty(bindingConfiguration)) binding = new WSHttpBinding(bindingConfiguration); else binding = new WSHttpBinding(SecurityMode.None, false); break; case "basicHttpBinding": if (!String.IsNullOrEmpty(bindingConfiguration)) binding = new BasicHttpBinding(bindingConfiguration); else binding = new BasicHttpBinding(); break; default: throw new InvalidOperationException("Could not understand binding"); } if (endpointAddress == null) throw new InvalidOperationException("When manually specifying binding you must specify an endpointAddress"); else wcfClient = new ConnectorServiceClient(binding, new EndpointAddress(endpointAddress)); } // Create the client else if (endpointName == null) throw new InvalidOperationException("The connection string must include the 'endpointName' attribute!"); else if (endpointAddress == null) wcfClient = new ConnectorServiceClient(endpointName); else wcfClient = new ConnectorServiceClient(endpointName, endpointAddress); #if WINDOWS_PHONE ((ICommunicationObject)wcfClient).Open(); #else wcfClient.Open(); // Using the app.config wcfConfiguration = ConfigurationManager.GetSection("marc.everest.connectors.wcf") as MARC.Everest.Connectors.WCF.Configuration.ConfigurationSection; if (Formatter == null) Formatter = (wcfConfiguration.Formatter as ICloneable).Clone() as IStructureFormatter; #endif }
/// <summary> /// Sets up the connector so it is able to open connections to the remote endpoint, and opens the channel. /// </summary> public void Open() { //TODO: Check if the connector is already open, or if the connector is in a faulted state. // Connection string if (ConnectionString == null) { throw new ConnectorException(ConnectorException.MSG_NULL_CONNECTION_STRING, ConnectorException.ReasonType.NullConnectionString); } else if (Formatter == null) { throw new ConnectorException(ConnectorException.MSG_NULL_FORMATTER, ConnectorException.ReasonType.NullFormatter); } Dictionary <string, List <string> > parameters = ConnectionStringParser.ParseConnectionString(ConnectionString); string endpointName = null, endpointAddress = null, bindingClass = null, bindingConfiguration = null; // Parameters foreach (KeyValuePair <string, List <string> > parm in parameters) { switch (parm.Key) { case "binding": bindingClass = parm.Value[0]; break; case "bindingConfiguration": bindingConfiguration = parm.Value[0]; break; case "endpointname": endpointName = parm.Value[0]; break; case "endpointaddress": endpointAddress = parm.Value[0]; break; } } if (bindingClass != null) { Binding binding = null; switch (bindingClass) { case "wsHttpBinding": if (!String.IsNullOrEmpty(bindingConfiguration)) { binding = new WSHttpBinding(bindingConfiguration); } else { binding = new WSHttpBinding(SecurityMode.None, false); } break; case "basicHttpBinding": if (!String.IsNullOrEmpty(bindingConfiguration)) { binding = new BasicHttpBinding(bindingConfiguration); } else { binding = new BasicHttpBinding(); } break; default: throw new InvalidOperationException("Could not understand binding"); } if (endpointAddress == null) { throw new InvalidOperationException("When manually specifying binding you must specify an endpointAddress"); } else { wcfClient = new ConnectorServiceClient(binding, new EndpointAddress(endpointAddress)); } } // Create the client else if (endpointName == null) { throw new InvalidOperationException("The connection string must include the 'endpointName' attribute!"); } else if (endpointAddress == null) { wcfClient = new ConnectorServiceClient(endpointName); } else { wcfClient = new ConnectorServiceClient(endpointName, endpointAddress); } #if WINDOWS_PHONE ((ICommunicationObject)wcfClient).Open(); #else wcfClient.Open(); // Using the app.config wcfConfiguration = ConfigurationManager.GetSection("marc.everest.connectors.wcf") as MARC.Everest.Connectors.WCF.Configuration.ConfigurationSection; if (Formatter == null) { Formatter = (wcfConfiguration.Formatter as ICloneable).Clone() as IStructureFormatter; } #endif }