检查下面的答案
xmlbody = (NSString *)CFURLCreateStringByAddingPercentEscapes(
NULL,
(CFStringRef)xmlbody,
NULL,
(CFStringRef)@"!*'\"();:@&=+$,/?%#[]% ",
kCFStringEncodingUTF8 );
NSMutableString *entirexmlbody=[[NSMutableString alloc]init ];
[entirexmlbody appendString:@"xml="];
[entirexmlbody appendString:xmlbody];
NSLog(@"posting XML Body after encoding--%@\n",xmlbody);
NSData *postData = [entirexmlbody dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d",[postData length]];
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:[NSURL URLWithString:posturl]];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
NSURLConnection *conn=[[[NSURLConnection alloc] initWithRequest:request delegate:self] autorelease];