Web service เช็ค บัตรประชาชน

กรุณารอสักครู่


ชื่อชุดข้อมูล

รายละเอียด

หน่วยงาน

แหล่งข้อมูล

ข้อมูลเพิ่มเติม


วันที่สร้าง

ขอบเขตเชิงภูมิศาสตร์

กลุ่มชุดข้อมูล

ป้ายกำกับ

ชื่อผู้ติดต่อ

อีเมลผู้ติดต่อ

ระดับในการเข้าถึงข้อมูล

ความถี่ในการปรับปรุง

High Value Dataset

สัญญาอนุญาต

วันที่ปรับปรุงข้อมูลล่าสุด

ข้อมูลการใช้งาน


URL

Method

Service Type

Request Body


คำอธิบายชุดข้อมูล (Request Parameters)

รายการข้อมูลData Typeรายละเอียดหมายเหตุ

ข้อมูลตอบกลับ


ตัวอย่างข้อมูลตอบกลับ
คำอธิบายชุดข้อมูล (Response Parameters)
รายการข้อมูลData Typeรายละเอียดหมายเหตุ

การเขียนโปรแกรมเรียกเว็บเซอร์วิสของกรมสรรพากรเพื่อตรวจสอบหมายเลขประจำตัวประชาชน

Web service เช็ค บัตรประชาชน

หลายโปรแกรมอาจต้องการมีส่วนในการตรวจสอบความถูกต้องของหมายเลขประจำตัวประชาชน ซึ่งทางกรมสรรพากรก็ให้บริการเว็บเซอร์วิสนี้ เนื่องจากเว็บเซอร์วิสของกรมสรรพกรให้บริการโดยใช้ SSL เพื่อช่วยทำให้มีความปลอดภัยมากยิ่งขึ้น ดังนั้นต้องเข้าโดย “HTTPS” แทนที่จะเป็น “HTTP” ปกติ

ข้างล่างนี้โค้ดที่ใช้ในการเรียกใช้เว็บเซอร์วิสและโอเปอเรชันดังกล่าว และใช้โปรแกรม XTrustProvider.java ที่ SSL Trust Provider for Java เพื่อใช้ในการเรียกเว็บเซอร์วิสที่เข้าถึงโดย HTTPS

package callsoapws;

import javax.xml.transform.TransformerFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.Source;
import javax.xml.soap.MessageFactory;
import javax.xml.transform.OutputKeys;
import javax.xml.soap.SOAPConnection;
import javax.xml.soap.SOAPConnectionFactory;
import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPBodyElement;
import javax.xml.soap.SOAPFactory;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.MimeHeaders;
import com.sun.net.ssl.internal.ssl.*;
import java.security.Security; 

/**
 * @author Kanda Runapongsa Saikaew and Pongsakorn Poosankam
 * Computer Engineering Department
 * Khon Kaen University
 * 
 */
public class CheckPinRDWS {
    public void msgEnvelope(String[] args) throws Exception {
               
        SOAPConnectionFactory soapConnectionFactory =
                SOAPConnectionFactory.newInstance();
        SOAPConnection connection =
                soapConnectionFactory.createConnection();
        MessageFactory messageFactory =
                MessageFactory.newInstance();
        
        // Create a message
        SOAPMessage message =
                messageFactory.createMessage();
        
        // Get the SOAP header and body from the message
        // and remove the header
        SOAPHeader header = message.getSOAPHeader();
        SOAPBody body = message.getSOAPBody();
        header.detachNode();
        
        // Create a SOAP factory
        // Create a UDDI v2 checkPin body element
        SOAPFactory soapFactory =
                SOAPFactory.newInstance();
        SOAPBodyElement checkPin =
                body.addBodyElement(soapFactory.createName("ServicePIN",
"ns", "https://rdws.rd.go.th/ServiceRD/CheckTINPINService"));
        
        SOAPElement username =
                checkPin.addChildElement(
                soapFactory.createName("username","ns",
"https://rdws.rd.go.th/ServiceRD/CheckTINPINService"));
        username.addTextNode("anonymous");
        
        SOAPElement password =
                checkPin.addChildElement(
                soapFactory.createName("password","ns",
"https://rdws.rd.go.th/ServiceRD/CheckTINPINService"));
        password.addTextNode("anonymous");
        
        SOAPElement pin =
                checkPin.addChildElement(
                soapFactory.createName("PIN","ns",
"https://rdws.rd.go.th/ServiceRD/CheckTINPINService"));
        pin.addTextNode("xxx TEST PIN NUMBER xxx");
        
        MimeHeaders hd = message.getMimeHeaders();
        hd.addHeader("SOAPAction", 
"https://rdws.rd.go.th/ServiceRD/CheckTINPINService/ServicePIN");
        
        message.saveChanges();
        System.out.println("REQUEST:");
        //Display Request Message
        displayMessage(message);
        
        System.out.println("\n\n");
        //add code below for trust x.509 ceritficate
            XTrustProvider.install(); 
        SOAPConnection conn = 
SOAPConnectionFactory.newInstance().createConnection();
        SOAPMessage response = conn.call(message, 
"https://rdws.rd.go.th/ServiceRD/CheckTINPINService.asmx");
        
        System.out.println("RESPONSE:");
        //Display Response Message
        displayMessage(response);
    }
    
    public void displayMessage(SOAPMessage message) throws Exception {
        TransformerFactory tFact = TransformerFactory.newInstance();
        Transformer transformer = tFact.newTransformer();
        Source src = message.getSOAPPart().getContent();
        StreamResult result = new StreamResult( System.out );
        transformer.setOutputProperty(OutputKeys.ENCODING, "tis-620");
        transformer.transform(src, result);
    }
    public static void main(String[] args) throws Exception {
        CheckPinRDWS clientApp = new CheckPinRDWS();
        clientApp.msgEnvelope(args);
    }
}

ผลลัพธ์ีที่ได้เมื่อหมายเลขบัตรประจำตัวประชาชนถูกต้อง

ผลลัพธที่ได้เมื่อหมายเลขบัตรประจำตัวประชาชนไม่ถูกต้อง

Get latest news from Blognone Follow @twitterapi