Use SOAP Web Service in Drupal 7

I am developing a web application in which I need to consume external web services. I looked at the WSClient module, but some, like I could not use it. Is there any other way to use an external web service in Drupal 7?

Thanks, Vishal

+3
source share
2 answers

This is resolved using the "SoapClient" in the Drupal module. Here are the steps I followed:
 1. Download the WSDL file and save it in the folder of your module.
 2. Using any WSDL to PHP converter, create a PHP file for the downloaded WSDL file
 3. Copy the generated PHP file to your Drupal module
 4. Include this generated PHP file in your function (in the Drupal module) using the following code:

$WSDLPHPPath = drupal_get_path('module', <Module Name>) .'/< generated PHP file>.php';
require_once($WSDLPHPPath);

5. Include the WSDL file using the following code:

    $WSDLPath = "http://localhost/drupal/" . drupal_get_path('module', <Module Name>) .'/<Name of WSDL file>.wsdl';
    $client = new SoapClient($WSDLPath, array('location'=><Location of the WSDL file>));

Here, the location of the WSDL file is the IP address of the server you want to connect to (for example, http://<server name or IP>/abc?wsdl)

6.Call your web method: (e.g. $client-><Web method name>)

7.Refer SoapClient documentation if you want to add parameters to the web method

+2
source

. , Drupal 7 http://drupal.org/project/feeds_soap. , Drupal 7.

+1

All Articles