Example #1
0
        public sendInvoiceResponseType FaturaGonder(string TCKN_VKN, string wsUserName, string wsPass, string Fatura, String UUID)
        {
            byte[] byteFatura = System.Text.Encoding.ASCII.GetBytes(Fatura); //xml verisini byte tipine çeviriyoruz.


            byte[] zipliFile = IonicZipFile(Fatura, UUID); //xml olarak dönüştürülen e-arşiv faturasını zip dosyası içine ekliyoruz.


            string hash = GetHashInfo(zipliFile); //ziplenen e-arşiv faturasının hash bilgisini alıyoruz.


            eArsivInvoicePortTypeClient wsClient = new eArsivInvoicePortTypeClient();

            using (new System.ServiceModel.OperationContextScope((System.ServiceModel.IClientChannel)wsClient.InnerChannel))
            {
                ServicePointManager.Expect100Continue = true;
                ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls12;
                System.ServiceModel.Web.WebOperationContext.Current.OutgoingRequest.Headers.Add(HttpRequestHeader.Authorization, GetAuthorization(wsUserName, wsPass));


                var req = new sendInvoiceRequest() //fatura göndermek için request parametrelerini set ediyoruz.
                {
                    sendInvoiceRequestType = new SendInvoiceRequestType
                    {
                        senderID   = TCKN_VKN,
                        receiverID = "1111111111",
                        fileName   = UUID,
                        binaryData = zipliFile,
                        docType    = "XML",
                        hash       = hash,

                        responsiveOutput = new ResponsiveOutput //gönerilen faturanın dönen cevabında binary olarak fatura görüntüsü almak için. opsiyonel alan.
                        {
                            outputType          = ResponsiveOutputType.PDF,
                            outputTypeSpecified = true
                        }
                    }
                };

                var result = wsClient.sendInvoice(req.sendInvoiceRequestType);

                return(result);
            }
        }