Using NSUrl for xml http get

Discussion in 'Mac Programming' started by ltt, Sep 22, 2009.

  1. ltt macrumors newbie

    Joined:
    Sep 22, 2009
    #1
    Hi,

    I am a new Objective-C Developer with mild C and Delphi experience. I am finding it hard to adapt to Objective-C. I can see the benefits, but I am still getting my head around the syntax.

    I have what I consider a really simple app to write but I can not for the life of me work out how to do it! Can anyone help?
    I believe I need to use NSUrl somehow.

    The requirement;

    I need to send an XML request to a specific url and do a http get, then write the results to a file. An example request and result is shown below.

    An example request would be:

    <request method="[method name]">
    <!-- method arguments -->
    </request>


    I expect a successful response like;

    <response status="ok">
    <!-- return value(s) here] -->
    </response>


    I need to write the returned values to a file.

    Unsucessful response like;

    <response status="fail">
    <error> ... </error>
    </response>


    I need to display the error message to NSLog.

    I can use curl to get the response using the following command;
    curl -u insert_token_here:X https://mydomain.com/xmlrequest -d '[xml body here]

    Thanks in advance. Comments would be great to I can learn from your response.

    Regards,
    Luke.
     
  2. ltt thread starter macrumors newbie

    Joined:
    Sep 22, 2009
    #2
    general tips?

    I know its a very specific request, but if no one has an example function, is there any way someone could give me some steps/pointers?

    How can I get NSURL to send a request and accept data?

    What functions/properties of NSURL do I need to research?

    Regards,
    Luke
     
  3. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #3
    What have you tried?

    http://whathaveyoutried.com/

    Have you done any research at all on NSURL? Have you read the programming guide? The class reference?

    http://developer.apple.com/mac/libr...eptual/URLLoadingSystem/URLLoadingSystem.html

    http://developer.apple.com/mac/libr.../Classes/NSURL_Class/Reference/Reference.html

    There are several links to sample code in the NSURL class reference? Have you looked at those?

    If you're more experienced with C, and your goal is to solve a problem rather than learn about NSURL, then maybe you should use libcurl to get your data.

    http://developer.apple.com/mac/library/DOCUMENTATION/Darwin/Reference/ManPages/man3/libcurl.3.html
     

Share This Page