Enabled the rest service, and could not access my custom stuff. My custom stuff isn't really RESTFUL, as it is a backport of SOAP endpoints from another project, but surely, I thought, there's a way to get to them!
The trick was in the URL. If you have a custom method named yourservice.yourmethod, you have to POST to example.com/services/rest/service_yourservice/yourmethod (with appropriate POST parameters). The addition of the "service_" is completely unintuitive (this was with services 2.0 released not a week ago). Something tells me that the struct layout from the services module changed.
A quick fix would be @ line 53, you have
$controller = $this->resolveController($resource, $method, $path);
Simply check the return value, and try appending 'service_' before it if it's null and try again. This should allow back compatibility.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | Screenshot.png | 97.24 KB | karthi.srinivasan |
Comments
Comment #1
gestahl commentedWhoops. That line 53 is in RESTServer.inc.
Comment #2
Hugo Wetterberg commentedThere is no need for backwards compatibility in the naming of the resourcified service-methods as they've never been named according to any other scheme, thus there's nothing to be compatible with. And falling back to guessing what the caller wanted to execute is not something I'll do.
The fault lies in that this is undocumented behaviour, which is my fault as I'm the one who wrote the stuff. The reasoning is that I wanted to prevent naming collisions between old rpc-style service implementations and new resource implementations. And as the rpc-style services are secondary in the context of the REST server, and as of services 3.x in the context of services, I chose to prefix the old services.
It's definitely something that has to go into the services handbook.
Comment #3
Hugo Wetterberg commentedComment #4
gestahl commented>>> The reasoning is that I wanted to prevent naming collisions between old rpc-style service implementations and new resource implementations.
Ah OK that makes sense. You aren't chaining your RESTful node calls (for example) to the built-in service modules, you've reimplemented them and shadowed the RPC services.
This undocumented feature is really annoying though, and breaks the url -> service/method mapping we (or at least I) expect. How about this:
RESTful services and non-conflicting custom services go here: /services/rest/service/method
Services (built-in or custom) that conflict with built-in RESTful services or are named whatever keyword you chose to use in this url (i.e. if someone named a custom service "chain" or "shadow") go here: /services/rest/[chain|noconflict|shadow]/service/method
Comment #5
marcingy commentedComment #6
karthi.srinivasan commentedFYI : My versions of packages. Drupal 6.16, Services 6.x-2.2
To call the web service(without authentication and can be accessible to anonymous user)
written in drupal, The following configurations has to be made in your HTTP Request
1. The method should be POST
2. The Content Type should be application/x-www-form-urlencoded
3. The URL should have the following syntax for the web service SERVICE_NAME.METHOD_NAME
Syntax : http://localhost/acquia-drupal/services/rest/service_SERVICE_NAME/METHOD...
Eg : http://localhost/acquia-drupal/services/rest/service_recipe/echo
4. Make sure you are passing permission string in access arguments of your web service in case you are not using access callback. And this permission enabled for anonymous user in Usermanagement -> Permissions page.
To check this web service from firefox browser, use the following firefox client
To download : https://addons.mozilla.org/en-US/firefox/addon/9780/
This firefox addon called REST Client can be used to call web services with
different methods(GET, POST, PUT, DELETE).
After this client installed :
Steps to test the web service with this REST client in firefox browser:
1. Open the REST client by navigating through Tools -> REST Client
2. Select REST Reqest method as POST
3. Enter the url of the web service (For ref see above in this comment)
4. Set content type as "application/x-www-form-urlencoded" by following the below steps
A. Click on Add Request Header
B. Enter "Content-Type" in name text box
C. Enter "application/x-www-form-urlencoded" and Press ok
D. Click send button
For more help, have a look at the attached Screenshot.png.
5. If you see in the Response of this request, you can find whatever you have sent from the webservice.
:)
Comment #7
marcingy commentedPlease do not randomly reopen threads
Comment #8
jayakrishnanj commentedI need to accesss user.save method ...
what is the url I should provide to the develloper, so that He will pass new users to this method...
Please give some example...
Comment #9
marcingy commentedSee #7