Yesterday the HTTPs certificate was installed on my server, where my webservice is running. Before the HTTPs certificate was installed, my self-made iPhone app sent a SOAP request to the webservice. The webservice succesfully answered by returning an XML message.
This is the code which I use for sending the soap request to the webservice:
NSString *soapMsg = [NSString stringWithFormat:@""
""
""
""
"%@"
"%@"
""
""
"", parameter1, parameter2];
NSURL *url = [NSURL URLWithString:
@"http://domain.com/webservice-name.svc"];
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d",
[soapMsg length]];
[req addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[req addValue:@"http://tempuri.org/webservice-name/method-name" forHTTPHeaderField:@"SOAPAction"];
[req addValue:msgLength forHTTPHeaderField:@"Content-Length"];
[req setHTTPMethod:@"POST"];
[req setHTTPBody:[soapMsg dataUsingEncoding:NSUTF8StringEncoding]];
NSURLResponse *response = nil;
NSError *error = nil;
NSData *resultsData = [NSURLConnection sendSynchronousRequest:req returningResponse:&response error:&error];
if(error){
NSLog(@"Error sending soap request: %@", error);
return FALSE;
}
NSLog(@"%@", soapMsg);
NSLog(@"%@", [[NSString alloc] initWithData:resultsData encoding:NSUTF8StringEncoding]);
Now if I change the URL to “https://domain.com/webservice-name.svc”, the webservice doesn’t repsonse at all.
What do I have to change to send a succesfull SOAP request to a HTTPS secured webservice?
For normal xml service using GET method https request was working for me. Try this delegate methods that I have used.`