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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:35:48+00:00 2026-06-14T17:35:48+00:00

So, I’ve ran over and over the web in search for anything about sending

  • 0

So, I’ve ran over and over the web in search for anything about sending XML with POST from iPhone app – no luck so far, none!

I’m using in my app KissXML, which I find very easy and useful when it comes to getting XML out of response – but quite opposite when sending XML to server…
Here is my method for connecting and receiving XML. I tried to put NSString containing simply my XML request into body of POST request, but it doesn’t work as planned.

-(void)prepareTransaction{
    NSLog(@"FXSecondVC: preparing transaction...");
    NSString *login = [[NSUserDefaults standardUserDefaults] stringForKey:@"kUsername"];
    NSString *password = [[NSUserDefaults standardUserDefaults] stringForKey:@"kPassword"];
    NSString *host = [[NSUserDefaults standardUserDefaults] stringForKey:@"kURLServer"];

    NSURL *url = [[NSURL alloc] initWithString:host];

    AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url];
    [httpClient setAuthorizationHeaderWithUsername:login password:password];
    [httpClient registerHTTPOperationClass:[AFKissXMLRequestOperation class]];

    NSString *xmlString = @"<RootEl xmlns=\"http://some.url/goes/here\">"
                                "<Element1>12678967.543233</Element1>"
                                "<Element2>"
                                    "<string xmlns=\"bla.bla/url\">"
                                            "String content</string>"
                                    "<string xmlns=\"bla.bla/url\">"
                                            "String content</string>"
                                "</Element2>"
                                "<Element3>true</Element3>"
                                "<Element4>String content</Element4>"
                                "<Element5>1999-05-31T11:20:00</Element5>"
                                "<Element6>true</Element6>"
                            "</RootEl>";

    NSMutableURLRequest *request = [httpClient requestWithMethod:@"POST" path:kServerRequestURL parameters:nil];
    [request setHTTPBody:[xmlString dataUsingEncoding:NSUTF8StringEncoding]];

    AFKissXMLRequestOperation *operation = [AFKissXMLRequestOperation XMLDocumentRequestOperationWithRequest:request success:^(NSURLRequest *req, NSHTTPURLResponse *resp, DDXMLDocument *XMLDocument){
        NSLog(@"[SUCCESS]: XMLDocument: %@", XMLDocument);
    }failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, DDXMLDocument *XMLDocument) {
        NSLog(@"error parsing: %@", [error localizedDescription]);
    }];
    [operation start];
}

This is what I’m getting in response:

2012-11-21 19:40:09.884 FXApp[19662:707] FXSecondVC: preparing transaction...
2012-11-21 19:40:10.011 FXApp[19662:707] error parsing: Expected status code in (200-299), got 400

Am I missing something here? I want to use KissXML, because it the simplest way (at least known to me) to use already prepared XML document in successful response, but if solution requires changing framework – don’t hesitate. The priority is to get it working.
I hit dead end – this is driving me crazy, especially it is really urgent matter.

  • 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-14T17:35:49+00:00Added an answer on June 14, 2026 at 5:35 pm

    Mystery solved:
    it appears that all I had to do was to set Content-Type for xml – which I wasn’t doing. Solution found here
    Here you go:

    [request setValue:@"application/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Seemingly simple, but I cannot find anything relevant on the web. What is the
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the
I am currently running into a problem where an element is coming back from
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.