-1
저는 HTTPS 요청을 받았습니다.IOS에서 HTTPS로 sendasynchronousrequest를 처리합니까?
sendAsynchronousRequest
은 NSURLConnection
입니다. 그때마다 나는 다음과 같은 오류 여기
NSURLConnection/CFURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9806)
CFNetwork SSLHandshake failed (-9806)
을 얻고있다 NSURLConnection
의 sendAsynchronousRequest
을 사용하고 언제
NSURL *url=[NSURL URLWithString:strService];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
[theRequest setHTTPMethod:@"POST"];
NSString *msgLength = [NSString stringWithFormat:@"%d", [strSoap length]];
[theRequest addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];;
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setValue:@"My User-Agent" forHTTPHeaderField:@"User-Agent"];
[theRequest addValue:strSoapAction forHTTPHeaderField:@"SOAPAction"];
[theRequest setHTTPBody: [strSoap dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:TRUE]];
[NSURLConnection sendAsynchronousRequest:theRequest queue:[NSOperationQueue currentQueue] completionHandler:^(NSURLResponse *resp, NSData *responseData, NSError *error) {
NSString *strResponse=[[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding] ;
strResponse=[self clearHtmlTags:strResponse];
NSMutableDictionary *dictResponse=[NSMutableDictionary dictionaryWithDictionary:[NSDictionary dictionaryWithXMLString:strResponse]];
block(dictResponse);
}];
이를 내 코드입니다
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
을 사용하지 않으 sendAsynchronousRequest를 사용하여 NSURLConnection의 대리자 메서드를 호출하는 다른 방법은 무엇입니까?
이 경우 위임을 설정해야합니까? –
이것은 대리자 메서드이므로 호출되지 않습니다. –
왜 호출되지 않습니까? .h 파일에'NSURLConnectionDataDelegate' 프로토콜을 추가해야합니다. –