README ¶
Scenario: <...>
<...>
In this example you will learn about <...> with Go (using sjwsdk111 package).
The following are the sections available in this guide.
What you’ll build
<...>
Prerequisites
go get github.com/ClientSDK/sriwijaya-ws-client-go/sjwsdk111
- A Text Editor or an IDE
Sriwijaya Air Agent requirements
- Sriwijaya Air Agent Credential Account (Agent Application)
- Sriwijaya Air Web Service Access (IP Whitelist) ( Production, Development )
- WSDL File ( Production, Development )
Implementation
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.
sjwsv111
├── by-scenario
│ └── Domestic
│ └── 1.1.<...>
│ ├── README.md
│ ├── build_and_run.sh
│ └── main.go
└── wsdl
└── wsp-wsdl.eticketv111.wsdl
-
Create the above directories in your local machine and also create empty
main.go
andbuild_and_run.sh
files. -
Download Sriwijaya Air Web Service WSDL and saved to
wsp-wsdl.eticketv111.wsdl
.
Developing the application
Let's make a simple application for retrieving route information using sjwsdk111
package.
package main
import (
"encoding/xml"
"fmt"
"net/http"
"net/url"
"github.com/ClientSDK/sriwijaya-ws-client-go/sjwsdk111"
)
func main() {
// 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 http client with transport
httpClient := &http.Client{Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)}}
// Initiate NewSoapSJClient version 111
sjClient, err := sjwsdk111.NewSoapSJClient(httpClient, "../../wsdl/wsp-wsdl.eticketv111.wsdl", "file")
if err != nil {
fmt.Println(err)
}
call<...>(sjClient)
}
// call<...> is a function to call <...> method
func call<...>(s *sjwsdk111.SoapSJClient) {
params := []byte(
`
<Username xsi:type="xsd:string">SRIWIJAWA_AGENT_USERNAME</Username>
<Password xsi:type="xsd:string">SRIWIJAWA_AGENT_PASSWORD</Password>
<...>
`)
wsResp, errC := s.Call<...>(params, false)
if errC != nil {
fmt.Println(errC)
return
}
// Access response variable
// fmt.Println()
// fmt.Println("ReturnData-<...>:")
// fmt.Printf("%#v\n", wsResp.Return)
// Marshal response variable to XML
myXML, _ := xml.MarshalIndent(wsResp, " ", " ")
fmt.Println(string(myXML))
}
echo "Clean..."
rm ./<...>
echo "Build..."
go build -o <...> main.go
echo "Build Done."
echo "Run..."
./<...> > <...>-Result.xml
echo "Done."
Build and Running
You can build and running by execute the "build_and_run.sh" bash files.
$ sh build_and_run.sh
After the application is running, you will get the xml response in <...>-Result.xml
files.
Sample Response
<...>
Documentation ¶
There is no documentation for this package.