Home Ask Login Register

Developers Planet

Your answer is one click away!

Nasir Khan February 2016

Geting NSURLConnection error while calling HTTPS Soap service

I am trying to get data from Soap request but getting my app crashed with this error:

2016-02-08 11:12:11.524 Example[567:128898] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9843)
Response: nil
fatal error: unexpectedly found nil while unwrapping an Optional value

I have enabled Security settings in plist and calling other services successfully.

Note: The service is on HTTPS, am i getting this error because of this? is this required any certificate?

i am calling soap service for the first time, please also guide me on how to add email parameter in service: (https://[IP]:9897/JLIPolicyinfo.asmx?op=GetEmail_Poldetail)

here is my code that i get from here: (IOS Swift Call Web Service using SOAP)

        let is_SoapMessage: String = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:cgs=\"http://www.cgsapi.com/\"><soapenv:Header/><soapenv:Body><cgs:GetSystemStatus/></soapenv:Body></soapenv:Envelope>"

        let is_URL: String = ""

        let lobj_Request = NSMutableURLRequest(URL: NSURL(string: is_URL)!)
        let session = NSURLSession.sharedSession()
        let err: NSError?

        lobj_Request.HTTPMethod = "POST"
        lobj_Request.HTTPBody = is_SoapMessage.dataUsingEncoding(NSUTF8StringEncoding)
        lobj_Request.addValue("", forHTTPHeaderField: "Host")
        lobj_Request.addValue("text/xml; charset=utf-8", forHTTPHeaderField: "Content-Type")
        lobj_Request.addValue(String((is_SoapMessage.characters.count)), forHTTPHeaderField: "Content-Length")
        //lobj_Request.addValue("223", forHTTPHeaderField: "Content-Length")


Vizllx February 2016

You might have a self signed certificate that can be also a problem .

Solution:- It will work if you renew your server's ssl certificate to use SHA2 and enabling TLS v1.2.

Possibly a solution:- You have to add this in your info.plist file, so that it can allow non-secure connection:-


Or even you can add like this:-

enter image description here


Add this in your info.plist for specific exception.


Post Status

Asked in February 2016
Viewed 1,789 times
Voted 9
Answered 1 times


Leave an answer

Quote of the day: live life