It's not always possible or desirable to find a one-to-one correspondence
between object/method-oriented APIs and resource-oriented APIs. One of the
hardest things for me in adopting Restlet has been to stop thinking in
terms of method calls and to start thinking in terms of resources and
representations.
That said, your example is about updating the address of an existing
patient. Assuming there's more to a patient than just an address, you have
to decide whether you want to model the address as part of the patient
resource or as a separate resource. There are trade-offs here (explored
more fully in books like *RESTful Web Services Cookbook* by Subbu
Allamaraju) but let's assume the latter. In that case, you would identify
the resource corresponding to the address of a patient with a given
patientId with a URI, something like this:
/patient/{patientId}/address/
and you would want to support at least GET and PUT on this resource. The
interface in Restlet might look like this:
public interface PatientAddressResource {
@Get public Address getAddress();
@Put public Address putAddress(Address address);
}
where Address is a value type that can be converted to the representation
types you want to support.
A server-side implementation of this interface might look like this:
public class PatientAddressServerResource
extends ServerResource implements PatientAddressResource {
@Override public Address getAddress() {
String patientId = getQueryValue("patientId");
return doGetAddress(patientId);
}
@Override public Address putAddress(Address newAddress) {
String patientId = getQueryValue("patientId");
doReplaceAddress(patientId, newAddress);
return doGetAddress(patientId);
}
private Address doGetAddress(String patientId) {
// Locate the address information for the patient with the given id:
return ...;
}
private void doReplaceAddress(String patientId, Address newAddress) {
// Replace existing address with newAddress
...
}
}
Does that help?
--tim
On Mon, Apr 23, 2012 at 3:55 PM, Dalia Sobhy <[email protected]>wrote:
> This is an example of a method:
>
> updatePatientAddressByID(String ID, String address)
>
> Any Help
>
> --
> View this message in context:
> http://restlet-discuss.1400322.n2.nabble.com/How-to-make-a-URI-which-passes-two-parameters-using-restlet-Restlet-2-1-tp7493109p7493109.html
> Sent from the Restlet Discuss mailing list archive at Nabble.com.
>
> ------------------------------------------------------
>
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2951260
>
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2951274