0

I am using Drupal to create a web service for my android application. I have basic understanding of Drupal like enabling modules , themes , configuring them ; But this "Services" module is the one which I can not get in head. I downloaded services 6.2 and enabled services module and node services module

Now when I navigate to site building -> services -> node.get I get a form in which I can enter the node id and fields and this is working fine.

But I don't know how to get the response from android. I have not yet enabled xmlRPC server. I have enabled the anonymous user to visit the services page so that I don't need to get authentication or session id.

Basically I just want to see the response in my log cat in eclipse sdk for just node 1 and I will be set to go from that point.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
abhishek
  • 1,434
  • 7
  • 39
  • 71

4 Answers4

2

Services module allow using remote protocols (xmlrpc, soap, rest, etc) to communicate third-party app with Drupal.

To use it, you need to define at least one endpoint. Setup name, protocol, allowed resources (nodes, users, files, comments, etc).

For example, define xmlrpc endpoint. Then you can call it from xmlrpc client on Android.

xml-rpc exposes a set of remote methods, the most interesting are:

  • user.login - logs in user, it takes username and password as arguments
  • user.logout - logout

Node CRUD operations:

  • node.retrieve - retrieve
  • node.create - create a new node
  • node.update - update existing node
  • node.delete - delete node
  • node.index - get list of nodes

The same CRUD methods exists for other Drupal objects (files, comments, users, taxonomy_terms), only replace "node" to object name. For example: "file.create" - create file, "file.index" - retrieve list of files, and etc

If you need to authorize, you need to call "user.login" first, and if call is succeeded, store sessid and session_name values of returned method structure.

Then send value

session_name+"="+sessid

as cookie in all subsequent calls to identify the session. Also, you must enable "session authentication" checkbox in Drupal service endpoint configuration. Without it, all requests to endpoint will be executed as anonymous user.

To make your own xmlrpc service, you need to define hook_xmlrpc in your module, and expose a set of methods.

Andrew Barber
  • 39,603
  • 20
  • 94
  • 123
0

The question has been answered but I am adding what I found to be an excellent Video tutorial to integrate Drupal site with Android App.

http://www.youtube.com/watch?v=ezk_21sfEQM

user1406716
  • 9,565
  • 22
  • 96
  • 151
0

I'm not sure if this is what you are looking for, but you could use an HttpClient to access your service. See this answer for more help. Since I am not a Drupal expert, I'm not sure if you need to enable or disable xmlRPC since you have enabled these "Service" modules. With a little research (here) I did find some useful information that basically says enable xmlRPC on Drupal and import an XML-RPC client into your Android application to begin using it.

Community
  • 1
  • 1
Jack
  • 9,156
  • 4
  • 50
  • 75
  • i dont think so its httpclient method i should be using. I am very much familiar with the xml parsing and stuff and i can play along with the urls of type www.myurl.com/api.php?&param1=value1&param2=value2 like this but this stuff is different. It is like calling a url like www.myurl.com and then calling a method separately somehow like node.get and pasing in arguments separately. All this is not in a simple url :( otherwise life wud have been easy – abhishek Sep 15 '11 at 13:09
  • hey guys i have found this link http://civicactions.com/blog/2010/may/02/tutorial_code_developing_apps_iphoneipadandroid_using_drupal_base_system please check and comment – abhishek Sep 16 '11 at 10:17
  • node.get is probably just a url. like mysite.com/node.get - it might expect a POST of data. – Jack Sep 16 '11 at 14:43
0

See the Services documentation at http://drupal.org/node/783722 and http://drupal.org/node/790416 for some examples to get you started. I find these give a good introduction on how to setup and use the Services module.

nmc
  • 8,724
  • 5
  • 36
  • 68
  • Do i need to enable any server module?? since i see the node.get() method is working fine in the drupal framework and is giving me the data which i actually want. What if i dont want to go complex and just enable services module and node services and then i create some urlConnection with url http://mydomain.com/drupal-6.19/admin/build/services and then call node.get method ?? and also once connection established how may i trigger the method node.get somehow ?? – abhishek Sep 15 '11 at 13:13
  • hey dude u can check this link http://civicactions.com/blog/2010/may/02/tutorial_code_developing_apps_iphoneipadandroid_using_drupal_base_system i have to do something similar and simpler but dont know how to call node.get from the url – abhishek Sep 16 '11 at 10:18