initWithContentsOfURL seems to have issues with "long" URLs

Posted by samsam on Stack Overflow See other posts from Stack Overflow or by samsam
Published on 2010-04-14T09:50:27Z Indexed on 2010/04/14 9:53 UTC
Read the original article Hit count: 181

Filed under:
|

Hi there I'm facing a rather strange Issue when trying to load data from an XML-Webservice. The webservice allows me to pass separated identifiers within the URL-Request. It is therefore possible for the URL to become rather long (>240 characters). If I open said URL in firefox the response arrives as planned, if I execute the following code xmlData remains empty.

NSString *baseUrl = [[NSString alloc] initWithString:[[[[kSearchDateTimeRequestTV stringByReplacingOccurrencesOfString:@"{LANG}" withString:appLanguageCode] 
                                              stringByReplacingOccurrencesOfString:@"{IDENTIFIERS}" withString:myIdentifiers]
                                             stringByReplacingOccurrencesOfString:@"{STARTTICKS}" withString:[NSString stringWithFormat:@"%@", [[startTime getTicks] descriptionWithLocale:nil]]]
                                            stringByReplacingOccurrencesOfString:@"{ENDTICKS}" withString:[NSString stringWithFormat:@"%@", [[endTime getTicks] descriptionWithLocale:nil]]]];

NSLog(baseUrl); //looks good, if openend in browser, returnvalue is ok

urlRequest = [NSURL URLWithString:baseUrl];


NSString *xmlData = [NSString stringWithContentsOfURL:urlRequest encoding:NSUTF8StringEncoding error:&err]; //err is nil, therefore i guess everything must be ok... :(

NSLog(xmlData); //nothing... 

is there any sort of URL-Length restriction, does the same problem happened to anyone of you as well? whats a good workaround?

thanks for your help

sam

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c