Xcode send a HTTPS Soap request

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?

Answers


For normal xml service using GET method https request was working for me. Try this delegate methods that I have used.`


- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace {
return [protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust];
}

- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
NSArray *trustedHosts=[NSArray arrayWithObject:@"yourdomian.com"];
if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust])
    if ([trustedHosts containsObject:challenge.protectionSpace.host])
        [challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];

[challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge];
}

Need Your Help

Sql Splitting Function

sql string function split

I have a string like that "10*cat*123456;12*rat*789;15*horse*365" i want to split it to be like that "cat, rat, horse" I have made this Function

When and why is the onupgradeneeded method called in indexedDB?

javascript html5 indexeddb

I'm using IndexedDB for a test project. Here is some example code:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.