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 7970935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:31:11+00:00 2026-06-04T07:31:11+00:00

I use the following hack-job code to perform a series of SOAP requests that

  • 0

I use the following hack-job code to perform a series of SOAP requests that download data from a server for use in the application:

This code is called when the ‘update’ button is pressed:

- (IBAction) update {
    UIAlertView *errorView;

    if([[Reachability reachabilityForInternetConnection] currentReachabilityStatus] == NotReachable) {
        errorView = [[UIAlertView alloc] 
                     initWithTitle: @"Network Error" 
                     message: @"No Network connection availible!" 
                     delegate: self 
                     cancelButtonTitle: @"OK" otherButtonTitles: nil]; 
        [errorView show];
    }
    else
    {
        [appDelegate.categories removeAllObjects];
        [appDelegate.currencies removeAllObjects];
        [appDelegate.projects removeAllObjects];

        HUD = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];
        HUD.labelText = @"Downloading..";

        [self requestCategories];
    }
}

Below is a typical request, I use approximately 6 of them.

// SOAP requests
- (void) requestCategories {
    // Indeterminate mode
    categories = [[NSMutableArray alloc] init];
    xmlBlock = CATEGORY;
    NSString *soapMsg =
    [NSString stringWithFormat:
     @"<?xml version=\"1.0\" encoding=\"utf-8\"?> <soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"> <soap:Body> <Categories xmlns=\"http://tempuri.org/\"> <UID>string</UID> <Username>string</Username> <Password>string</Password> </Categories>      </soap:Body> </soap:Envelope>"
     ];
    //---print it to the Debugger Console for verification---
    NSLog(@"%@", soapMsg);
    NSURL *url = [NSURL URLWithString:
                  @"http://www.$$%$%^^^%$$££.co.uk/%$^£^£^$&£.asmx"];
    NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
    //---set the headers---
    NSString *msgLength = [NSString stringWithFormat:@"%d",
                           [soapMsg length]];
    [req addValue:@"text/xml; charset=utf-8"
forHTTPHeaderField:@"Content-Type"];
    [req addValue:@"http://tempuri.org/Categories"
forHTTPHeaderField:@"SOAPAction"];
    [req addValue:msgLength forHTTPHeaderField:@"Content-Length"];
    //---set the HTTP method and body---
    [req setHTTPMethod:@"POST"];
    [req setHTTPBody: [soapMsg dataUsingEncoding:NSUTF8StringEncoding]];
    //[activityIndicator startAnimating];
    conn = [[NSURLConnection alloc] initWithRequest:req delegate:self];
    if (conn) {
        webData = [NSMutableData data];
    }

}

Below are my delegate methods for NSURLConnection (and a parsing method):

-(void) connection:(NSURLConnection *) connection
didReceiveResponse:(NSURLResponse *) response {
    [webData setLength: 0];
}

-(void) connection:(NSURLConnection *) connection
    didReceiveData:(NSData *) data {
    [webData appendData:data];
}

-(void) connection:(NSURLConnection *) connection
  didFailWithError:(NSError *) error {

}

-(void) connectionDidFinishLoading:(NSURLConnection *) connection {
    NSLog(@"DONE. Received Bytes: %d", [webData length]);
    NSString *theXML = [[NSString alloc]
                        initWithBytes: [webData mutableBytes]
                        length:[webData length]
                        encoding:NSUTF8StringEncoding];
    //---shows the XML---
    NSLog(@"%@", theXML);

    if (xmlBlock == CATEGORY){
        [self parseXML:webData];

        [self requestCurrencies];
    }
    else if (xmlBlock == CURRENCY){
        [self parseXML:webData];

        [self requestNominals];
    }
    else if (xmlBlock == NOMINAL){
        [self parseXML:webData];

        [self requestProjects];
    }
    else if (xmlBlock == PROJECT){
        [self parseXML:webData];

        [self requestRegister];
    }
    else {
        [self parseXML:webData];

        HUD.customView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"37x-Checkmark.png"]];
        HUD.labelText = @"Done!";
        HUD.mode = MBProgressHUDModeCustomView;
        [HUD hide:YES afterDelay:2];
    }

}

- (void) parseXML: (NSMutableData *)localWebData {
    xmlParser = [[NSXMLParser alloc] initWithData: localWebData];
    [xmlParser setDelegate: self];
    [xmlParser setShouldResolveExternalEntities:YES];
    [xmlParser parse];
}

I don’t think you need to see my xml parsing delegate methods (if you do let me know). My question is, is there a better way to implement this functionality in my app? As in perform the requests one after another while displaying some kind of progress indicator to the user?

Thanks,

Jack

  • 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-06-04T07:31:13+00:00Added an answer on June 4, 2026 at 7:31 am

    use NSOperation queue, that is make your class a subclass of NSOperation in which you are sending the request to service, and rename of your method to main. then make the property of this class in parent class and add all the request in operation queue. And for the finishing, use keyobserver for your that property of nsopertion subclass

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

Sidebar

Related Questions

Hello Sir i want send list of data to php server i use following
i would like to use following code to turn off Button back that i
I use following code: Create a retry policy, when error, retry after 1 second,
I just use following code to add an image to my project, var paper
for example i use following command to find a record SELECT `users`.`mail` FROM `users`
I use VS2010, C# to develop Silverlight 4 app, I use following code in
I have an array of objects, and i use following code to get in
I have the following code which I use to set HttpRequest querystring. I want
I have the following function, which I use (admitedly, as a hack, since I
I have the following code: set.seed(47) df <- data.frame(V1 = sample(letters[1:5], size = 10,

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.