- create database with
rake db:create
- migrate to correct DB schema with
rake db:migrate
- import some test data with
rake db:fixtures:load
- start the server with
script/server
- set up a proxy forwarding, e.g. using Apache, from om.example.com:80 to localhost:3000. If you don't know how to do this, replace
om.example.com
below withlocalhost:3000
Then you can try a few things:
curl -i http://om.example.com/orders -H 'Accept: application/xml'
curl -i http://om.example.com/orders/1054584184 -H 'Accept: application/xml'
curl -i -X POST -H 'Accept: application/xml' -H 'Content-type: application/xml' http://om.example.com/orders -d '<order xmlns="http://example.com/schemas/ordermanagement">
<customer>
<name>Prof. Bienlein</name>
<link>http://crm.example.com/customers/0815</link>
</customer>
<billingAddress>Bruxelles, Belgium</billingAddress>
<items>
<item>
<product>http://prod.example.com/products/352</product>
<productDescription>Laptop X65</productDescription>
<quantity>2</quantity>
<price currency="EUR">799.0</price>
</item>
</items>
</order>'
curl -i -X PUT -H 'Accept: application/xml' -H 'Content-type: application/xml' http://om.example.com/orders/1054583387 -d '<order xmlns="http://example.com/schemas/ordermanagement">
<customer>
<name>Prof. Bienlein</name>
<link>http://crm.example.com/customers/0815</link>
</customer>
<billingAddress>Bruxelles, Belgium</billingAddress>
<shippingAddress>Paris, France</shippingAddress>
<items>
<item>
<product>http://prod.example.com/products/352</product>
<productDescription>Laptop X65</productDescription>
<quantity>2</quantity>
<price currency="EUR">799.0</price>
</item>
</items>
</order>'
curl -i -X POST http://om.example.com/orders/1054583387 -H 'Accept: application/xml' -H 'Content-type: application/xml' -d '<cancellation xmlns="http://example.com/schemas/ordermanagement">
<date>2009-01-22</date>
<reason>Changed my mind</reason>
</cancellation> '
curl -i -X POST -H 'Accept: application/xml' -H 'Content-type: application/xml' http://om.example.com/cancellations -d '<cancellation xmlns="http://example.com/schemas/ordermanagement">
<date>2009-01-22</date>
<reason>Totally lost interest</reason>
<orders>
<order>http://om.example.com/orders/953125641</order>
<order>http://om.example.com/orders/1054583384</order>
</orders>
</cancellation>
You can also try to connect to the server from your browser and admire the awesome HTML being returned.
See http://rest-http.info for more information. -- Stefan Tilkov, [email protected]