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:impl", value: "urn:parameters.v3.ewr.ws.ssa.gov")
xml.addAttribute("xmlns:ns0", value: "urn:skeleton.v3.ewr.ws.ssa.gov")
xml.updateChildContent("soap:Header", value: "")
xml.updateChildContent("soap:Body|ns0:GetWageFileStatusRequest|impl:confirmationNumber", value: "string")
// 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://ws.ssa.gov/ewrwsv3/services/WageFileServices"var soapAction: String? = "getWageFileStatus"// 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!.getBody(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 wfid: String? = responseXml.getChildContent("*:Body|*:GetWageFileStatusResponse|*:wfid")
var receiptYear: Int = responseXml.getChildIntValue("*:Body|*:GetWageFileStatusResponse|*:receiptYear").intValue
var version: String? = responseXml.getChildContent("*:Body|*:GetWageFileStatusResponse|*:version")
var receiptDate: String? = responseXml.getChildContent("*:Body|*:GetWageFileStatusResponse|*:receiptDate")
var statusCode: String? = responseXml.getChildContent("*:Body|*:GetWageFileStatusResponse|*:statusCode")
var statusDescription: String? = responseXml.getChildContent("*:Body|*:GetWageFileStatusResponse|*:statusDescription")
var statusDate: String? = responseXml.getChildContent("*:Body|*:GetWageFileStatusResponse|*:statusDate")
var filingMethod: String? = responseXml.getChildContent("*:Body|*:GetWageFileStatusResponse|*:filingMethod")
var w3Count: Int = responseXml.getChildIntValue("*:Body|*:GetWageFileStatusResponse|*:w3Count").intValue
var originalFilename: String? = responseXml.getChildContent("*:Body|*:GetWageFileStatusResponse|*:originalFilename")
var returnCode: String? = responseXml.getChildContent("*:Body|*:GetWageFileStatusResponse|*:response|*:returnCode")
var transactionTimestamp: String? = responseXml.getChildContent("*:Body|*:GetWageFileStatusResponse|*:response|*:transactionTimestamp")
var errorInfo: String? = responseXml.getChildContent("*:Body|*:GetWageFileStatusResponse|*:response|*:errorInfo")
var errorDateInfo: String? = responseXml.getChildContent("*:Body|*:GetWageFileStatusResponse|*:response|*:errorDateInfo")
var deprecationDate: String? = responseXml.getChildContent("*:Body|*:GetWageFileStatusResponse|*:response|*:deprecationDate")
var sunsetDate: String? = responseXml.getChildContent("*:Body|*:GetWageFileStatusResponse|*:response|*:sunsetDate")
}