func chilkatTest() {
let xml = CkoXml()
xml.Tag = "soap:Envelope"
xml.AddAttribute("xmlns:soap", value: "http://www.w3.org/2003/05/soap-envelope")
xml.AddAttribute("xmlns:spr", value: "http://www.springcm.com/atlas/webservices/v201308/scm/")
xml.UpdateChildContent("soap:Header", value: "")
xml.UpdateChildContent("soap:Body|spr:ContactFind|spr:token", value: "string")
xml.UpdateChildContent("soap:Body|spr:ContactFind|spr:SearchText", value: "string")
xml.UpdateChildContent("soap:Body|spr:ContactFind|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/ContactFind"// 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|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:Id")
var Name: String? = responseXml.GetChildContent("*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:Name")
var ObjectType: String? = responseXml.GetChildContent("*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:ObjectType")
var v_Email: String? = responseXml.GetChildContent("*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:Email")
var FirstName: String? = responseXml.GetChildContent("*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:FirstName")
var LastName: String? = responseXml.GetChildContent("*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:LastName")
var PhoneNumber: String? = responseXml.GetChildContent("*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:PhoneNumber")
var FaxNumber: String? = responseXml.GetChildContent("*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:FaxNumber")
var Company: String? = responseXml.GetChildContent("*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:Company")
var Department: String? = responseXml.GetChildContent("*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:Department")
var Title: String? = responseXml.GetChildContent("*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:Title")
var Address1: String? = responseXml.GetChildContent("*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:Address1")
var Address2: String? = responseXml.GetChildContent("*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:Address2")
var Address3: String? = responseXml.GetChildContent("*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:Address3")
var City: String? = responseXml.GetChildContent("*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:City")
var ProvinceState: String? = responseXml.GetChildContent("*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:ProvinceState")
var PostalCode: String? = responseXml.GetChildContent("*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:PostalCode")
var Country: String? = responseXml.GetChildContent("*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:Country")
}