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.
service etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
service etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
5 Ağustos 2015 Çarşamba
10 Şubat 2015 Salı
C# - Create COM compatible DLL and use without app.config file with a web service consume
You can make your DLL as COM compatible a way which I learned from an article:
[ComVisible(true)]
Also Register for COM interop checkbox should be checked from project properties->build page.
You can use Intellisense when using COM object with this:
[ClassInterface(ClassInterfaceType.AutoDual)]
After all you can use DLL yet from your COM compatible language (except there is no binding). When you try to use you get an error; "OLE IDispatch exception code 0 from System.ServiceModel: ServiceModel...". You have to copy app.config file as yourexefile.EXE.app.config or add these red code parts to your class (I got help for this from Paul Mrozowski):
For add this sample web service to your project, you have to right click at Service References than Add Service Reference-> write https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx to address and push GO.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using System.ServiceModel;
namespace TCKimlik
{
[ComVisible(true)] //for visible COM object
[ClassInterface(ClassInterfaceType.AutoDual)] //for intellisense at using COM
[ProgId("TCKimlik.TCSorgula")] //COM object name
public class TCKimlikClass
{
public bool Dogrula(string adi,string soyadi,Int64 tc,Int32 dogumT)
{
bool ret = false;
//------ for using COM compatible DLL without APP.CONFIG
BasicHttpsBinding binding = new BasicHttpsBinding();
EndpointAddress address = new EndpointAddress("https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx");
//------ run --------
try
{
Sorgula.KPSPublicSoapClient servis = new Sorgula.KPSPublicSoapClient(binding, address);
ret = servis.TCKimlikNoDogrula(tc, adi, soyadi, dogumT);
}
catch
{
}
return ret;
}
}
}
Now you can use this DLL at COM compatible languages plus .NET. But if you move DLL to client computer without setup you have to register with regasm. I shared project.
There is a sample usage with Microsoft Visual Foxpro:
o=CREATEOBJECT("tckimlik.tcsorgula")
?o.Dogrula("METİN","EMRE",11111111111,1980)
[ComVisible(true)]
Also Register for COM interop checkbox should be checked from project properties->build page.
You can use Intellisense when using COM object with this:
[ClassInterface(ClassInterfaceType.AutoDual)]
After all you can use DLL yet from your COM compatible language (except there is no binding). When you try to use you get an error; "OLE IDispatch exception code 0 from System.ServiceModel: ServiceModel...". You have to copy app.config file as yourexefile.EXE.app.config or add these red code parts to your class (I got help for this from Paul Mrozowski):
For add this sample web service to your project, you have to right click at Service References than Add Service Reference-> write https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx to address and push GO.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using System.ServiceModel;
namespace TCKimlik
{
[ComVisible(true)] //for visible COM object
[ClassInterface(ClassInterfaceType.AutoDual)] //for intellisense at using COM
[ProgId("TCKimlik.TCSorgula")] //COM object name
public class TCKimlikClass
{
public bool Dogrula(string adi,string soyadi,Int64 tc,Int32 dogumT)
{
bool ret = false;
//------ for using COM compatible DLL without APP.CONFIG
BasicHttpsBinding binding = new BasicHttpsBinding();
EndpointAddress address = new EndpointAddress("https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx");
//------ run --------
try
{
Sorgula.KPSPublicSoapClient servis = new Sorgula.KPSPublicSoapClient(binding, address);
ret = servis.TCKimlikNoDogrula(tc, adi, soyadi, dogumT);
}
catch
{
}
return ret;
}
}
}
Now you can use this DLL at COM compatible languages plus .NET. But if you move DLL to client computer without setup you have to register with regasm. I shared project.
There is a sample usage with Microsoft Visual Foxpro:
o=CREATEOBJECT("tckimlik.tcsorgula")
?o.Dogrula("METİN","EMRE",11111111111,1980)
Etiketler:
0,
app.config,
C#,
COM DLL,
exception code,
IDispatch,
OLE,
service,
System.ServiceModel,
web,
without
25 Aralık 2014 Perşembe
AX 2012 - Consume web service with sample turkish citizen ID check
I used a blog when developing this sample. You can download to ready use XPO from there .
1- Create a new Class Library type C# project at Visual Studio.
2- Press right click at project name, select Add service reference and write https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx?WSDL to Address, write Sorgula to Namespace and press GO so service reference will be shown.
3- Add your project to AOT with Add to AOT .
4- Go to project properties and make
Debug Target = No
Deploy to Client = Yes
Deploy to EP = No
Deploy to Server = Yes
Deploy to SSRS = No
5. Deploy project and down all AX clients. If you don't down all clients at deploy, deploy will fail accoring to blog writer.
This is my sample job:
//Metin Emre, 2.10.2014
static void TCIDTest(Args _args)
{
CLRObject clientType;
TCKimlik.Sorgula.KPSPublicSoapClient cl;
System.Exception ex;
boolean s,erOccured;
System.Exception e;
str ret;
new InteropPermission(InteropKind::ClrInterop).assert();
try
{
clientType = CLRInterop::getType("TCKimlik.Sorgula.KPSPublicSoapClient");
cl = AifUtil::createServiceClient(clientType);
s = cl.TCKimlikNoDogrula(11111111111,"METİN","EMRE",1999);
}
catch(Exception::CLRError)
{
Ex=CLRInterop::getLastException();
ret = Ex.ToString();
if (!strScan(ret,"Not a valid citizen ID",1,strLen(Ret)))
{
info(Ex.ToString());
erOccured = true;
}
}
if (!erOccured)
info(strFmt("%1",s));
}
11111111111 is citizen ID, name and surname after citizen ID and the last born year. If all these are correct, returns true else false.
1- Create a new Class Library type C# project at Visual Studio.
2- Press right click at project name, select Add service reference and write https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx?WSDL to Address, write Sorgula to Namespace and press GO so service reference will be shown.
3- Add your project to AOT with Add to AOT .
4- Go to project properties and make
Debug Target = No
Deploy to Client = Yes
Deploy to EP = No
Deploy to Server = Yes
Deploy to SSRS = No
5. Deploy project and down all AX clients. If you don't down all clients at deploy, deploy will fail accoring to blog writer.
This is my sample job:
//Metin Emre, 2.10.2014
static void TCIDTest(Args _args)
{
CLRObject clientType;
TCKimlik.Sorgula.KPSPublicSoapClient cl;
System.Exception ex;
boolean s,erOccured;
System.Exception e;
str ret;
new InteropPermission(InteropKind::ClrInterop).assert();
try
{
clientType = CLRInterop::getType("TCKimlik.Sorgula.KPSPublicSoapClient");
cl = AifUtil::createServiceClient(clientType);
s = cl.TCKimlikNoDogrula(11111111111,"METİN","EMRE",1999);
}
catch(Exception::CLRError)
{
Ex=CLRInterop::getLastException();
ret = Ex.ToString();
if (!strScan(ret,"Not a valid citizen ID",1,strLen(Ret)))
{
info(Ex.ToString());
erOccured = true;
}
}
if (!erOccured)
info(strFmt("%1",s));
}
11111111111 is citizen ID, name and surname after citizen ID and the last born year. If all these are correct, returns true else false.
Kaydol:
Kayıtlar (Atom)