func chilkatTest() {
let xml = CkoXml()
xml.Tag = "soapenv:Envelope"
xml.AddAttribute("xmlns:soapenv", value: "http://schemas.xmlsoap.org/soap/envelope/")
xml.AddAttribute("xmlns:spr", value: "http://www.springcm.com/atlas/webservices/v201308/scm/")
xml.UpdateChildContent("soapenv:Header", value: "")
xml.UpdateChildContent("soapenv:Body|spr:GroupFind|spr:token", value: "string")
xml.UpdateChildContent("soapenv:Body|spr:GroupFind|spr:name", value: "string")
xml.UpdateChildContent("soapenv:Body|spr:GroupFind|spr:IncludeDeleted", value: "true")
// In a SOAP HTTP request, including the XML declaration (<?xml version="1.0" encoding="UTF-8"?>) in the XML body is generally not required.
xml.EmitXmlDecl = falsevar soapRequestBody: String? = xml.GetXml()
var endpoint: String? = "https://soapna11.springcm.com/atlas/webservices/v201308/springcmservice.asmx"var soapAction: String? = "http://www.springcm.com/atlas/webservices/v201308/scm/GroupFind"// For SOAP requests, the standard Content-Type is usually set to "text/xml" or "application/soap+xml"var contentType: String? = "text/xml"let http = CkoHttp()
http.ClearHeaders()
http.SetRequestHeader("Content-Type", value: contentType)
http.SetRequestHeader("SOAPAction", value: soapAction)
var resp: CkoHttpResponse? = http.PostXml(endpoint, xmlDoc: soapRequestBody, charset: "utf-8")
if http.LastMethodSuccess == false {
print("\(http.LastErrorText)")
print("Failed to send SOAP request.")
return
}
// Get the XML response body.let responseXml = CkoXml()
resp!.GetBodyXml(responseXml)
var statusCode: Int = resp!.StatusCode.intValue
print("response status code: \(statusCode)")
resp = nil// If the status code does not indicate succcess, then show the response XML,
// which probably contains error information.if statusCode != 200 {
print("\(responseXml.GetXml())")
return
}
print("\(responseXml.GetXml())")
// Parse the successful SOAP response XML.// This is a sample of the response XML, but the namespace prefixes will be different.
// We can parse the result using "*" for the namespace prefixes (see below).var Id: String? = responseXml.GetChildContent("*:Body|*:GroupFindResponse|*:GroupFindResult|*:SCMGroup|*:Id")
var Name: String? = responseXml.GetChildContent("*:Body|*:GroupFindResponse|*:GroupFindResult|*:SCMGroup|*:Name")
var ObjectType: String? = responseXml.GetChildContent("*:Body|*:GroupFindResponse|*:GroupFindResult|*:SCMGroup|*:ObjectType")
var IsPrivate: String? = responseXml.GetChildContent("*:Body|*:GroupFindResponse|*:GroupFindResult|*:SCMGroup|*:IsPrivate")
Id = responseXml.GetChildContent("*:Body|*:GroupFindResponse|*:GroupFindResult|*:SCMGroup|*:Members|*:SCMContactInfo|*:Id")
Name = responseXml.GetChildContent("*:Body|*:GroupFindResponse|*:GroupFindResult|*:SCMGroup|*:Members|*:SCMContactInfo|*:Name")
ObjectType = responseXml.GetChildContent("*:Body|*:GroupFindResponse|*:GroupFindResult|*:SCMGroup|*:Members|*:SCMContactInfo|*:ObjectType")
var v_Email: String? = responseXml.GetChildContent("*:Body|*:GroupFindResponse|*:GroupFindResult|*:SCMGroup|*:Members|*:SCMContactInfo|*:Email")
var FirstName: String? = responseXml.GetChildContent("*:Body|*:GroupFindResponse|*:GroupFindResult|*:SCMGroup|*:Members|*:SCMContactInfo|*:FirstName")
var LastName: String? = responseXml.GetChildContent("*:Body|*:GroupFindResponse|*:GroupFindResult|*:SCMGroup|*:Members|*:SCMContactInfo|*:LastName")
var PhoneNumber: String? = responseXml.GetChildContent("*:Body|*:GroupFindResponse|*:GroupFindResult|*:SCMGroup|*:Members|*:SCMContactInfo|*:PhoneNumber")
var FaxNumber: String? = responseXml.GetChildContent("*:Body|*:GroupFindResponse|*:GroupFindResult|*:SCMGroup|*:Members|*:SCMContactInfo|*:FaxNumber")
var Company: String? = responseXml.GetChildContent("*:Body|*:GroupFindResponse|*:GroupFindResult|*:SCMGroup|*:Members|*:SCMContactInfo|*:Company")
var Department: String? = responseXml.GetChildContent("*:Body|*:GroupFindResponse|*:GroupFindResult|*:SCMGroup|*:Members|*:SCMContactInfo|*:Department")
var Title: String? = responseXml.GetChildContent("*:Body|*:GroupFindResponse|*:GroupFindResult|*:SCMGroup|*:Members|*:SCMContactInfo|*:Title")
var Address1: String? = responseXml.GetChildContent("*:Body|*:GroupFindResponse|*:GroupFindResult|*:SCMGroup|*:Members|*:SCMContactInfo|*:Address1")
var Address2: String? = responseXml.GetChildContent("*:Body|*:GroupFindResponse|*:GroupFindResult|*:SCMGroup|*:Members|*:SCMContactInfo|*:Address2")
var Address3: String? = responseXml.GetChildContent("*:Body|*:GroupFindResponse|*:GroupFindResult|*:SCMGroup|*:Members|*:SCMContactInfo|*:Address3")
var City: String? = responseXml.GetChildContent("*:Body|*:GroupFindResponse|*:GroupFindResult|*:SCMGroup|*:Members|*:SCMContactInfo|*:City")
var ProvinceState: String? = responseXml.GetChildContent("*:Body|*:GroupFindResponse|*:GroupFindResult|*:SCMGroup|*:Members|*:SCMContactInfo|*:ProvinceState")
var PostalCode: String? = responseXml.GetChildContent("*:Body|*:GroupFindResponse|*:GroupFindResult|*:SCMGroup|*:Members|*:SCMContactInfo|*:PostalCode")
var Country: String? = responseXml.GetChildContent("*:Body|*:GroupFindResponse|*:GroupFindResult|*:SCMGroup|*:Members|*:SCMContactInfo|*:Country")
var GroupType: String? = responseXml.GetChildContent("*:Body|*:GroupFindResponse|*:GroupFindResult|*:SCMGroup|*:GroupType")
}