Community Documentation

Services API Documentation

Comments

SOAP server module

There's not much documentation for the Drupal soap_server module so as a rank newbie this wasn't particularly obvious. Anyway ...

To endow your new "whatever" module with a SOAP Web Services interface, you need to:

  1. install services module in sites/all/modules/ dir
  2. install soap_server in sites/all/modules/ dir
  3. install nuSoap php package in sites/all/modules/soap_server
  4. in administer->site-building->modules interface enable Services module
  5. likewise enable Services Key Authentication
  6. enable Services System Service
  7. enable Services User Service
  8. enable SOAP Server
  9. Save config
  10. navigate to administer->site-building -> Services->settings
  11. select Key authentication (otherwise you only get boolean:true SOAP responses)
  12. disable "Use keys"
  13. disable "Use sessid"
  14. save settings

At this point, you can implement hook_service() in your module - as in e.g. the "Echo service" example above. Then:

  1. Navigate to administer->Site building-> Services and select system.cacheClearAll
  2. Call method (this rebuilds the list of services IIUC).
  3. Navigate to administer->Site building-> Services and select SOAP - /services/soap to see a beautified represention of the Web Service interfaces
  4. Navigate (manually) to the url http://your.host/?q=services/soap/wsdl to obtain the WSDL description
  5. http://your.host/?q=services/soap is your WS endpoint address
  6. build a client
  7. get upset when your auto generated service function calls have embedded "." in the function names
  8. ...
  9. profit!

Probably this info should go some place else, but I don't know where.
Thanks to Ilo for pointing this out to me.

confirmation on this instruction please

3. install nuSoap php package in sites/all/modules/soap_server

Is this where the nuSoap php package is suppose to go for certain?

just a thought on next version of services. Why not put the package in /sites/libraries/services/soap_server next time.

Odd, but it happened to me...

Thank you for this. just wanted to add that when I tried to follow this, I found out that my services/services.module had this line in services_get_all() function:

services_strip_hashes()

this means, of course that the hashes are removed from array keys. however, my soap_server.module is still using hashes, like: $method['#method'].

this results in the NUSOAP.php to fail with this message:

You must specify a name when registering an operation

since $method['#method'] is null. once I edited the soap_server.module file and removed the incorrect hashes, it worked.

Cheers,
Rex

Confirmed

Once I removed the # signs from the soap_server.module I stopped receiving this error.

Another thing:

array(
'#method' => 'price.echo',
'#callback' => 'price_echo',
//'#auth' => false,
'#return' => 'struct',
'#args' => array(
array(
'#name' => 'message',
'#type' => 'string',
'#description' => t('The message to return.'),
)),
'#help' => t('Returns an object containing a sessid and user.')
)

I can't seem to get more than one argument in the array.

I've tried the following:

'#args' => array(
array(
'#name' => 'message',
'#type' => 'string',
'#description' => t('The message to return.'),
),
array(
'#name' => 'message1',
'#type' => 'string',
'#description' => t('The message to return.'),
)
),

I only get a "Access denied". I've cleared the cache but nothing helps? Can this be true?

This may help:

Develop for Drupal

Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.