Created
August 22, 2019 16:35
-
-
Save braulio94/f11f15c3baa0c4f93eafcdc9b0ae84c2 to your computer and use it in GitHub Desktop.
This are the many ways to request
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const SOAPRequest = `<?xml version="1.0" encoding="UTF-8"?> | |
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" | |
xmlns:xsd="http://www.w3.org/2001/XMLSchema" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" | |
xmlns:base_services="http://wsdl.cybozu.co.jp/base/2008"> | |
<SOAP-ENV:Header> | |
<Action SOAP-ENV:mustUnderstand="1" xmlns="http://schemas.xmlsoap.org/ws/2003/03/addressing">{{.Action}}</Action> | |
<Security xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility" | |
SOAP-ENV:mustUnderstand="1" | |
xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext"> | |
<UsernameToken wsu:Id="id"><Username>{{.Username}}</Username><Password>{{.Password}}</Password></UsernameToken> | |
</Security> | |
<Timestamp SOAP-ENV:mustUnderstand="1" Id="id" | |
xmlns="http://schemas.xmlsoap.org/ws/2002/07/utility"> | |
<Created>2037-08-12T14:45:00Z</Created> | |
<Expires>2037-08-12T14:45:00Z</Expires> | |
</Timestamp> | |
<Locale>jp</Locale> | |
</SOAP-ENV:Header><SOAP-ENV:Body> | |
<{{.Action}}> | |
{{.Parameters}} | |
</{{.Action}}> | |
</SOAP-ENV:Body></SOAP-ENV:Envelope> | |
` | |
type APIParameters struct { | |
Username, Password, Action, Parameters string | |
} | |
func main() { | |
var api_parameters = APIParameters{"ID", "パスワード", "ScheduleGetEvents", `<parameters start="2014-01-01T08:00:00" end="2014-01-30T20:00:00" ></parameters>`} | |
var url = "https://ほげほげほげ/grn.cgi/cbpapi/schedule/api?" | |
//リクエストbodyのテンプレートを適用 | |
t := template.Must(template.New("SOAPRequest").Parse(SOAPRequest)) | |
body := bytes.NewBufferString("") | |
err := t.Execute(body, api_parameters) | |
if err != nil { | |
log.Panicf("template.Execute: %#v", err) | |
} | |
// Postする | |
response, err := http.Post(url, "text/xml; charset=utf-8", body) | |
if err != nil { | |
log.Panicf("http.Post: %#v", err) | |
} | |
//レスポンスを読み込んで表示 | |
b, err := ioutil.ReadAll(response.Body) | |
response.Body.Close() | |
if err != nil { | |
log.Panicf("ioutil.ReadAll: %#v", err) | |
} | |
fmt.Printf(string(b)) | |
return | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" | |
xmlns:xsd="http://www.w3.org/2001/XMLSchema" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" | |
xmlns:base_services="http://wsdl.cybozu.co.jp/base/2008"> | |
<SOAP-ENV:Header> | |
<Action SOAP-ENV:mustUnderstand="1" | |
xmlns="http://schemas.xmlsoap.org/ws/2003/03/addressing"> | |
ScheduleGetEvents | |
</Action> | |
<Security xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility" | |
SOAP-ENV:mustUnderstand="1" | |
xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext"> | |
<UsernameToken wsu:Id="id"> | |
<Username>xxxxxxxxxx</Username> | |
<Password>xxxxxxxxxx</Password> | |
</UsernameToken> | |
</Security> | |
<Timestamp SOAP-ENV:mustUnderstand="1" Id="id" | |
xmlns="http://schemas.xmlsoap.org/ws/2002/07/utility"> | |
<Created>2037-08-12T14:45:00Z</Created> | |
<Expires>2037-08-12T14:45:00Z</Expires> | |
</Timestamp> | |
<Locale>jp</Locale> | |
</SOAP-ENV:Header> | |
<SOAP-ENV:Body> | |
<ScheduleGetEvents> | |
<parameters start="2014-01-01T08:00:00" end="2014-01-30T20:00:00" > | |
</parameters> | |
</ScheduleGetEvents> | |
</SOAP-ENV:Body> | |
</SOAP-ENV:Envelope> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8" ?> | |
<soap:Envelope> | |
<soap:Header> | |
<vendor>Cybozu</vendor> | |
<product>Garoon</product> | |
<product_type>1</product_type> | |
<version>3.7.2</version> | |
<apiversion>1.3.0</apiversion> | |
</soap:Header> | |
<soap:Body> | |
<schedule:ScheduleGetEventsResponse> | |
<returns> | |
<schedule_event id="3451422" event_type="repeat" public_type="public" plan="打合せ" ・・・・ | |
・ | |
・ | |
・ | |
・ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment