2013-04-27 38 views
1

我正在使用nusoap,並且我在使用webservices時遇到困難...我試圖返回誰使用其中一個web服務的是一個數組... 在第一種情況下我試圖返回此類型的數組:PHP Webservice沒有被使用

Array ([0] => EX123EX [1] => Test [2] => 2013/04/27 [3] => 12:06 [4] => This is a test [5] => [+]Info [-]Info) 

,對此我有:

$server->wsdl->addComplexType(
'details', 
'complexType', 
'struct', 
'all', 
'', 
array(
     'id' => array('name' => 'id', 'type' => 'xsd:string'), 
     'product' => array('name' => 'product', 'type' => 'xsd:string'), 
     'date' => array('name' => 'date', 'type' => 'xsd:string'), 
     'hour' => array('name' => 'hour', 'type' => 'xsd:string'), 
     'status' => array('name' => 'status', 'type' => 'xsd:string'), 
    'info' => array('name' => 'info', 'type' => 'xsd:string'), 
)); 

$server->register(
'getdetails', 
array('url' => 'xsd:string'), 
array('return' => 'tns:details'), 
      $namespace, 
      false, 
      'rpc', 
      'literal', 
      'details'); 

和功能:

function getdetalhes($url) 
{ 
$details = getHeader($url); 
return $details; 
} 

問題是web服務沒有被使用......當我提出請求時,我沒有答案......有了這個錯誤,我也無法繼續下一個web服務,它將返回一個具有這種結構的數組:

Array ([0] => Array () [1] => Array ([0] => 2012/12/13 [1] => 12:06 [2] => Test [3] => - [4] => Test Test [5] => Test) [2] => Array ([0] => 2012/12/13 [1] => 09:23 [2] => Test Test [3] => - [4] => Test [5] => -) [3] => Array ([0] => 2012/12/12 [1] => 17:43 [2] => Test [3] => - [4] => Test [5] => -) [4] => Array ([0] => 2012/12/12 [1] => 11:25 [2] => Test [3] => Test [4] =>Test [5] => -) 

我相信錯誤是在複雜類型的聲明,但是我想不出有什麼問題,有人可以幫我嗎?

回答

1

請確保您訪問數組的關聯關鍵字而不是索引:)

+1

哇!它真的幫助了很多隊友!謝謝!! :)你可以告訴我在主數組內傳遞數組嗎?它應該像'date'=> array(array('name'=>'date','type'=>'xsd:string')),?還是有更多的東西呢? – user1782638 2013-05-01 14:19:12

+1

不客氣!回答你的問題,我認爲複雜的類型將非常有幫助。首先,創建一個包含數據結構的複雜類型(例如汽車 - >標識,商標,型號,代碼等),然後創建另一個包含汽車陣列的類型。以下示例可以向您展示一個簡單的教程來檢索電子郵件聯繫人數組:http://www.koopman.me/2008/01/nusoap-wsdl-service-return-array-of-complex-data/ – Telmo 2013-05-03 17:23:55

+1

非常感謝您的幫助!問題解決了! ;) – user1782638 2013-05-05 15:24:42