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); } }
/// <summary> /// Sisteme e-Arşiv fatura gönderir /// </summary> /// <returns>Sisteme gönderilen e-Arşiv faturanın bilgileri ve binary PDF datası</returns> public sendInvoiceResponseType EArsivGonder(TextModel m, BaseInvoiceUBL arsiv, ArrayList sslList) { var createdUBL = arsiv.BaseUBL; // e-Arşiv fatura UBL i oluşturulur UBLBaseSerializer serializer = new InvoiceSerializer(); // UBL XML e dönüştürülür var strFatura = serializer.GetXmlAsString(createdUBL); // XML byte tipinden string tipine dönüştürülür byte[] zipliFile = ZipUtility.CompressFile(Encoding.UTF8.GetBytes(strFatura), createdUBL.UUID.Value); // XML ziplenir string hash = GetHashInfo(zipliFile); // zipli dosyanın hash bilgisi alınır ServicePointManager.SecurityProtocol = TlsSetting.TlsSet(sslList); // TLS/SSL ayarları WebServisAdresDegistir(); using (new OperationContextScope(WsClient.InnerChannel)) { if (WebOperationContext.Current != null) { WebOperationContext.Current.OutgoingRequest.Headers.Add(HttpRequestHeader.Authorization, Authorization.GetAuthorization(m.Kullanici, m.Sifre)); } var req = new sendInvoiceRequest { sendInvoiceRequestType = new SendInvoiceRequestType { senderID = m.VknTckn, //gönderici VKN-TCKN receiverID = "2222222222", //alıcı VKN-TCKN fileName = createdUBL.UUID.Value, //dosya ismi binaryData = zipliFile, //gönderilecek fatura docType = "XML", //dosya tipi hash = hash, //dosyanın hash bilgisi customizationParams = new[] { new CustomizationParam { paramName = "BRANCH", //parametre ismi paramValue = m.Sube //şube adı opsiyoneldir. Gönderilmez ise varsayılan olarak "default" şube setlenir. } } } }; return(WsClient.sendInvoice(req.sendInvoiceRequestType)); } }