PHP GuruPHP, MySQL, JavaScript, AJAX, MVC, Codeigniter
  • Technology
    • PHP
    • PHP Frameworks
    • MySql
    • Javascript
    • AJAX
    • React Js
    • Node JS
    • ChatGPT
  • JSON Viewer
  • XML Viewer

SOAP Client In CodeIgniter using NuSOAP PHP Toolkit

Date July 30, 2015 Author By PravinS Category PHP Frameworks

To create SOAP client in CodeIgniter, it is better to use NuSOAP (SOAP Toolkit for PHP).

Download NuSOAP Toolkit from this URL: Download

Below are the steps to create SOAP client in CodeIgniter using NuSOAP PHP Toolkit.

Step 1: After downloading NuSOAP toolkit, copy “lib” and “nusoap” folder in “application/library/” folder.

Step 2: Create one library file say “nusoap_library.php” in “application/library” folder and copy and paste below given code in “application/library/nusoap_library.php” file. It just includes “nusoap.php” library file from “lib” folder.

    class Nusoap_library
    {
       function Nusoap_library()
       {
           require_once('lib/nusoap'.EXT);
       }
    }

Step 3: SOAP request function. Copy and paste below given function to “application/library/nusoap_library.php” file.

function soaprequest($api_url, $api_username, $api_password, $service, $params)
{
	if ($api_url != '' && $service != '' && count($params) > 0)
	{
		$wsdl = $api_url."?wsdl";
		$client = new nusoap_client($wsdl, 'wsdl');
		$client->setCredentials($api_username,$api_password);
		$error = $client->getError();
		if ($error)
		{
			echo "\nSOAP Error\n".$error."\n";
			return false;
		}
		else
		{
			$result = $client->call($service, $params);
			if ($client->fault)
			{
				print_r($result);
				return false;
			}
			else
			{
				$result_arr = json_decode($result, true);
				$return_array = $result_arr['result'];
				return $return_array;
			}
		}
	}
}

Step 4: To send SOAP request to SOAP web service method, we need to load NuSOAP library in Controller where we want to use SOAP client.

$this->load->library("Nusoap_lib", "");

Step 5: SOAP service call in Controller

$api_url = WEBSERVICE_URL; // ex. http://www.example.com/index.php/soapserver
$api_username = AUTHENTICATION USERNAME;
$api_password = AUTHENTICATION PASSWORD;
$service = "addnumbers"; // from my POST <a href="https://www.php-guru.in/2013/soap-server-in-codeigniter-using-nusoap-library/" target="_blank">SOAP Server In CodeIgniter using NuSOAP PHP Toolkit</a>
$params = array('a' => 5, 'b' => 10); // input parameters to "addnumbers" medhod
if ($api_url != '')
{
	$result = $this->nusoap_lib->soaprequest($api_url, $api_username, $api_password, trim($service), $params);
	if (is_array($result) && count($result) > 0)
	{
		print_r($result);
	}
}

Hope this post will help you !!!

Tags: codeigniter nusoap library, nusoap client in codeigniter, soap client in codeigniter

Comments are currently closed.

Recent Posts

  • Comparison between CodeIgniter and Laravel
  • SOAP Client In CodeIgniter using NuSOAP PHP Toolkit
  • Pagination using PHP and MySQL – 1
  • Pagination using PHP and MySQL – 2
  • Upload Files using PHP CURL
  • Search Value in Multidimensional Array Using PHP
  • SOAP Server In CodeIgniter using NuSOAP PHP Toolkit
  • Simple JavaScript/CSS Lightbox
  • Import CSV data to MySQL Using PHP
  • Export MySQL data to CSV file Using PHP

Pages

  • ChatGPT
  • Node JS
  • PHP
  • React Js

Tag Cloud

A-Z alphabets in php AJAX alphabets using php array search in php Asynchronous JavaScript and XML CI NUSOAP library Client Side codeigniter codeigniter nusoap library coparison chart Database file upload using curl html to pdf import csv to mysql Javascript javascript css lightbox laravel lightbox MySQL nusoap client in codeigniter nusoap in codeigniter nusoap integration with codeigniter Open Source pagination in php and mysql pagination in php mysql pasination using php pdf pdf generation in codeigniter PHP php and mysql pagination php curl file upload php file upload using curl php mysql pagination php pagination php pagination function RDBMS Scripting Language search in multidimensional array Server Side language soap client in codeigniter soap in codeigniter soap server in codeigniter soap server using nusoap in codeigniter SQL TCPDF with CodeIgniter

Categories

  • AJAX
  • Javascript
  • MySql
  • PHP
    • PHP Frameworks

Recent Posts

  • Comparison between CodeIgniter and Laravel
  • SOAP Client In CodeIgniter using NuSOAP PHP Toolkit
  • Pagination using PHP and MySQL – 1
  • Pagination using PHP and MySQL – 2
  • Upload Files using PHP CURL
  • Search Value in Multidimensional Array Using PHP
  • SOAP Server In CodeIgniter using NuSOAP PHP Toolkit
  • Simple JavaScript/CSS Lightbox
  • Import CSV data to MySQL Using PHP
  • Export MySQL data to CSV file Using PHP

Tag Cloud

A-Z alphabets in php AJAX alphabets using php array search in php Asynchronous JavaScript and XML CI NUSOAP library Client Side codeigniter codeigniter nusoap library coparison chart Database file upload using curl html to pdf import csv to mysql Javascript javascript css lightbox laravel lightbox MySQL nusoap client in codeigniter nusoap in codeigniter nusoap integration with codeigniter Open Source pagination in php and mysql pagination in php mysql pasination using php pdf pdf generation in codeigniter PHP php and mysql pagination php curl file upload php file upload using curl php mysql pagination php pagination php pagination function RDBMS Scripting Language search in multidimensional array Server Side language soap client in codeigniter soap in codeigniter soap server in codeigniter soap server using nusoap in codeigniter SQL TCPDF with CodeIgniter

Advertisements

Categories

  • AJAX
  • Javascript
  • MySql
  • PHP
    • PHP Frameworks
  • Theme created by PWT. Powered by WordPress.org

Copyright © 2014 PHP Guru