我在新的web服務,並一直在尋找如何創建Web服務,在那一刻,我覺得我莫名其妙地設法使一個,但它不返回任何結果。我使用nusoap和Codeigniter。的NuSOAP web服務CodeIgniter的服務器和客戶端
WebService的服務器是在一個名爲WebServiceTester
的應用程序是爲Bills_WS
控制器充當服務器的代碼:
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";
}
}
,並調用它,我在另一個應用程序調用它(同一臺機器)在事務控制器中正在使用的ws_client庫下稱爲ussccsv1:
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);
}
}
}
我是al所以包括nusoap_lib
我使用:
class Nusoap_lib
{
function nusoap_lib()
{
include(APPPATH.'libraries/nusoap/nusoap'.EXT);
}
}
我的問題是: 1.如何調用在bills_ws
web服務?是$url
是否正確?因爲迄今它給了我404錯誤HTTP未找到。 2.是ws_client
還是bills_ws
? 3.但它給了我一個count($r)
在ws_client = 1
當我回聲它。
一直在努力學習本教程,但我似乎並沒有完全理解: - http://www.phpeveryday.com/articles/PHP-Web-Services-Fetching-Data-From-Database-P105.html - http://ellislab.com/forums/viewthread/59710/
預先感謝您。
問題解決了:用這個例子來解決這個問題: http://board.phpbuilder.com/showthread.php?10224396-php-xml-NuSoap-!working – Ponce
如果你已經解決了這個問題,請發表答案在這裏,並接受你的答案,這樣其他人也會受益。 – Sushil