Last updated 3 November 2016. Created on 2 April 2011.
Edited by wildflower_0001, amalaer. Log in to edit this page.


This section describes by example how to consume a SOAP web service using the Web service client module from within Rules.


We use a temperature conversion example:

  1. User input: a temperature value in Celsius
  2. Temperature conversion to Fahrenheit by web service (
  3. Display value in Fahrenheit

(See illustration.)


  1. Add a web service description
  2. Node form (create node) for user input
  3. Workflow with Rules (screenshot)
  • Event: after saving new content
  • Condition: content is of given type
  • Action: create a data structure
  • Action: call web service (using Web service client)
  • Action: display result


  • Drupal 7 (time of writing: 7.0)
  • Rules modules (time of writing: 7.x-2.0-beta1)
    • Rules
    • Rules UI
  • Web service client modules (time of writing: 7.x-1.0-alpha3)
    • Web service client
    • Web service client SOAP
    • Web service client UI
  • PHP filter (time of writing: 7.0) optional: will be mentioned where needed


(All screenshots as a gallery.)

  1. Administration -> Configuration -> Web services -> Web service descriptions -> Add web service description (screenshot)

    Web service description saved without errors (screenshot)

  2. Add content type "Celsius to Fahrenheit" with a float field for the temperature input (screenshot)
  3. Administration -> Configuration -> Workflow -> Rules -> Add new rule: "Celsius to Fahrenheit" on event "After saving new content" (screenshot)
  4. Administration -> Configuration -> Workflow -> Rules -> Editing reaction rule "Celsius to Fahrenheit"
    • Add condition: Content is of type "Celsius to Fahrenheit" (screenshot)
    • Add a new action: Create a data structure
      • Select the action to add: Data > Create a data structure (screenshot)
      • TYPE: Value: "Temperature Converter: CelsiusToFahrenheit" (screenshot)
      • Continue
      • CELSIUS: Value: [node:field-ctf-temp] (the name of the temperature input field) (screenshot)
      • Provided variables: CREATED DATA (screenshot)
        • Variable label: Celsius input
        • Variable name: celsius_input
      • Save
    • Add a new action: "Temperature Converter: CelsiusToFahrenheit"
      • Select the action to add: Web services > "Temperature Converter: CelsiusToFahrenheit" (screenshot)
      • Set parameters and names (screenshot)
        • PARAMETERS: Data selector: celsius-input (the name given in the data structure)
        • Provided variables: CELSIUSTOFAHRENHEITRESPONSE
          • Variable label: CelsiusToFahrenheitResponse
          • Variable name: fahrenheit_output
        • Save
    • Add a new action: Show a message on the site (Option 1: Data selector only)
      • Select the action to add: System> Show a message on the site (screenshot)
      • MESSAGE: Data selector: "fahrenheit-output:CelsiusToFahrenheitResult" (the name of the web service output) (screenshot)
      • Save
    • Add a new action: Show a message on the site (Option 2: Data selector with PHP evalution (needs PHP filter module))
      • Select the action to add: System> Show a message on the site (screenshot)
      • Message using Data selector with PHP evalution (needs PHP filter module) (screenshot)
        • MESSAGE: Data selector: "fahrenheit-output:CelsiusToFahrenheitResult"
        • MESSAGE: PHP EVALUATION: return $value . ' Fahrenheit'; (without <?php ... ?> tags)
    • Add a new action: Show a message on the site (Option 3: Direct input with PHP evalution (needs PHP filter module))
      • Select the action to add: System> Show a message on the site (screenshot)
      • Message using Direct input with PHP evalution (needs PHP filter module) (screenshot)
        • MESSAGE: Value:
          // var_dump($celsius_input); // do this to learn about the variable at hand
          // var_dump($fahrenheit_output);
          echo $celsius_input['Celsius'] . ' Celsius is ' . $fahrenheit_output->CelsiusToFahrenheitResult . ' Fahrenheit';
        • MESSAGE: PHP EVALUATION: see variable names
  5. Complete rule "Celsius to Fahrenheit" (screenshot)
    • Events
      • After saving new content
    • Conditions
      • Content is of type "Celsius to Fahrenheit"
    • Actions
      • Create a data structure "Temperature Converter: CelsiusToFahrenheit"
      • Call web service "Temperature Converter: CelsiusToFahrenheit"
      • Show a message on the site option "data selector"
      • Show a message on the site option "data selector with PHP"
      • Show a message on the site option "direct input with PHP"
  6. Create content of type "Celsius to Fahrenheit" and celebrate :-) (screenshot)

Looking for support? Visit the forums, or join #drupal-support in IRC.


mvonline’s picture

I have An input parameter with "unsignedbyte" Type;
In step 4 When I want to describe related input Field To this parameter i have a problem and cant do that.
what can I do ;
please answer To this Question

colinsjones’s picture

I'm trying to use the WSClient module to consume a remote SOAP web service on Drupal 7.2 and I'd like to view the SOAP XML before it gets dispatched to the server. Can any kind person suggest how I can do that?

I've looked at the module code and can't see a variable name I could print.

Colin Jones

colinsjones’s picture

You can see the SOAP XML by calling a PHP5 SOAP client method __getLastRequest(), after the call has been made (very useful for debugging SOAP client code).

fhojman’s picture

I get the following messages when I try to save the URL (step 1 of the instructions above):

Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in wsclient_soap_wsclient_service_form_validate() (line 100 of /homepages/17/d350495749/htdocs/Drupal/sites/all/modules/wsclient/wsclient_soap/wsclient_soap.module).
Warning: file_get_contents( [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in wsclient_soap_wsclient_service_form_validate() (line 100 of /homepages/17/d350495749/htdocs/Drupal/sites/all/modules/wsclient/wsclient_soap/wsclient_soap.module).
Error downloading the WSDL file.

Can someone help ?


gm03’s picture

i have done with the above given process & created the content of type "Celsius to Fahrenheit" but not getting any output, please help I am new to drupal

gm03’s picture

I am getting the following error :

Status messageError
Error Fahrenheit
[node:field_ctf_temp] Celsius is Error Fahrenheit
Celsius to Fahrenheit name has been created.

According to me there is some error in retreiving value from text filed coz when I directly pass the value in call function in WS_client.module file, it shows the result as follows :

Status message98.6
98.6 Fahrenheit
[node:field_ctf_temp] Celsius is 98.6 Fahrenheit
Celsius to Fahrenheit new has been created.

The code m changing is :

public function call($operation, $arguments) {
$arguments["parameters"]["Celsius"] = 37;

$client = $this->client();
try {
$response = $client->__soapCall($operation, $arguments);

return $response;
catch (SoapFault $e) {
throw new WSClientException('Error invoking the SOAP service %name, operation %operation: %error', array('%name' => $this->service->label, '%operation' => $operation, '%error' => $e->getMessage()));

cspbm’s picture

I'm calling a web service that uses complex data types as well as requires authentication by passing a user name and password. I have the data structure setup and can make the call but can't seem to tie in the user name and password into it. Can you point me in the right direction, please?

afabian’s picture

Can anyone have some information about this topic?

millerengage’s picture

I was able to edit wsclient_soap/wsclient_soap.module to incorporate authentication using SOAP headers. Here is the code I have changed:

 public function call($operation, $arguments) {
    $client = $this->client();
    if ( $this->service->name == "my_web_service" ) {
		$auth = array("user"=>"username", "password"=>"password");
		$header = new SoapHeader('NAMESPACE', 'auth', $auth, false);
    try {

You will have to get the namespace from the WSDL and check which header values need to be set.

dineshw’s picture

it is not clear on how to set headers

Dinesh Waghmare (LAMP)
UK, Surrey | India, Mumbai
Web Development | Digital Media Marketing | Strategic Consulting
m: +91 9867888266
(Drupal / Wordpress / SugarCRM )

alerivrod’s picture

Hi guys,

I developed this example easily with the SOAP architecture. Afterwards, I tried with REST arquitectures using some example webservices, given in the module Web service client examples, but im not able to do it. It just ignores the output. I follow the same proccess than for the Celsius Fahrenheit example. Do u know if that should work??

Thank u in advance.

simoneaudesigns’s picture

Hi, so I am consuming a web service, and I am able to display the content in a message, but how can I display this same content on a page, without the message? Thanks in advance for your help!

Java Experience’s picture

if looking for basic java based consumption of soap web service see:

Anonymous’s picture

not as show after consuming web services from another site, I am very clear example if someone has another example to appreciate

Horroshow’s picture

Can't complete the example. The screenshot in step #1 shows that you need to input Data Types but no detail in the description.

And in #4, after adding the 'Create a data structure' rule, there's no CELSIUS value field where to put the token [node:field-ctf-temp].

DeN_’s picture

Thank you for this article really helpful info.

How i can output information from WSDL into existing CCK fields or simply with PHP in templates without or within Rules module?

calello’s picture

Thank you for the clarifying tutorial!

If I create another field in the "Celsius to Fahrenheit" content type with a float field for the temperature output, is it possible to save the result of the conversion in it?

Thank you in advance.

MC’s picture

I am newbie to Drupal.
Installtions done=>
Drupal 7.41
Apache 2.4.9
PHP - 5.5.12
MySQL - 5.6.17

I intsalled module Web service client module and Rules. I am following below tutorial to consume a webservice in drupal

When I go to the Configuration -> Webservices ->Web service descriptions ->Add web service description then getting below error.

Notice: Undefined index: operations in wsclient_tester_form_wsclient_service_form_alter() (line 41 of C:\wamp\www\viavidrupal\sites\all\modules\wsclient\wsclient_tester\wsclient_tester.module).
Warning: Invalid argument supplied for foreach() in wsclient_tester_form_wsclient_service_form_alter() (line 41 of C:\wamp\www\viavidrupal\sites\all\modules\wsclient\wsclient_tester\wsclient_tester.module).

Please help me out

respown’s picture

That's the new SOAP URL:

respown’s picture

That's the new SOAP URL:

lmbuffetti’s picture

I'm using wsclient ( to get data from asmx. If I use the test from admin/config/services/wsclient/manage/dati_amianto (where dati_amianto is my web service) it works and get me the result.
I would use this data on my page using php to extract data from xml generated, is possibile to use this function inside a page-node?And if it is yes, how can I do that?