Ruby web service.

Discussion in 'Ruby' started by bradphelan, Mar 30, 2010.

  1. bradphelan

    bradphelan Guest

    Hi all,

    I'm looking to make a web service probably with Sinatra. I'm a little
    confused about the best way to structure parameter passing for POST /
    PUT. I'd like to use XML formats for the data. I've found the
    'active_record' Hash.to_xml and Hash.from_xml and I'm happy to settle
    for that choice of encoding.

    However I see two ways of doing constructing the POST/PUT body.

    (a) Posting the XML parameter as the body of the post using an XML
    content type
    (b) Using URL encoding and setting a parameter

    xml=<foo>...</foo>

    Can I choose either approach or do I need to support both?

    Regard Brad

    --
    http://xtargets.heroku.com
     
    bradphelan, Mar 30, 2010
    #1
    1. Advertising

  2. bradphelan wrote:
    > However I see two ways of doing constructing the POST/PUT body.
    >
    > (a) Posting the XML parameter as the body of the post using an XML
    > content type
    > (b) Using URL encoding and setting a parameter
    >
    > xml=<foo>...</foo>
    >
    > Can I choose either approach or do I need to support both?


    It's your app and your users, so you get to choose :) But (a) is the
    standard way to handle XML uploads.

    If you want to handle form data, note that Rack/Sinatra/Rails support
    nested form elements, so for example

    a[c]=1&a[d]=2

    will give you params = {"a"=>{"b"=>{"c"=>"1","d"=>"2"}}}
    --
    Posted via http://www.ruby-forum.com/.
     
    Brian Candler, Mar 30, 2010
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. hocho888
    Replies:
    1
    Views:
    661
  2. Michael Averstegge
    Replies:
    0
    Views:
    4,272
    Michael Averstegge
    Jan 10, 2006
  3. Not Me
    Replies:
    1
    Views:
    3,207
    Not Me
    Jun 5, 2007
  4. Isaias Formacio Serna

    Web Service that calls an external Web Service

    Isaias Formacio Serna, Jan 28, 2004, in forum: ASP .Net Security
    Replies:
    5
    Views:
    258
  5. Leo Violette
    Replies:
    0
    Views:
    1,068
    Leo Violette
    Apr 17, 2009
Loading...

Share This Page