Can we make XML-RPC calls from iPhone?

Discussion in 'iOS Programming' started by shweta13, Nov 10, 2008.

  1. shweta13 macrumors member

    Aug 7, 2008
    Hi all,

    Can we make XML-RPC protocols to any server on net?
    From the results that I got from my search, XML-RPC calls can be done using
    AppleScript,but not on iPhone.

    Anyone has any ideas why.....

  2. SqueegyX macrumors regular

    Mar 24, 2008
    I'm not sure if a library exists to help with this or not, but you can just POST some XML to an address right? What support do you need besides basic HTTP messages?
  3. shweta13 thread starter macrumors member

    Aug 7, 2008
    How exactly should I POST XML it in the form of HTTPBody?

    The following is my problem:-

    When I handle the delegates of NSURLConnection, I get response as "Invalid request"
    Can anyone help?
  4. shweta13 thread starter macrumors member

    Aug 7, 2008
    Thnks for ur help

    Unfortunately, NSXMLNode and NSXMLDocument are not supported on iPhone device :(
  5. david.david macrumors newbie

    Nov 12, 2008
    it works well in my iPhone simulator..

    means it works in simulator and not work with actual device ?

    if NSXMLNode and NSXMLDocument are not working, then initialize the NSString with desired format like 3rd post and convert NSString to NSData

    I am using
  6. SqueegyX macrumors regular

    Mar 24, 2008
    Here is a snippet from my app. It doesnt send XML, but it does send content in the post body.

      // Create the request
      NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
      [request setURL:[NSURL URLWithString:@""]];
      // Set request body and HTTP method
      NSString *usernameString = [LatestChattyAppDelegate urlEscape:[[NSUserDefaults standardUserDefaults] stringForKey:@"username_preference"]];
      NSString *passwordString = [LatestChattyAppDelegate urlEscape:[[NSUserDefaults standardUserDefaults] stringForKey:@"password_preference"]];
      NSString *bodyString     = [LatestChattyAppDelegate urlEscape:postContent.text];
      NSString *parentId       = [NSString stringWithFormat:@"%d", parentPost.postId];
      if ([parentId isEqualToString:@"0"]) parentId = @"";
      NSString *postBody = [NSString stringWithFormat:@"body=%@&iuser=%@&ipass=%@&parent=%@&group=%d", bodyString, usernameString, passwordString, parentId, storyId];
      [request setHTTPBody:[postBody dataUsingEncoding: NSASCIIStringEncoding]];
      [request setHTTPMethod:@"POST"];
      // Send the request
      NSHTTPURLResponse *response;
      NSString *responseBody = [[NSString alloc] initWithData:[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:nil]

Share This Page