Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const string apiUrl = "https://facturaelectronica.dian.gov.co/habilitacion/B2BIntegrationEngine/FacturaElectronica",
- apiUserName = "8ac82326-3016-430f-8d69-9efc4bcefd8f";
- string apiPassword = "6361b7b5322acb07ced00a35a85a4cc5183da3a42ede0b07f578067a18425a55";
- EndpointAddress endpointAddress = new EndpointAddress(new Uri(apiUrl));
- SecurityBindingElement securityElement = SecurityBindingElement.CreateUserNameOverTransportBindingElement();
- securityElement.AllowInsecureTransport = false;
- securityElement.EnableUnsecuredResponse = true;
- securityElement.IncludeTimestamp = false;
- TextMessageEncodingBindingElement encodingElement = new TextMessageEncodingBindingElement(MessageVersion.Soap11, Encoding.UTF8);
- HttpsTransportBindingElement transportElement = new HttpsTransportBindingElement();
- CustomBinding binding = new CustomBinding(securityElement, encodingElement, transportElement);
- //basic prueba
- BasicHttpSecurityMode securityMode = new BasicHttpSecurityMode();
- BasicHttpBinding binding2 = new BasicHttpBinding(securityMode);
- // Then assign username and password based on the proxy. For example -
- //var remoteAddress = new EndpointAddress("");
- WSDian.facturaElectronicaPortNameClient service = new WSDian.facturaElectronicaPortNameClient(binding, endpointAddress);
- //WSDian.facturaElectronicaPortNameClient service = new WSDian.facturaElectronicaPortNameClient(binding2, endpointAddress);
- service.ClientCredentials.UserName.UserName = apiUserName;
- service.ClientCredentials.UserName.Password = apiPassword;
- var Obtnonce = GetNonce();
- byte[] archivo = FileToByteArray(@"c:tempws_f0816002834000000000A.zip");
- service.Open();
- WSDian.EnvioFacturaElectronica enviofactura = new WSDian.EnvioFacturaElectronica();
- enviofactura.NIT = "816002834";
- enviofactura.InvoiceNumber = "10";
- enviofactura.IssueDate = Convert.ToDateTime("2018-01-01 05:00:00");
- enviofactura.Document = archivo;
- //temporal
- WSDian.EnvioFacturaElectronicaPeticion envioFacturaElectronicaPeticion = new WSDian.EnvioFacturaElectronicaPeticion();
- WSDian.EnvioFacturaElectronicaRespuesta envioFacturaElectronicaRespuesta = new WSDian.EnvioFacturaElectronicaRespuesta();
- WSDian.AcuseRecibo acuseRecibo = new WSDian.AcuseRecibo();
- WSDian.ReceivedInvoice receivedInvoice = new WSDian.ReceivedInvoice();
- WSDian.facturaElectronicaPortNameClient facturaElectronicaPortNameClient = new WSDian.facturaElectronicaPortNameClient();
- envioFacturaElectronicaPeticion.EnvioFacturaElectronicaPeticion1 = enviofactura;
- var versionSoap = acuseRecibo.GetType();
- acuseRecibo = service.EnvioFacturaElectronica(envioFacturaElectronicaPeticion.EnvioFacturaElectronicaPeticion1);
Add Comment
Please, Sign In to add comment