Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3424566
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:29:23+00:00 2026-05-18T06:29:23+00:00

I’ve got a class called BackendConnector which uses a NSURLConnection to call a SoapWebservice

  • 0

I’ve got a class called BackendConnector which uses a NSURLConnection to call a SoapWebservice that is https. I found a lot of posts and tried to implement the delegate Methods regarding Authentication but they won’t get called and after 6 hours in google I don’t get what I’ve done wrong. Can someone please give me a hint why those 2 Delegate Methods won’t get called? I set a breakpoint in each one, started my app with XCode in the simulator but still get the error and the Breakpoints don’t get hit.

BackendConnector.m

#import "BackendConnector.h"

@implementation BackendConnector

@synthesize dataPoint, chartDataPoints;

- (NSMutableArray *)GetWebserviceData
{
    NSMutableData *myMutableData;
    chartDataPoints = [[NSMutableArray alloc] init];

    [self createWebserviceAndGetResponse: &myMutableData];

    if (myMutableData != NULL)
    {
        NSString *theXml = [[NSString alloc]initWithBytes:[myMutableData mutableBytes] length:[myMutableData length] encoding:NSUTF8StringEncoding];

        NSLog(@"doc = %@", theXml);

        arrayCount = 0;
        [self parseResponse: myMutableData];
    }
    else 
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" 
                                                        message:@"There is no Data returned from Webservice!"
                                                       delegate:nil 
                                              cancelButtonTitle:@"OK" 
                                              otherButtonTitles: nil];
        [alert show];
        [alert release];
}

    return NULL;
    //return chartDataPoints;
}

- (void) createWebserviceAndGetResponse: (NSMutableData **) myMutableData_p  
{
    NSMutableString *sRequest = [[NSMutableString alloc]init];

    [sRequest appendString:@"<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ser=\"http://service.ReportWebservice.xyz.com/\">"];
    [sRequest appendString:@"<soapenv:Header/>"];
    [sRequest appendString:@"<soapenv:Body>"];
    [sRequest appendString:@"<ser:getReport>"];
    [sRequest appendString:@"<arg0>User/arg0>"];
    [sRequest appendString:@"<arg1>password</arg1>"];
    [sRequest appendString:@"</ser:getReport>"];
    [sRequest appendString:@"</soapenv:Body>"];
    [sRequest appendString:@"</soapenv:Envelope>"];

    NSURL *myWebserverURL = [NSURL URLWithString:@"https://xyz.com/services/report"];

    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:myWebserverURL]; 
    NSLog(@"request: %@", request);

    [request addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
    [request addValue:@"" forHTTPHeaderField:@"SOAPAction"];

    NSString *contentLengthStr = [NSString stringWithFormat:@"%d", [sRequest length]];

    [request addValue:contentLengthStr forHTTPHeaderField:@"Content-Length"];
    [request setHTTPMethod:@"POST"];
    [request setHTTPBody:[sRequest dataUsingEncoding:NSUTF8StringEncoding]];

    NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request delegate:self];

    if(conn)
    {
        *myMutableData_p=[[NSMutableData data] retain];
    }

    [NSURLConnection connectionWithRequest:request delegate:self];

    NSError *WSerror;
    NSURLResponse *WSresponse;

    *myMutableData_p = [NSURLConnection sendSynchronousRequest:request returningResponse:&WSresponse error:&WSerror];
}

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

- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
    [challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];
    [challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge];
}
@end

The Error is:

Error Domain=NSURLErrorDomain Code=-1202 "The certificate for this server is invalid. You might be connecting to a server that is pretending to be “xyz.com” which could put your confidential information at risk." UserInfo=0x8161600 {NSErrorFailingURLStringKey=https://xyz.com/services/report, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, NSErrorFailingURLKey=https://xyz.com/services/report, NSLocalizedDescription=The certificate for this server is invalid. You might be connecting to a server that is pretending to be “xyz.com” which could put your confidential information at risk., NSUnderlyingError=0x8134cb0 "The certificate for this server is invalid. You might be connecting to a server that is pretending to be “xyz.com” which could put your confidential information at risk.", NSURLErrorFailingURLPeerTrustErrorKey=<SecTrustRef: 0x6d86020>}

Thank you very much

twickl

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T06:29:23+00:00Added an answer on May 18, 2026 at 6:29 am

    I won’t be able to answer why those methods aren’t getting fired, I have the exact same methods and they get called when using HTTPS, but I’m wondering why you aren’t implementing the rest of the NSURLConnection delegate methods? Such as -didReceiveResponse etc.

    I also think that your connection actually initiates at

    NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request delegate:self];
    

    You shouldn’t have [NSURLConnection connectionWithRequest:request delegate:self]; and lastly you are starting and setting another synchronous NSURLConnection and storing it into what should be NSMutableData.

    Try using only your first NSUrlConnection *conn (and be sure to release it properly later) and then setup your data in the -didReceiveResponse delegate method, and you can actually set or append the data in the -didReceiveData delegate method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
i got an object with contents of html markup in it, for example: string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a bunch of posts stored in text files formatted in yaml/textile (from
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a text area in my form which accepts all possible characters from
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a JSP page retrieving data and when single or double quotes are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.