0

Error with connection Error Domain=NSURLErrorDomain Code=-1002 "unsupported 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=unsupported URL, NSUnderlyingError=0x6a3f450 "unsupported URL"}

I am getting this error when i am hitting the server.

Its directly calling the didfailwithError. -(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error{

NSLog(@"Error with connection %@",error);

}

May i know when this error call!

I create soapenvelope and call soap request with method name. and encoded the url and send to the dot.net webserver

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");
    }

And the Request time is GET

Unable to hit the server. Please any one advice me with this issue.

@thanks in advance

kiran
  • 4,285
  • 7
  • 53
  • 98

1 Answers1

0

The problem is that you are encoding the full URL:

NSString *urlString = @"http://systemName:8090/businessservice.svc";
NSString *encodeUrl = (__bridge_transfer NSString *)
CFURLCreateStringByAddingPercentEscapes(NULL, ...

while you should only encode the last URI portion (the one containing arguments etc.).

In your case you do not actually need encoding your URL because there is no such part as:

@"?param=1&url=newsite.com&title=Post title";

Just pass urlString to URWithString:

NSString *urlString = @"http://systemName:8090/businessservice.svc";
NSURL *url = [NSURL URLWithString:urlString];    
sergio
  • 68,819
  • 11
  • 102
  • 123
  • Thanks for replay! i try without encoding i got same error. (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error{ NSLog(@"Error with connection %@",error); } – kiran Jul 30 '12 at 15:25
  • 1
    Error with connection Error Domain=kCFErrorDomainCFNetwork Code=303 "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error 303.)" UserInfo=0x6a37870 {NSErrorFailingURLKey=http://systemName:8090/businessservice.svc, NSErrorFailingURLStringKey=http://systemName:8090/businessservice.svc} – kiran Jul 30 '12 at 15:39
  • as you can see, this is a completely different kind of error. This seems to be related to a bug in NSURLMutableRequest: http://stackoverflow.com/questions/3469061/nsurlrequest-cannot-handle-http-body-when-method-is-not-post – sergio Jul 30 '12 at 16:38
  • for this error is that i am missing any forHTTPHeaderField need to send! – kiran Jul 31 '12 at 07:47