Пример #1
0
        public TService CreateClient <TService>(EndpointAddress address, IConnectionParameters connectionParameters, MessageVersion messageEncodingVersion, int timeout)
        {
            CustomBinding binder = CreateCustomBinding(connectionParameters.ConnectionTimeout,
                                                       connectionParameters.Credentials, messageEncodingVersion);

            binder.SendTimeout = binder.CloseTimeout = binder.ReceiveTimeout = binder.OpenTimeout = TimeSpan.FromSeconds(timeout);

            var factory = new ChannelFactory <TService>(binder);

            var clientInspector = new CustomMessageInspector();

            if (_securityToken != null)
            {
                clientInspector.Headers.Add(new DigestSecurityHeader(connectionParameters.Credentials, _securityToken));
            }

            var behavior = new CustomEndpointBehavior(clientInspector);

            factory.Endpoint.Behaviors.Add(behavior);

            if (factory.Credentials != null)
            {
                factory.Credentials.UserName.UserName = connectionParameters.Credentials.UserName;
                factory.Credentials.UserName.Password = connectionParameters.Credentials.Password;
            }

            TService service = factory.CreateChannel(address);

            return(service);
        }
Пример #2
0
        public TService CreateClient <TService>(EndpointAddress address,
                                                ConnectionParameters connectionParameters,
                                                MessageVersion messageEncodingVersion)
        {
            CustomBinding customBinding = CreateCustomBinding(connectionParameters.ConnectionTimeout,
                                                              connectionParameters.Credentials,
                                                              messageEncodingVersion);

#pragma warning disable CA2000 // Dispose objects before losing scope
            ChannelFactory <TService> factory = new ChannelFactory <TService>(customBinding);
#pragma warning restore CA2000 // Dispose objects before losing scope

            var clientInspector = new CustomMessageInspector();

            if (securityToken != null)
            {
                clientInspector.Headers.Add(new DigestSecurityHeader(connectionParameters.Credentials, securityToken));
            }

            var behavior = new CustomEndpointBehavior(clientInspector);

            factory.Endpoint.Behaviors.Add(behavior);

            if (factory.Credentials != null)
            {
                factory.Credentials.UserName.UserName = connectionParameters.Credentials.UserName;
                factory.Credentials.UserName.Password = connectionParameters.Credentials.Password;
            }

            TService service = factory.CreateChannel(address);
            return(service);
        }
Пример #3
0
        //Envio Factura Web Service proveedor Carvajal
        public static string UploadFileFE(string encodeFile, string docCode, string codelog)
        {
            string status  = "";
            string idTrans = "";

            try
            {
                CarvajalWS.invoiceServiceClient client = new CarvajalWS.invoiceServiceClient();
                //var testservice = new CustomClient(endpointname, endpoint);

                var requestInterceptor = new CustomEndpointBehavior();
                client.Endpoint.Behaviors.Add(requestInterceptor);

                //CarvajalWS.invoiceServiceClient client = new CarvajalWS.invoiceServiceClient();

                client.Open();

                CarvajalWS.Upload        cuerpo    = new CarvajalWS.Upload();
                CarvajalWS.UploadRequest uploadDoc = new CarvajalWS.UploadRequest();

                uploadDoc.fileName = "Fac" + codelog + docCode + ".txt";
                uploadDoc.fileData = encodeFile;//"RU5DLElOVk9JQyw5MDA0NDA0NDEsMjA1MDU3NzkyOTEsVUJMIDIuMCxESUFOIDEuMCxGQUM0LDIwMTgtMDEtMDMsMDk6MDg6NTksMSxDT1AsMjAxOC0wMS0wMywsOTA1OTY3NDIsMDM1MCwyLDIwMTYtMTItMzENCkVNSSwxLDkwMDQ0MDQ0MSwzMSwyLDE3MDgxNixTUUEgQ09MT01CSUEgUy5BLixTUUEgQ09MT01CSUEgUy5BLixKYXZpZXIsQ2Fsdm8gQm9ycmVybyxBdi4gVW5pdmVyc2l0YXJpYSBTdXIgNTgzIERpcmVjY2lvbiBQcnVlYmEgU1FBIGRlIENvbG9tYmlhIFBydWViYSBRVUFMSVRZIFNFUlZJQ0lPUyBERSBJTlRFR1JBQ0lPTiBDVFMgQ08sVmFsbGUgZGVsIENhdWNhLFNhbnRpYWdvIGRlIENhbGksU2FudGlhZ28gZGUgQ2FsaSw3NjAwMDEsQ08sRUFOMDM1MA0KQ0RFLDEsSW5nIENhbGlkYWQsNjYxODE2MSxwcnVlYmFzc3FhQGdtYWlsLmNvbQ0KQURRLDIsOTAwNDQwNDQxLDEzLDAsMTgxMSxDYXJ2YWphbCBUZWNub2xvZ2lhIHkgU2VydmljaW9zIFMuQS5TLixDYXJ2YWphbCBUZWNub2xvZ2lhIHkgU2VydmljaW9zIFMuQS5TLixVc3VhcmlvLENhbGlkYWQsU2FudGEgUm9zYSA3Ni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L05BMlhZIDAuNi8xIGtWIDI0MCBtbTIgTkVHUk8sLCwsLCwsMTAwMzQyNjQsNDc0MS44MCxDT1AsLCws";

                if (Procesos.nit.IndexOf('_') > 0)
                {
                    uploadDoc.companyId = Procesos.nit.Substring(0, Procesos.nit.IndexOf('_'));
                }
                else if (Procesos.nit.IndexOf('-') > 0)
                {
                    uploadDoc.companyId = Procesos.nit.Substring(0, Procesos.nit.IndexOf('-'));
                }
                else
                {
                    uploadDoc.companyId = Procesos.nit;
                }

                uploadDoc.accountId = Procesos.nit;

                cuerpo.UploadRequest = uploadDoc;

                CarvajalWS.UploadResponse resultadoCliente = new CarvajalWS.UploadResponse();

                resultadoCliente = client.Upload(cuerpo.UploadRequest);

                status  = resultadoCliente.status;
                idTrans = resultadoCliente.transactionId;

                Procesos.RepoMensajes(idTrans, status);

                client.Close();
            }
            catch (Exception ex)
            {
                Procesos.RepoMensajes("catch", ex.Message);
                Procesos.EscribirLogFileTXT("uploadFileFE: " + ex.Message);
            }
            return(idTrans);
        }
Пример #4
0
    public void ApplyDispatchBehavior(ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase)
    {
        CustomEndpointBehavior endpointBehavior = new CustomEndpointBehavior();

        foreach (var endpoint in serviceDescription.Endpoints)
        {
            endpoint.EndpointBehaviors.Add(endpointBehavior);
        }
    }
Пример #5
0
        //Peticion web service estado documento
        public static void DocStatusFE(string codeLog, string transID, string request, Boolean ReSend, string strtext)
        {
            Procesos.responseStatus = "";
            try
            {
                CarvajalWS.invoiceServiceClient client = new CarvajalWS.invoiceServiceClient();
                //var testservice = new CustomClient(endpointname, endpoint);

                var requestInterceptor = new CustomEndpointBehavior();
                client.Endpoint.Behaviors.Add(requestInterceptor);

                //CarvajalWS.invoiceServiceClient client = new CarvajalWS.invoiceServiceClient();

                client.Open();

                CarvajalWS.DocumentStatus        cuerpo           = new CarvajalWS.DocumentStatus();
                CarvajalWS.DocumentStatusRequest requestDocStatus = new CarvajalWS.DocumentStatusRequest();

                if (Procesos.nit.IndexOf('_') > 0)
                {
                    requestDocStatus.companyId = Procesos.nit.Substring(0, Procesos.nit.IndexOf('_'));
                }
                else if (Procesos.nit.IndexOf('-') > 0)
                {
                    requestDocStatus.companyId = Procesos.nit.Substring(0, Procesos.nit.IndexOf('-'));
                }
                else
                {
                    requestDocStatus.companyId = Procesos.nit;
                }

                requestDocStatus.accountId     = Procesos.nit;
                requestDocStatus.transactionId = transID;

                cuerpo.DocumentStatusRequest = requestDocStatus;

                CarvajalWS.DocumentStatusResponse resultadoCliente = new CarvajalWS.DocumentStatusResponse();
                resultadoCliente = client.DocumentStatus(cuerpo.DocumentStatusRequest);
                Procesos.UpdateLog(codeLog, transID, resultadoCliente, request, ReSend, strtext);

                if (resultadoCliente.processStatus == "FAIL")
                {
                    Procesos.RepoMensajes(resultadoCliente.errorMessage, resultadoCliente.errorMessage);
                }
                else if (resultadoCliente.processStatus == "PROCESSING")
                {
                    Procesos.RepoMensajes(resultadoCliente.errorMessage, resultadoCliente.processName);
                }

                client.Close();
            }
            catch (Exception ex)
            {
                Procesos.RepoMensajes("catch", ex.Message);
                Procesos.EscribirLogFileTXT("DocStatusFE: " + ex.Message);
            }
        }
Пример #6
0
        //Peticion web service descarga documento
        public static string DownloadDocFE(string codeLog, string docType, string numDoc, string downloadType)
        {
            Procesos.responseStatus = "";
            try
            {
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3;
                CarvajalWS.invoiceServiceClient client           = new CarvajalWS.invoiceServiceClient();
                CarvajalWS.DownloadResponse     resultadoCliente = null;

                var requestInterceptor = new CustomEndpointBehavior();
                client.Endpoint.Behaviors.Add(requestInterceptor);

                client.Open();

                CarvajalWS.Download        cuerpo             = new CarvajalWS.Download();
                CarvajalWS.DownloadRequest requestDownloadDoc = new CarvajalWS.DownloadRequest();

                if (Procesos.nit.IndexOf('_') > 0)
                {
                    requestDownloadDoc.companyId = Procesos.nit.Substring(0, Procesos.nit.IndexOf('_'));
                }
                else if (Procesos.nit.IndexOf('-') > 0)
                {
                    requestDownloadDoc.companyId = Procesos.nit.Substring(0, Procesos.nit.IndexOf('-'));
                }
                else
                {
                    requestDownloadDoc.companyId = Procesos.nit;
                }
                requestDownloadDoc.accountId      = Procesos.nit;
                requestDownloadDoc.documentType   = docType;
                requestDownloadDoc.documentNumber = numDoc;
                requestDownloadDoc.resourceType   = downloadType;

                cuerpo.DownloadRequest = requestDownloadDoc;

                resultadoCliente = new CarvajalWS.DownloadResponse();
                resultadoCliente = client.Download(cuerpo.DownloadRequest);
                Procesos.EscribirLogFileTXT(downloadType + resultadoCliente.status);
                //Procesos.EscribirLogFileTXT("Archivo" + resultadoCliente.downloadData);
                client.Close();
                //if()
                Procesos.requestSend = "";
                return(resultadoCliente.downloadData);
            }
            catch (Exception ex)
            {
                Procesos.EscribirLogFileTXT("DownloadDocFE: " + ex.Message);
                return(ex.Message);
            }
        }
Пример #7
0
        //Peticion web service descarga documento
        public static string DownloadDocFE(string codeLog, string docType, string numDoc, string downloadType)
        {
            Procesos.responseStatus = "";
            try
            {
                CarvajalWS.invoiceServiceClient client = new CarvajalWS.invoiceServiceClient();

                var requestInterceptor = new CustomEndpointBehavior();
                client.Endpoint.Behaviors.Add(requestInterceptor);

                client.Open();

                CarvajalWS.Download        cuerpo             = new CarvajalWS.Download();
                CarvajalWS.DownloadRequest requestDownloadDoc = new CarvajalWS.DownloadRequest();

                if (Procesos.nit.IndexOf('_') > 0)
                {
                    requestDownloadDoc.companyId = Procesos.nit.Substring(0, Procesos.nit.IndexOf('_'));
                }
                else if (Procesos.nit.IndexOf('-') > 0)
                {
                    requestDownloadDoc.companyId = Procesos.nit.Substring(0, Procesos.nit.IndexOf('-'));
                }
                else
                {
                    requestDownloadDoc.companyId = Procesos.nit;
                }
                requestDownloadDoc.accountId      = Procesos.nit;
                requestDownloadDoc.documentType   = docType;
                requestDownloadDoc.documentNumber = numDoc;
                requestDownloadDoc.resourceType   = downloadType;

                cuerpo.DownloadRequest = requestDownloadDoc;

                CarvajalWS.DownloadResponse resultadoCliente = new CarvajalWS.DownloadResponse();
                resultadoCliente = client.Download(cuerpo.DownloadRequest);
                Procesos.RepoMensajes("catch", resultadoCliente.status);
                client.Close();
                return(resultadoCliente.downloadData);
            }
            catch (Exception ex)
            {
                Procesos.RepoMensajes("catch", ex.Message);
                Procesos.EscribirLogFileTXT("DocStatusFE: " + ex.Message);
                return(ex.Message);
            }
        }
        public void EndpointBehaviorTest()
        {
            ServiceCollection ServiceCollection = new ServiceCollection();

            CustomEndpointBehavior?CustomEndpointBehavior = null;

            ServiceCollection
            .AddSoapClient <ITestProxy, TestProxy>((serviceProvider, soapClientFactory)
                                                   => new ChannelFactory <ITestProxy>(new BasicHttpBinding(), new EndpointAddress("http://localhost:9999/")))
            .AddEndpointBehavior((serviceProvider) =>
            {
                CustomEndpointBehavior = new CustomEndpointBehavior();
                return(CustomEndpointBehavior);
            });

            ServiceProvider ServiceProvider = ServiceCollection.BuildServiceProvider();

            ITestProxy TestProxy = ServiceProvider.GetRequiredService <ITestProxy>();

            Assert.IsNotNull(CustomEndpointBehavior);
            Assert.IsTrue(CustomEndpointBehavior.ClientBehaviorApplied);
        }
Пример #9
0
        //Peticion web service estado documento
        public static void DocStatusFE(string codeLog, string transID, string request, Boolean ReSend, string strtext)
        {
            Procesos.responseStatus = "";
            try
            {
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3;
                CarvajalWS.invoiceServiceClient   client           = new CarvajalWS.invoiceServiceClient();
                CarvajalWS.DocumentStatusResponse resultadoCliente = null;
                //var testservice = new CustomClient(endpointname, endpoint);

                var requestInterceptor = new CustomEndpointBehavior();
                client.Endpoint.Behaviors.Add(requestInterceptor);

                //CarvajalWS.invoiceServiceClient client = new CarvajalWS.invoiceServiceClient();

                client.Open();

                CarvajalWS.DocumentStatus        cuerpo           = new CarvajalWS.DocumentStatus();
                CarvajalWS.DocumentStatusRequest requestDocStatus = new CarvajalWS.DocumentStatusRequest();

                if (Procesos.nit.IndexOf('_') > 0)
                {
                    requestDocStatus.companyId = Procesos.nit.Substring(0, Procesos.nit.IndexOf('_'));
                }
                else if (Procesos.nit.IndexOf('-') > 0)
                {
                    requestDocStatus.companyId = Procesos.nit.Substring(0, Procesos.nit.IndexOf('-'));
                }
                else
                {
                    requestDocStatus.companyId = Procesos.nit;
                }

                requestDocStatus.accountId     = Procesos.nit;
                requestDocStatus.transactionId = transID;

                cuerpo.DocumentStatusRequest = requestDocStatus;

                resultadoCliente = new CarvajalWS.DocumentStatusResponse();
                resultadoCliente = client.DocumentStatus(cuerpo.DocumentStatusRequest);

                //if (resultadoCliente.processStatus == "FAIL")
                //{
                //    Procesos.EscribirLogFileTXT("DocStatusFE: " + resultadoCliente.errorMessage + "n/" + resultadoCliente.errorMessage);
                //}
                //else if (resultadoCliente.processStatus == "PROCESSING")
                //{
                //    Procesos.EscribirLogFileTXT("DocStatusFE: " + resultadoCliente.errorMessage + "n/" + resultadoCliente.errorMessage);
                //}
                Procesos.requestSend = "";
                if (resultadoCliente != null)
                {
                    Procesos.UpdateLog(codeLog, transID, resultadoCliente, request, ReSend, strtext);
                }
                client.Close();
            }
            catch (Exception ex)
            {
                Procesos.EscribirLogFileTXT("DocStatusFE: " + ex.Message);
            }
        }
Пример #10
0
        //Envio Factura Web Service proveedor Carvajal
        public static string UploadFileFE(string encodeFile, string tipoDoc, string docNum)
        {
            Procesos.responseStatus = "";
            string status        = "";
            string idTrans       = "";
            string nombreArchvio = "";

            switch (tipoDoc)
            {
            case "01":
                nombreArchvio = "Factura de Venta " + docNum;
                break;

            case "02":
                nombreArchvio = "Factura de Exportacion " + docNum;
                break;

            case "03":
                nombreArchvio = "Factura de Contingencia " + docNum;
                break;

            case "91":
                nombreArchvio = "Nota Credito " + docNum;
                break;

            case "92":
                nombreArchvio = "Nota Debito " + docNum;
                break;
            }

            try
            {
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3;
                CarvajalWS.invoiceServiceClient client           = new CarvajalWS.invoiceServiceClient();
                CarvajalWS.UploadResponse       resultadoCliente = new CarvajalWS.UploadResponse();

                var requestInterceptor = new CustomEndpointBehavior();
                client.Endpoint.Behaviors.Add(requestInterceptor);

                client.Open();

                CarvajalWS.Upload        cuerpo    = new CarvajalWS.Upload();
                CarvajalWS.UploadRequest uploadDoc = new CarvajalWS.UploadRequest();

                uploadDoc.fileName = nombreArchvio + ".txt";
                uploadDoc.fileData = encodeFile;

                if (Procesos.nit.IndexOf('_') > 0)
                {
                    uploadDoc.companyId = Procesos.nit.Substring(0, Procesos.nit.IndexOf('_'));
                }
                else if (Procesos.nit.IndexOf('-') > 0)
                {
                    uploadDoc.companyId = Procesos.nit.Substring(0, Procesos.nit.IndexOf('-'));
                }
                else
                {
                    uploadDoc.companyId = Procesos.nit;
                }

                uploadDoc.accountId = Procesos.nit;

                cuerpo.UploadRequest = uploadDoc;

                resultadoCliente = new CarvajalWS.UploadResponse();

                resultadoCliente = client.Upload(cuerpo.UploadRequest);

                idTrans = resultadoCliente.transactionId;

                client.Close();
            }
            catch (Exception ex)
            {
                Procesos.EscribirLogFileTXT("uploadFileFE: " + ex.Message);
            }
            return(idTrans);
        }