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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:14:39+00:00 2026-06-09T06:14:39+00:00

in my Iphone app i use AFNetworking to POST some data to a webservice

  • 0

in my Iphone app i use AFNetworking to POST some data to a webservice and get some data back…

Here is my example, i always get “false” back as response, what i am doing wrong?

NSURL *baseURL = [NSURL URLWithString:@"http://myPath/Iphone/method"];


    AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:baseURL];
    [httpClient defaultValueForHeader:@"Accept"];

    NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
                            [udid copy], @"uuid",
                            nil];


    NSMutableURLRequest *request = [httpClient requestWithMethod:@"POST" path:@"http://myPath/Iphone/method" parameters:params];


    AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];


    [httpClient registerHTTPOperationClass:[AFXMLRequestOperation class]];


    [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
        response = [operation responseString];
        NSLog(@"response: %@",response);
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"error: %@", [operation error]);
    }];


    [operation start];

EDIT: the method i call in the Url returns a string (no the string is not false)


  [HttpPost]
        public bool checkIphone(string uuid)
        {
           IDictionary<string,object> check  = Request.Properties;

           uuid = check["uuid"].ToString();

           //do anything with the uuid

           if (1<0)
           {
               return true;
           }
           else
           {
               return false;
           }

        }

this method i am calling with my iphone and normaly it should return xml or?

  • 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-09T06:14:40+00:00Added an answer on June 9, 2026 at 6:14 am

    You are using a complicated way of building the operation, but it will work.
    But it should work, the thing you are missing is assign the XMLparser.
    In the documentation of AFXMLRequestOperation is stated.

     NSMutableURLRequest *request = [httpClient requestWithMethod:@"POST" path:@"http://myPath/Iphone/method" parameters:params];
    
    AFXMLRequestOperation *operation = [[AFXMLRequestOperation alloc] initWithRequest:request];
    operation.responseXMLParser = xmlParser; //Here you should assign an instance of NSXMLParser to handle you XML parsing.
    
    [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
        response = [operation responseString];
        NSLog(@"response: %@",response);
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"error: %@", [operation error]);
    }];
    

    Also there is not need to make the NSURLRequest via the AFHTTPClient, you can easily create one you self or use the AFHTTPClient to do the creation of the AFHTTPRequestOperation for you.


    To use the AFHTTPClient to just return whatever the server returns :

    // Don't include the method here
    NSURL *baseURL = [NSURL URLWithString:@"http://myPath/Iphone/"];
    
    AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:baseURL];
    [httpClient defaultValueForHeader:@"Accept"];
    
    NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
                            [udid copy], @"uuid",
                            nil];
    
    [httpClient postPath:@"method" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        // reponseObject will hold the data returned by the server.
    
    }failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"Error retrieving data: %@", error);
    }];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am making an iphone app that get data from web ,i use HPPLE
I want to use geoJSON-formatted Data in my iPhone app. THere is a JSON
I am trying to use some external Framework in my iPhone app. I did
Programming an iPhone App, I need to use Google Maps api to get directions
In my iPhone app, I use a sqlite table to hold my data. While
I have an iPhone app that must use external cloud db to sync data
I am planning to develop an iphone app which makes use of image filters
My iPhone app can't seem to use soft keyboards that doesn't use the US-like
I use an uiwebview into my iphone app. When i display a javascript alert
I'd like to use an STL set in my iPhone app (which is written

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.