I have to edit a code in Objective C, to call a secure https webservice with login, password and cookie Container.
The code actually :
NSString *plistInfosServeurPath = [[NSBundle mainBundle] pathForResource:@"InfosServeur" ofType:@"plist"];
NSDictionary *infosServeurDictionary = [NSDictionary dictionaryWithContentsOfFile:plistInfosServeurPath];
NSString *urlServeur = [infosServeurDictionary objectForKey:@"serveur_url"];
/* ADDED BY ME */
/* ------- */
NSURLCredential *newcredential = [NSURLCredential credentialWithUser:@"plop" password:@"Plop" persistence:NSURLCredentialPersistenceNone];
NSURLProtectionSpace *space = [[NSURLProtectionSpace alloc] initWithHost:@"https://plop.com"
port:443
protocol:@"https"
realm:nil
authenticationMethod:NSURLAuthenticationMethodHTTPBasic];
[[NSURLCredentialStorage sharedCredentialStorage] setCredential:newcredential
forProtectionSpace:space];
/* ------- */
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[[NSURL alloc] initWithString:[NSString stringWithFormat:@"%@/plop.svc/plop/%@", urlServeur, _gare.code]]];
[request setHTTPMethod:@"GET"];
[NSURLConnection sendAsynchronousRequest:request
queue:[NSOperationQueue mainQueue]
completionHandler:^(NSURLResponse *response, NSData *result, NSError *error){
if (result)
{
NSArray *trains = [[CJSONDeserializer deserializer] deserializeAsArray:result error:&error];
}
if (erro) {
NSLog(@"connexion NOK");
NSLog(@"ERROR : %@", error);
}
}
];
The code work for a webservice in http, but now with the https, i tried to add credentials, without succes, and don't find how add cookie Container.