Paste "tc kimlik no doğrular" Text
  1. public static bool TcKimlikNoDogrula(long tcKimlikNo, string ad, string soyad, int dogumYili)
  2. {
  3. var r = (HttpWebRequest)WebRequest.Create("https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx");
  4. r.Method = "POST";
  5. r.ContentType = "text/xml";
  6. r.Host = "tckimlik.nvi.gov.tr";
  7. r.Headers.Add("SOAPAction", "http://tckimlik.nvi.gov.tr/WS/TCKimlikNoDogrula");
  8. r.Timeout = 30000;
  9.  
  10. var doc = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
  11. doc += "<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/\">";
  12. doc += "<soap:Body>";
  13. doc += "<TCKimlikNoDogrula xmlns=\"http://tckimlik.nvi.gov.tr/WS\">";
  14. doc += $"<TCKimlikNo>{tcKimlikNo}</TCKimlikNo>";
  15. doc += $"<Ad>{ad}</Ad>";
  16. doc += $"<Soyad>{soyad}</Soyad>";
  17. doc += $"<DogumYili>{dogumYili}</DogumYili>";
  18. doc += "</TCKimlikNoDogrula>";
  19. doc += "</soap:Body>";
  20. doc += "</soap:Envelope>";
  21.  
  22. byte[] PostData = Encoding.UTF8.GetBytes(doc);
  23. r.ContentLength = PostData.Length;
  24. using (Stream requestStream = r.GetRequestStream())
  25. {
  26. requestStream.Write(PostData, 0, PostData.Length);
  27. }
  28. XmlDocument rDoc;
  29. HttpWebResponse response = (HttpWebResponse)r.GetResponse();
  30. using (var reader = new StreamReader(response.GetResponseStream()))
  31. {
  32. var res = reader.ReadToEnd();
  33. rDoc = new XmlDocument();
  34. rDoc.LoadXml(res);
  35. }
  36.  
  37. var rs = rDoc.ChildNodes[1].FirstChild.FirstChild.FirstChild.FirstChild.Value;
  38. return Convert.ToBoolean(rs);
  39. }
Submitted and never expires    Report abuse
2KB Characters: 1935 Hits: 122