POPBill Developers
SDK Reference
Java

Tutorial

Following is an example to implement NTS Crawling job request (RequestJob) API by adding the POPBiLL SDK within Java setting.

1. Add POPBiLL SDK

To add POPBiLL Java SDK, input POPBiLL Java SDK dependency information on “pom.xml” file of Spring project and update the Maven.

<dependency>
    <groupId>kr.co.linkhub</groupId>
    <artifactId>popbill-sdk</artifactId>
    <version>1.64.0</version>
</dependency>

2. POPBiLL SDK Setting

Add NTS Crawling class into Spring Bean. By referring to the code below, edit “servlet-context.xml” file.

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">

    <annotation-driven/>

    <resources mapping="/resources/**" location="/resources/"/>

    <beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <beans:property name="prefix" value="/WEB-INF/views/"/>
        <beans:property name="suffix" value=".jsp"/>
    </beans:bean>

    <context:component-scan base-package="com.popbill.example"/>

    <util:properties id="EXAMPLE_CONFIG">
        <!-- LinkID -->
        <beans:prop key="LinkID">TESTER</beans:prop>
        <!-- SecretKey -->
        <beans:prop key="SecretKey">SwWxqU+0TErBXy/9TVjIPEnI0VTUMMSQZtJf3Ed8q3I=</beans:prop>
        <!-- Stage setting value , true(TEST), false(PRODUCTION) -->
        <beans:prop key="IsTest">true</beans:prop>
        <!-- Whether to recommend use of authentication token IP restriction function or not, -->
        <!-- recommended to use (true) -->
        <beans:prop key="IsIPRestrictOnOff">true</beans:prop>
        <!-- Whether to use POPBiLL API service static IP or not, -->
        <!-- true – use, false- do not use, default(false) -->
        <beans:prop key="UseStaticIP">false</beans:prop>
        <!-- Whether to use local system time or not, -->
        <!-- true – use(default – recommended), false – do not use -->
        <beans:prop key="UseLocalTimeYN">true</beans:prop>
    </util:properties>

    <beans:beans>
        <!-- NTS Crawling Service Implementation Bean registration.  -->
        <beans:bean id="htTaxinvoiceService"
            class="com.popbill.api.htTaxinvoice.HTTaxinvoiceServiceImp">
            <beans:property name="linkID" value="#{EXAMPLE_CONFIG.LinkID}"/>
            <beans:property name="secretKey" value="#{EXAMPLE_CONFIG.SecretKey}"/>
            <beans:property name="test" value="#{EXAMPLE_CONFIG.IsTest}"/>
            <beans:property name="IPRestrictOnOff" value="#{EXAMPLE_CONFIG.IsIPRestrictOnOff}"/>
            <beans:property name="useStaticIP" value="#{EXAMPLE_CONFIG.UseStaticIP}"/>
            <beans:property name="useLocalTimeYN" value="#{EXAMPLE_CONFIG.UseLocalTimeYN}"/>
        </beans:bean>
    </beans:beans>
</beans:beans>

3. Implement RequestJob Function

① To add Service Class Bean object, add @Autowired annotation and registIssue API code.

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.popbill.api.HTTaxinvoiceService;
import com.popbill.api.PopbillException;
import com.popbill.api.hometax.QueryType;


@Controller
public class HTTaxinvoiceExample {

    @Autowired
    private HTTaxinvoiceService htTaxinvoiceService;

    @RequestMapping(value = "requestJob", method = RequestMethod.GET)
    public String requestJob(Model m) {

        // Business registration number of a POPBiLL user
        String corpNum = "1234567890";

        // Type of e-Tax invoice
        // SELL – sales
        // BUY – purchase
        // TRUSTEE - consigned
        QueryType TIType = QueryType.SELL;

        // Date type
        // W – date of preparation
        // I – date of issuance
        // S – date of filing
        String DType = "S";

        // Starting date(format : yyyyMMdd)
        String SDate = "20220101";

        // End date(format : yyyyMMdd)
        String EDate = "20220130";

        try {
            String jobID = htTaxinvoiceService.requestJob(corpNum, TIType,
                    DType, SDate, EDate);
            m.addAttribute("Result", jobID);

        } catch (PopbillException e) {
            // If an exceptional error occurs,
            // check the error code with e.getCode()
            // and check the error message with e.getMessage()
            System.out.println("Error Code : " + e.getCode());
            System.out.println("Error Message : " + e.getMessage());
        }

        return "response";
    }
}

② Add response.jsp file that outputs the code and message of the API calling result.

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>Popbill SDK Response</title>
  </head>

  <body>
    <p>JobID for a request (JobID) : ${Result}</p>
  </body>
</html>

4. Check the Result

If the API calling is being processed successfully, Response code will be returned as “1” and if it fails, an error code(8-digits that starts with “-”) and error message will be returned to POPBiLL Exception. [Error Code]