I am new in webservice, and have been looking in how to create web service, at the moment, I think I somehow manage to make one but it does not return any result. I am using nusoap and also Codeigniter.
The WebService Server is in an application called WebServiceTester
below is the code for the Bills_WS
controller that serve as the server:
class Bills_WS extends CI_Controller
{
function __construct()
{
parent:: __construct ();
}
public function index()
{
$this->load->library('Nusoap_lib');
$namespace = "http://localhost:8080/webservicetester/bills_ws.php?wsdl";
$server = new nusoap_server;
$server->configureWSDL('WebServiceTester');
$server->wsdl->schemaTargetNamespace = $namespace;
$server->register('hello');
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
}
function hello()
{
return "greetings from server";
}
}
and to call it, I am calling it in another application(same machine) called ussccsv1 under ws_client library that is being used in transaction controller:
class Ws_client
{
private $CI = null;
function __construct()
{
$this->CI =& get_instance();
}
public function transaction_send_ws($param)
{
$this->CI->load->library('nuSoap_lib');
$url = 'http://localhost/webservicetester.php/bills_ws?wsdl';
$client = new nusoap_client($url);
$response = $client->call('hello');
if($client->fault)
{
echo "FAULT:".$client->faultcode;
echo "string: ".$client->faultstring;
}
else
{
$r = $response;
count($r);
echo "count".count($r);
}
}
}
I am also including the nusoap_lib
I am using:
class Nusoap_lib
{
function nusoap_lib()
{
include(APPPATH.'libraries/nusoap/nusoap'.EXT);
}
}
my questions are:
1. How do I invoke the webservice in the bills_ws
? is the $url
correct? coz so far it gives me 404 error HTTP not found.
2. Is the fault in ws_client
or bills_ws
?
3. but it gives me a count($r)
in ws_client = 1
when i echo it.
Been trying to follow this tutorial, but I don't seem to understand it fully: -http://www.phpeveryday.com/articles/PHP-Web-Services-Fetching-Data-From-Database-P105.html -http://ellislab.com/forums/viewthread/59710/
Thank you in advance.