![]() |
|
|
#1 (permalink) |
|
Sil_Baştan
![]() Üyelik tarihi: Dec 2006
Nerden: İstanbul
Mesaj Sayısı: 2.364
Konu Sayısı: 127
Takım: Fenerbahçe
Rep Gücü: 4350
Rep Puanı: 434699
Rep Derecesi :
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
Ruh Hali:
|
TC Kimlik No Sorgulama (Url Connection ile) import java.net.*; import java.io.*; public class TCKimlik { public static String getNodeValue(String xml, String tag) { int p1 = xml.indexOf("<"+tag+">"); int p2 = xml.indexOf("</"+tag+">"); if (p1>=0 && p2>=0) return xml.substring(p1+tag.length()+2,p2); else return null; } public String[] getTCKimlikBilgisi(String KimlikNo) { DataOutputStream output = null; DataInputStream input = null; String result = ""; URL url; URLConnection conn; String[] KimlikBilgileri = new String[3]; try { String parameters = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + " <soap:Body>" + " <TCKimlikNoDogrula xmlns=\"http://kps.nvi.gov.tr/WS/Public\">" + " <tcKimlikNo>" + KimlikNo + "</tcKimlikNo>" + " </TCKimlikNoDogrula>" + " </soap:Body>" + "</soap:Envelope>"; url = new URL("http://tckimlik.nvi.gov.tr/kpspublic.asmx"); conn = url.openConnection(); conn.setDoInput(true); conn.setDoOutput(true); conn.setUseCaches(false); conn.setRequestProperty("Content-Type", "text/xml; charset=utf-8"); conn.setRequestProperty("SOAPAction", "http://kps.nvi.gov.tr/WS/Public/TCKimlikNoDogrula"); output = new DataOutputStream(conn.getOutputStream()); output.writeBytes(parameters); output.flush(); output.close(); String str; input = new DataInputStream(conn.getInputStream()); while (null != ((str = input.readLine()))) { result += (str + "\n"); } input.close (); KimlikBilgileri[0] = getNodeValue(result,"Ad"); KimlikBilgileri[1] = getNodeValue(result,"Soyad"); KimlikBilgileri[2] = getNodeValue(result,"DogumYil"); } catch (Exception e) { e.printStackTrace(); } return KimlikBilgileri; } } -------------------------------------------------------------------------------- Çağırmak için String[] KimlikArray = {"","",""}; TCKimlik tck = new TCKimlik(); KimlikArray = tck.getTCKimlikBilgisi("kimlik no buraya"); System.out.println(KimlikArray[0]); System.out.println(KimlikArray[1]); System.out.println(KimlikArray[2]);
__________________
bir silahım olsaydı...
![]() hiç bir farklılık ayrımcılığa neden olamaz. Hürriyet Hürriyettir. |
|
|
|
![]() |
| Seçenekler | |
| Stil | |
|
|