Blog Listem

11 Ocak 2018 Perşembe

AX 2012 - Uyumsoft E-fatura servisini kullanma

Önce Uyumsoft'un WSDL adresine (https://efatura.uyumsoft.com.tr/Services/Integration?wsdl) daha önce bloğumda bahsettiğim şekilde bağlanan bir servis referansı oluşturun. Servis referansındaki App.Config dosyasına aşağıda kırmızı ile işaretlediğim parametreleri ekleyin. Bunları eklemediğiniz takdirde Uyumsoft varsayılan değer olan 65.536'dan büyük bloklar göndereceği için hata alacaksınız:

 <binding name="BasicHttpBinding_IIntegration"  maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">

class SNBuyum
{
    uyumAX.uyumServis.IntegrationClient wsClient;
    uyumAX.uyumServis.PagedQueryContext pq;
    uyumAX.uyumServis.SystemUsersResponse res;
    uyumAX.uyumServis.PagedResponseOfSystemUser s;
    uyumAX.uyumServis.SystemUser[] u;
    uyumAX.uyumServis.SystemUser u2;

    System.ServiceModel.Description.ClientCredentials clientCredentials;
    System.ServiceModel.Security.UserNamePasswordClientCredential userPass;

    EInvoiceTRParameters                param;
}


void getEinvoiceUserList()
{
    CLRObject                             clientType;
    int i,j,k,l;
    System.Exception ex;


    new InteropPermission(InteropKind::ClrInterop).assert();

    param = EInvoiceTRParameters::find();

    clientType = CLRInterop::getType("uyumAX.uyumServis.IntegrationClient");
    wsClient = AifUtil::createServiceClient(clientType,"https://efatura.uyumsoft.com.tr/services/Integration");

    clientCredentials = wsClient.get_ClientCredentials();

    userPass = clientCredentials.get_UserName();
    userPass.set_UserName(param.UserID);
    userPass.set_Password(param.Password);

    pq = new uyumAX.uyumServis.PagedQueryContext();
    pq.set_PageIndex(0);


    try
    {
        res = wsClient.GetEInvoiceUsers(pq);

        s = Res.get_Value();

         i =   s.get_TotalPages();



        info(strfmt("%1",i));
        for (l=1;l<=i;l++)
        {
            pq.set_PageIndex(l);
            res = wsClient.GetEInvoiceUsers(pq);
            s = Res.get_Value();
            U = s.get_Items();
            k = u.get_Count();
            info(strFmt("%1",k));

            for (j=0;j<k;j++)
            {
                u2 = u.get_Item(j);
                info(u2.get_Title());
            }
            break; //sadece ilk sayfayı al ve çık (örnek dökümü hızlı almak için konuldu.)...
        }
    }
    catch(Exception::CLRError)
    {
        ex = ClrInterop::getLastException();
        if (ex != null)
        {
            ex = ex.get_InnerException();
            if (ex != null)
            {
                error(ex.ToString());
            }
        }

    }
}

Yukarıdaki örnek sisteme kayıtlı efatura kullanıcılarının listesini almak içindi. Diğer fonksiyonları da örnekten yararlanarak yapabilirsiniz.

Not: Sizin kodunuzda uyumAX.uyumServis yerine oluşturduğunuz referansa verdiğiniz isme göre farklı bir adres yazmanız gerekebilir.

4 yorum:

  1. Çok yararlı bir bilgi olmuş. Teşekkürler paylaşım için.

    YanıtlaSil
  2. Örnek olması açısından faydalı olmuş. Buradan anlaşılan Uyumsoft bir E fatura entegratörü olarak servis sunuyor.
    Keşke Microsoft E fatura temellerini sağlayan yapıları AX içine eklese. Giden faturalar, gelen faturalar, statüler, bağlantı testi vs gibi. Parterlere ise kurgu, kontrol ve düzenlemeler vs kalsa.

    YanıtlaSil
    Yanıtlar
    1. Evet, Uyumsoft entegratör. Bir partner araya bir C# DLL koymuş, bu DLL'nin kaynak kodu da olmayınca AX'ın açık kaynak kod yaklaşamına pek uymamış. Bu sebeple Uyumsoft WEB servis başvuru kodunu yazdım ve paylaştım.

      Sil