类里面调用nusoap和单个函数没什么区别,例如: <?php require_once('nusoap.php'); Class ExtSOAP { public $server; public $http_raw_post_data; function __construct(){ $this->server = new soap_server(); $this->server->register('hello'); $this->http_raw_post_data = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : ''; }
function services() { $this->server->service($this->http_raw_post_data); } }// 类调用 $obj = new ExtSOAP(); $obj->services(); ?>
不需要注册所有的函数。 你做一个共用的入口函数。 class myclass{ //*********** } function runApi($methodname,$parment){//方法名,参数数组 $classname = "myclass"; call_user_func_array(array($classname, $methodname),$parment); }
<?php
require_once('nusoap.php');
Class ExtSOAP {
public $server;
public $http_raw_post_data; function __construct(){
$this->server = new soap_server();
$this->server->register('hello');
$this->http_raw_post_data = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
}
function services() {
$this->server->service($this->http_raw_post_data);
}
}// 类调用
$obj = new ExtSOAP();
$obj->services();
?>
你做一个共用的入口函数。
class myclass{
//***********
}
function runApi($methodname,$parment){//方法名,参数数组
$classname = "myclass"; call_user_func_array(array($classname, $methodname),$parment);
}