2008-12-05 25 views

回答

2

你可以將其他服務包裝在一個類中嗎?經過充分測試,它僅僅是一個想法...

 
class MySoapService 
{ 
    public function __construct() 
    { 
    $this->_service1 = new Service1(); 
    $this->_service2 = new Service2(); 
    } 

    // You could probably use __call() here and intercept any calls, 
    // thus avoiding the need for these declarations in the wrapper class... 

    public function add($a, $b) 
    { 
    return $this->_service1->add($a, $b); 
    } 

    public function sub($a, $b) 
    { 
    return $this->_service2->sub($a, $b); 
    } 
} 

class Service1 
{ 
    public function add($a, $b) 
    { 
    return $a + $b; 
    } 
} 

class Service2 
{ 
    public function sub($a, $b) 
    { 
    return $a - $b; 
    } 
} 
0

另取同一總體思路(代理類) - 爲PHP5 使用哈希函數來映射到回調。例如,該類也可以使用反射API並添加來自對象的所有pulic方法。

0

如果這兩個類的方法名稱相同(但參數不同),則可以使用func_get_args()來分析參數並區分這兩種方法。

如果他們採取相同的論點......那麼你有點卡住了。

爲什麼你不能只使用兩個單獨的Web服務?

相關問題