tags:

views:

48

answers:

1

How can code be resource?

I will give you an example: I want to create a hotel web site. But also i want to show my customers, which come from abroad, at which time they can come to my city. So i deal with an airplane web site. This site will give me his resources using REST. (resources mean representation of resources). For example his URI will be like that http://example.com/plane/flight%5Fnumber http://example.com/plane/flight%5Fnumber/date

My users will give me a date and i will say them at which flight number they can come. I'll give him a list of flight number then he can fly. OK. there is something i haven't solve yet. if i would know the plane number, i found date. But i dont know which flight number can he travel. So i need to search all the plane and all the flight number to find the same date. But how can i do it? How can i write my query?

another question is I have a function. That function gives me the flight number if i give the date [ int get_Flight_Number(12/11/2009) ].
I just want that clients can see parameters and name of function. And I want him to use my function. How this will be happen?

+1  A: 

Without the details of the media types returned by the service it is difficult to answer your question. Does the site return a search form? Does the site return a collection of flights for a set of dates?

The general flow of any http based RESTful client inquiry should go something like this:

  1. Do a HTTP GET on the root url of the API.
  2. Parse the response based on the media type specified in the http header "Content-Type".
  3. Does the response contain the answer to my question?
  4. If yes then extract the information and do what you want with it.
  5. If no, then does the response contain a link to another resource that may have the answer to my question.
  6. If yes then do a HTTP GET or POST on that link based on what the media type definition tells you to do. Goto step 3.
  7. If no then stop looking and tell the user you cannot find an answer.
Darrel Miller
I got it all except number 2. If i don't parse that means i can't reach the resources? And what happens if i write wrong media type?
Iguramu
The server will put the media type in the Http content type header. If you as a client does not understand how to deal with that media type then you are pretty much stuck.
Darrel Miller