连接错误 Error Domain=NSURLErrorDomain Code=-1002“不支持的 URL”UserInfo=0x6a3f420 {NSErrorFailingURLStringKey=http%3A%2F%2F10.101.189.65%3A8090%2Fbusinessservice.svc, NSErrorFailingURLKey=http%3A%2F%2F10.101.189 .65%3A8090%2Fbusinessservice.svc,NSLocalizedDescription=不支持的 URL,NSUnderlyingError=0x6a3f450“不支持的 URL”}
我在访问服务器时收到此错误。
它直接调用了didfailwithError。-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error{
NSLog(@"Error with connection %@",error);
}
我可以知道这个错误何时调用!
我创建soapenvelope 并使用方法名称调用soap 请求。并对 url 进行编码并发送到 dot.net 网络服务器
NSString *soapMessage = [self getTestSoapEnvelope];
NSLog(@"soapMessage %@",soapMessage);
NSString *urlString = @"http://systemName:8090/businessservice.svc";
NSString *encodeUrl = (__bridge_transfer NSString *)
CFURLCreateStringByAddingPercentEscapes(NULL,
(__bridge_retained CFStringRef)urlString,
NULL,
(CFStringRef)@"!*'();:@&=+$,/?%#[]",
kCFStringEncodingUTF8);
NSURL *url = [NSURL URLWithString:encodeUrl];
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
[theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue: @"ManageCase" forHTTPHeaderField:@"SOAPAction"];
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"GET"];
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if( theConnection )
{
webData = [NSMutableData data];
}
else
{
NSLog(@"theConnection is NULL");
}
请求时间是 GET
无法访问服务器。请任何人就这个问题给我建议。
@提前致谢