In iOS 9, I'm using NSURLSession and for one specific URL, it's generating the following error:
Error Domain=NSPOSIXErrorDomain Code=89 "Operation canceled".
Configuring ATS diagnostic, using nscurl --ats-diagnostics for current url returns a nil error.
Anyone else seen this kind?
Update:
now give response:
"curl --head soap.alfabank.kz:30444/soa/rate?wsdl"
HTTP/1.1 405 Method Not Allowed Content-Type: application/soap+xml;
charset=UTF-8 Content-Length: 286
Server: Jetty(8.1.14.v20131031)
Strict-Transport-Security: max-age=157680000
X-FRAME-OPTIONS: DENY
Some code:
let url = "https://soap.alfabank.kz:30444/soa/rate?wsdl"
let soapMessage = "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><GetRates xmlns=\"http://soa.rate.alfabank.kz/\"><RateListRq reqid=\"6f56631b-01d0-4886-917b-1c5565743627\" systemcode=\"VSTest\"><list_type xmlns=\"\">short</list_type><period xmlns=\"\"><fromDate>2016-09-07</fromDate><toDate>2016-09-07</toDate></period></RateListRq></GetRates></s:Body></s:Envelope>"
let request = NSMutableURLRequest(URL: NSURL(string:url)!)
let msgLength = soapMessage.characters.count
request.addValue("text/xml; charset=utf-8", forHTTPHeaderField: "Content-Type")
request.addValue(String(msgLength), forHTTPHeaderField: "Content-Length")
request.HTTPMethod = "POST"
request.HTTPBody = soapMessage.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)
let configuration = NSURLSessionConfiguration.defaultSessionConfiguration()
let session = NSURLSession(configuration: configuration, delegate: self, delegateQueue: nil)
let task = session.dataTaskWithRequest(request){
data, response, error in
if error != nil {
print(error)
}
else {
//some
}
}
task.resume()
Remove the space after the semicolon in the Content-Type header. Apparently NSURLSession is very picky about validating that header (because a curl request succeeded without making that change).
And remove the Content-Length header as previously noted.