5 Ağustos 2015 Çarşamba

AX 2009 - Consume web service with TC ID number test sample

I rewrite sample which I wrote for 2012. When I write the service I used Microsoft'un white page about consume web services in 2009. White page written for a web service which is not avaliable than but anyway worked.

First run AOT->References->Add service reference:

Write https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx?WSDL to WSDL URL field.

I wrote TCSorgula to .NET code namespace field. I left reference name field with default written TCSorgula value.

After I wrote this method:

public server static boolean Sorgula(Int64 _TCID,str _name,str _surname, int _birthDate, boolean _interActive = false)
{
    TCSorgula.KPSPublicSoapClient  cl;
    boolean ret;
    System.Exception                      ex;

    str st;
    ;
    try
    {
        new InteropPermission(InteropKind::ClrInterop).assert();
        cl = new TCSorgula.KPSPublicSoapClient("KPSPublicSoap");
        ret = cl.TCKimlikNoDogrula(_TCID,_name,_surname,_dogumYili);
        CodeAccessPermission::revertAssert();
    }
    catch(Exception::CLRError)
    {
        exceptionTextFallThrough();
    }
    if (_interActive)
    {
        if (ret)
            info("TC ID verified!..");
        else
            warning("Failed TC ID verification!..");
    }
    return ret;
}



My job for run code:

static void TCKimlikTest(Args _args)
{
    ;
    TCKimlik::Sorgula(11111111111,"METİN","EMRE",1911,true);
}


 
 TC ID verification service returns false when name or birthdate is wrong in case invalid ID strangely run exception. I was catching this case in AX 2012 with search "T.C. Kimlik No alanına girdiğiniz değer geçerli bir T.C. Kimlik Numarası değildir" value in return error string. Unfortunately I failed this with 2009. So I can just catch correct ID or invalid ID/failed service.

If VS doesn't installed you can install .NET framework SDK.

Hiç yorum yok:

Yorum Gönder