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.

CommentFileSizeAuthor
#6 Screenshot.png97.24 KBkarthi.srinivasan

Comments

gestahl’s picture

Whoops. That line 53 is in RESTServer.inc.

Hugo Wetterberg’s picture

Project: REST Server » Services
Component: Code » Documentation
Assigned: Unassigned » Hugo Wetterberg

There 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.

Hugo Wetterberg’s picture

Version: 6.x-2.x-dev » 6.x-3.x-dev
gestahl’s picture

>>> 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

marcingy’s picture

Status: Active » Closed (won't fix)
karthi.srinivasan’s picture

Version: 6.x-3.x-dev » 6.x-2.2
Assigned: Hugo Wetterberg » karthi.srinivasan
Status: Closed (won't fix) » Needs review
StatusFileSize
new97.24 KB

FYI : 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.

:)

marcingy’s picture

Version: 6.x-2.2 » 6.x-3.x-dev
Status: Needs review » Closed (won't fix)

Please do not randomly reopen threads

jayakrishnanj’s picture

Version: 6.x-3.x-dev » 6.x-2.x-dev
Assigned: karthi.srinivasan » Unassigned
Category: feature » support
Status: Closed (won't fix) » Active

I 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...

marcingy’s picture

Status: Active » Closed (won't fix)

See #7