내가 작업 한 프로젝트 용으로 만든 웹 서비스에서 데이터에 액세스하려고합니다. 가 나는 URL을 생성하고 문제가NSURLConnection sendSynchronousRequest가 응답하는 데 너무 많은 시간이 걸림
NSURL *ServiceURL = [NSURL URLWithString:[[NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"webservices" ofType:@"plist"]] valueForKey:@"EndPointURL"]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:ServiceURL];
[request addValue:@"text/xml" forHTTPHeaderField:@"Content-Type"];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:[sRequest dataUsingEncoding:NSUTF8StringEncoding]];
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
NSTimeInterval start = [NSDate timeIntervalSinceReferenceDate];
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:NULL error:NULL];
NSTimeInterval duration = [NSDate timeIntervalSinceReferenceDate] - start;
NSLog(@"Response Time%.4f",duration);
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
return responseData;
를 요청하고 그 다음
NSMutableString *sRequest = [[NSMutableString alloc] init];
[sRequest appendString:@"<soapenv:Envelope xmlns:soapenv=\"http:blah blah blah /messages\">"];
[sRequest appendString:@"<soapenv:Header/>"];
[sRequest appendString:@"<soapenv:Body>"];
[sRequest appendString:@"<mes:processActionRequest>"];
[sRequest appendString:@"<ProcessAction>"];
[sRequest appendString:@"</mes:processActionRequest>"];
[sRequest appendString:@"</soapenv:Body>"];
[sRequest appendString:@"</soapenv:Envelope>"];
요청을 생성하는 문자열을 만드는 오전, 내가 로그 인쇄 응답 시간은 항상 위 20초로 온다 어쩐지. 하지만 eviware/SoapUI 프로젝트를 사용하여 동일한 링크를 클릭하면 초 이내에 실행됩니다. 또한 동일한 링크가 블랙 베리 프로젝트에 사용되는 경우 원활하게 작동합니다. 나는 어디가 잘못 가고 있는지 알지 못한다. 왜 아이폰에서만 응답이 느린 지요. 도와주세요. 명확하지 않은 소리가 들리면 알려주십시오. 나는 더 많이 설명하려고 노력할 것이다.
비동기 API를 사용해 보았습니다. 그것은 동일한 지연 응답을 보여준다. – jason