The error code I'm receiving:
Error Domain=ASIHTTPRequestErrorDomain Code=1 "A connection failure occurred" UserInfo=0x6993280 {NSUnderlyingError=0x6d520c0 "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error 306.)"
I do not have option but ASIHTTPRequest. I have already developed the app and cannot use the any alternatives.
Currently we are using iOS version 5.1.1
I have developed the app one year back with the same code for iOS 3 and it was working properly. Now same code is failed to work. I suspect this happens with the latest iOS versions.
This code works well without proxy settings but not with proxy settings.
_method = [NSStringstringWithFormat:@"http://%@%@", _settings.ServerLocation, _settings.WebServicePath];
NSLog(_method);
NSString *soapMessage = [NSStringstringWithFormat:@"%@%@%@",
@"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"
"<soap:Body>\n",
parameters,
@"</soap:Body>\n"
"</soap:Envelope>\n"];
//NSLog(@"soapMessage : %@",soapMessage);
NSURL *url = [NSURLURLWithString:_method];
ASIHTTPRequest *request = [ASIHTTPRequestrequestWithURL:url];
if(_settings.IsProxy)
{
[request setProxyHost:_settings.HostIP];
[request setProxyPort:(NSInteger)_settings.Port];
}
constchar *utfString = [soapMessage UTF8String];
NSMutableData *req = [NSDatadataWithBytes:utfString length:strlen(utfString)];
[request addRequestHeader:@"Content-Type"value:@"text/xml; charset=utf-8"];
[request addRequestHeader:@"Content-Length"value:[NSStringstringWithFormat:@"%d", [soapMessage length]]];
[request addRequestHeader:@"SOAPAction"value:action];
if(_settings.IsProxy)
{
[request addRequestHeader:@"Host"value:_settings.HostIP];
}
[request setPostLength:[soapMessage length]];
[request setRequestMethod:@"POST"];
[request setPostBody:req];
[request setTimeOutSeconds:5];
[request setNumberOfTimesToRetryOnTimeout:1];
if(_settings.IsProxy)
{
if([_settings.Usernamelength] > 0)
{
[request setProxyUsername:_settings.Username];
}
if([_settings.Passwordlength] > 0)
{
[request setProxyPassword:_settings.Password];
}
}
//[request setValidatesSecureCertificate:NO];
[request setDelegate:self];
[request startAsynchronous];