Version: v0.0.0-...-0c25df4 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2018 License: Apache-2.0 Imports: 7 Imported by: 0


Module/Method DATA:GET_DES (data.get_des)

Module "Get Destination" (DATA:GET_DES) is a service method to retreive list of Destination (arrive location) information from KAI Train (RailTicket) Web Service [1].

The following are the sections available in this guide.

Use Case

Let’s retrieve destination/arrive location from KAI Train Web Service Endpoint.

Get Destination Diagram


go get
  • A Text Editor or an IDE
KAI Agent requirements
  • KAI Train (RailTicket) Agent Credential Account (RQID)
  • KAI Train (RailTicket) Web Service Access (IP Whitelist) ( Production Server, Demo Server)


If you want to skip the basics, you can download the git repo and directly move to the "Build and Running" section by skipping "Implementation" section.

Example structure

Go is a complete programming language that supports custom project structures. Let's use the following package structure for this example.

   └── main.go
  • Create the above directories in your local machine and also create empty main.go and files.
Developing the application

Let's make a simple application for getting list of destination (arrive location) information using kaiwsdkv2 package.

Main code for "data.get_des" (main.go)
package main

import (


const (
	kaiServer = "" // Production Server
	// kaiServer = ""		// Demo Server

func makeHTTPClient() *http.Client {
	// Access via proxy if needed
	proxyURL, _ := url.Parse("http://proxy-ip-address:proxy-port")
	//proxyURL, _ := url.Parse("http://proxy-user:proxy-password@proxy-ip-address:proxy-port")

	// Initiate transport with proxy and skip TLS
	tr := &http.Transport{
		Proxy:           http.ProxyURL(proxyURL),
		TLSClientConfig: &tls.Config{InsecureSkipVerify: true},

	// Initiate transport without proxy and skip TLS
	// tr := &http.Transport{
	//	TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
	// }

	// Using Transport
	httpClient := &http.Client{Transport: tr}

	return httpClient

func main() {

	// init http client
	httpClient := makeHTTPClient()

	// Initiate NewKAIHttpClient version 2
	kaiClient, err := kaiwsdkv2.NewKAIHttpClient(httpClient, kaiServer, kaiRQID)
	if err != nil {

	// call KAI web service method

func callGetDestination(kaiClient *kaiwsdkv2.KAIHttpClient) {

	// params := make(map[string]string)
	vRS, err := kaiClient.CallGetDestination(false)

	if err != nil {

	// sample how to Access Response
	// fmt.Println(vRS.ErrCode)
	// fmt.Println(vRS.ErrMsg)
	// fmt.Println(vRS.Return[0].DestCode)
	// fmt.Println(vRS.Return[0].DestName)

	// if you want to retreive KAI Origin Response
	// fmt.Println(string(kaiClient.KAIRealResponseBody))

	json, _ := json.Marshal(vRS)

Bash code for building and running the example application (
echo "Clean..."
rm ./data.get_des
echo "Build..."
go build -o data.get_des main.go 
echo "Build Done..."
echo "Run..."
./data.get_des > data.get_des-rs.json
echo "Done."

Build and Running

You can build and running by execute the "" bash files.

   $ sh 

After the application is running, you will get the json response in data.get_des-rs.json files.

Sample Response

Sample KAI Response:
    // Get KAI Response Raw from KAIHttpClient Struct 
    "err_code": 0,
    "destination": [
Sample Internal Response:
    // Get Internal Response Raw from KAIHttpClient Struct 
    "errCode": "0",
    "errMsg": null,
    "return": [
            "DestCode": "AK",
            "DestName": "ANGKE"
            "DestCode": "YK",
            "DestName": "YOGYAKARTA"


The Go Gopher

There is no documentation for this package.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL